|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.vishia.java2C.Docu.G_Instantiation
class Docu.G_Instantiation
This chapter describes some cohesion of allocation, initializing (construction), finalizing, garbage collection.
| Constructor Summary | |
|---|---|
Docu.G_Instantiation()
|
|
| Method Summary | |
|---|---|
(package private) void |
g1_kindOfInstances()
In Java there are two kinds of instances: Primitive types such as int, float. |
(package private) void |
g10_enhancedRefs()
|
(package private) void |
g11_garbageCollection()
|
(package private) void |
g12_blockHeap()
|
(package private) void |
g16_finalizing()
Java knows a method Object.finalize(), which is called from the system before the instance is removed from memory. |
(package private) void |
g2_allocation()
|
(package private) void |
g3_referencingWithMemC()
In the CRuntimeJavalike context a struct MemC {int32 size_; MemAreaC* address;}
is defined. |
(package private) void |
g5_ctor()
The four kinds of instances (see g1_kindOfInstances()) uses several kinds of constructors
to initial them with given arguments:
Primitive types doesn't need a constructor. |
(package private) void |
g7_embeddedTypes()
Embedded types are types, which are deployed in C with a simple small struct, handled call and return per value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
Docu.G_Instantiation()
| Method Detail |
|---|
void g1_kindOfInstances()
MemC, StringJC
or OS_TimeStamp, which are presented in that kind. This instances are used
embedded only. They are taken as arguments or as return-value of methods per value anytime.
They are never referenced. It is similar like primitive types. The embedded types are
short structures, only consisting of less memory words. They should pass through registers
as return value.
FieldData.modeAccess = '$'
void g2_allocation()
void g3_referencingWithMemC()
struct MemC {int32 size_; MemAreaC* address;}
is defined.
It is placed in the header file fw_MemC.h, because it is not a own concept of
CRuntimeJavalike,
but an own concept of common C-programming. This struct MemC is an answer about the question:
I have a void*-pointer to the memory, but which and how many bytes....
In generally a void*-pointer is a undefined thing. No type is given, no size is known.
A void* is a well concept in the C-language with its closure to machine level,
but not for user-level programming.
MemC is undefined in type, but defined in size.
It is a representation of raw memory. An allocation of memory with alloc_MemC(size)
returns this struct with the found address and the associated size. It is one parameter for using.
Otherwise the size is separated from the void*-pointer and mistakes are possible.
The MemC comprises only 2 register values. Therefore most of C compilers return it
in machine level in 2 register, not in a copied struct. It is efficient.
void g5_ctor()
g1_kindOfInstances()) uses several kinds of constructors
to initial them with given arguments:
INIT...(THIS, ...)-routine. The first
argument is the instance itself, not referenced. The INIT...(THIS, ...) should be
implemented as a macro anyway. Mostly it is a simple macro.
ctorM...(MemC mthis, ...)-
constructor. The memory space for the instance is given in a MemC-structure, which contains
the pointer and the length information about the memory space of the instance. The MemC-value
may be a return value of a alloc_MemC(size)-call or it is build from a given
embedded instance using a build_MemC(ref, length)-method. The ctorM-method should check
whether the memory space is large enough. It should not be assumed, that the data are initialized
with 0. The initializing should be done in the constructor.
ctorO...(ObjectJc* othis, ...)-
constructor. The memory space for the instance is given with the ObjectJc-pointer. The
ObjectJc-data should be initialized already, only the reflection information can't be set.
The size of the instance is contained in the ObjectJc-objectIdentSize value. It can be seen
as guaranteed, that the rest of values are initialized with 0 already. Either the
alloc_ObjectJc(...) method has initialized all allocated memory bytes with 0,
and it has initialized the ObjectJc-base data, or the init_ObjectJc(...)-method
should be do that.
alloc_ObjectJc(size)-call or it is build from a given
embedded instance with referencing it. The ctorO-method should check
whether the memory space is large enough.<
init_ObjectJc(ObjectJc* ythis, int sizeObj, int identObj).
This routine sets the initial values of the ObjectJc-data and sets the rest of data to 0.
void g10_enhancedRefs()
void g11_garbageCollection()
void g12_blockHeap()
void g16_finalizing()
#g5_blockHeap() the finalize method is used especially
to remove enhanced references. The references may refer other instances which were in use,
although the instance itself isn't use and it is freed therefore.
The referred instances contains backward references to the freed instance. If the enhanced
references are not cleaned, that backward references are faulty.
ClassData.bFinalizeNeed
contains the information about. It is set calling ClassData.needFinalize()
or ClassData.setBodyForFinalize(org.vishia.zbnf.ZbnfParseResultItem).
It is able to quest calling ClassData.isFinalizeNeed().
SecondPass.write_finalizeDefinition(org.vishia.zbnf.ZbnfParseResultItem, String, LocalIdents).
void g7_embeddedTypes()
FieldData.modeAccess = '$'
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||