
Interfaces

Interfaces are not supported natively on the run-time platform. Since the
run-time platform is dynamically typed there is no need for interfaces in method
dispatch. However, they are still needed in explicitly typed operations such as
casts (emitCheckCast) and instanceof (emitInstanceOf).

For each interface a correponding class is generated. Since there is no
involvement in method dispatch there is no need for method signatures.
Interface fields are still needed though. 

Each generated interface class has a method called isInterface to determine if
a class is an interface class or not (TODO: That method should be removed). Each
class has a method "instanceofInterface_Z_java_lang_Object:" that returs true
for each implemented interface.

Fields

The run-time platform does only allow access to fields from the class in which
they are declared. To allow access from other classes as well we introduce
getters and setters for all fields. These are generated in InnerClasser.jrag
(TODO: should probably be moved somewhere else) by emitAccessor and
emitAccessorWrite. Each field name is prefixed by "get_" and "set_".

Class fields and static initializers

The run-time platform does not support initialization of static members when a
class is being loaded.  We approximate that behavior by a demand driven
initialization of static members when the class is first being accessed. This
is violating the Java Language Specification.

Each class has a field named isClinit, which is true when the class has been
initialized, and a corresponding method clinit, which is called to initialize
the class. A utility method emitDoClinitPRE in CodeGeneration generates a
demand driven initialization. This method is called from each static method,
constructor, static field getter, and static field setter. The utility method
doClinitPRE generates a call to the demand driven initialization.

Native methods

Each native method is replaced by a call to the corresponding method
in the "NativeJavaCoreImplementation" component. This was a quick hack to interface
external Smalltalk code and can now be considered obsolete.

Parameters and Local variables

Parameters and local variables are accessed in the current activation record
using separate indices. Each index is computed in LocalNum.jrag (TODO: fix
separate computation of parameter and variable indices.). This computation
takes nested classes, which add additional parameters, into account. 

Nested Classes

Each nested class declared in a non static context has an enclosing instance.
This property is computed by needsEnclosing in InnerClasses. An anonymous class
may in certain situations have an enclosing instance not only for itself but
also for its superclass. That property is computed by needsSuperEnclosing in
InnerClasses.

Local classes and anonymous classes may access final local variables in the
enclosing method. The set of local variables that is accessed in the enclosing
method is computed by enclosingVariables() in InnerClasses. The values of these
variables are passed as parameters to the constructor of the nested class.


get_this$0
val$name

emitLoadThis
emitLoadSuper


Non local transfer of control (exceptions, break, continue)

Relies heavily on blocks. There is an abstraction for blocks in CodeGeneration
which simplifies the use of nested blocks using a simple enter and exit scheme. 

blockDiff

Name mangling

Java method names with typed parameter lists are converted into untyped
selector based names. This conversion is done in PRENames.jrag. We include the
type names in the generated selectors to ensure unique names.

Conditional expressions

definesLabel
true_label
false_label


Array initialization

Needs to be done explicitly by the compiler. Each newly created array is
traversed and initialized either with explicitly specified values or default
values. This is done in emitNewArray in CodeGeneration.

Null values

There is a special null object used to represent null values from a Java point
of view. This object has all its methods overridden by calls to a single method
that throws a null pointer exception.  This simulates the behavior for
dereferencing null values as specified in the Java Language Specification.

Casts and numeric conversion and promotion between primitive types 

CodeGeneration holds methods to convert a particular type into another type
through a set of "emitCastTo" methods. A double dispatch scheme is used to
convert a value of "this" type into a specified type. (TODO: fix conversion
between byte, int, short, etc., taking limits into account)

Primitive operations (+,-,*,/, etc.)

The primitive operations in Java are mapped directly to method invocations
performing the same operations. These methods are usually implemented as
primitives in the VM.


Interopability with Smalltalk code

May specify the desired mangled name for a method in external descriptions of
Smalltalk classes.  This is handled by descName for methods in PRENames.


