The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
CodeGeneration.CLRCodeGenerator Class Reference

This class encapsulates the IL CLR code generator IL. More...

Inheritance diagram for CodeGeneration.CLRCodeGenerator:
CodeGeneration.ILCodeGenerator CodeGeneration.CodeGenerator

Public Member Functions

 CLRCodeGenerator (TextWriter writer)
 Constructor of CodeGenerator. More...
 
override void UnboxAny (int indent, TypeExpression type)
 Writes the Unbox and ldobj instruction (Unbox.any = Unbox + ldobj) More...
 
override void CallVirt (int indent, MethodType memberType, TypeExpression klass, string member, AST.CompoundExpression arguments)
 Writes the CallVirt instruction. More...
 
- Public Member Functions inherited from CodeGeneration.ILCodeGenerator
 ILCodeGenerator (TextWriter output)
 
override void InitialComment ()
 Displays de comment to show in the first line of il file. More...
 
override void Comment (string msg)
 Writes the specified message as a comment in il language More...
 
override void Comment (int indent, string msg)
 
override void WriteLabel (int indentation, string label)
 Writes a label in il. Format –indentation– LABEL:
More...
 
override void WriteType (TypeExpression type)
 Writes the current type information More...
 
override void WriteHeader (string fileName)
 Writes the header of the il code file. More...
 
override void WriteNamespaceHeader (int indent, string name)
 Writes the namespace header of an IL file. More...
 
virtual void WriteClassName (string name)
 
virtual void WriteClassExtends (ClassType type)
 
virtual void WriteClassImplements (ClassType type)
 
override void WriteLNClassHeader (int indent, string name, ClassType type)
 Writes the class header in IL code More...
 
override void WriteEndOfClass (int indent, string name)
 Writes the class termination acoording to IL code More...
 
override void WriteInterfaceHeader (int indent, string name, InterfaceType type)
 Writes the interface header More...
 
override void WriteEndOfInterface (int indent, string name)
 Writes the interface termination More...
 
virtual void ProcessField (int indent, FieldDeclaration node, Object obj, bool constantField)
 
override void WriteField (int indent, string name, FieldType type, bool constantField)
 Writes the field header. More...
 
override void WriteLNFieldInitialization (TypeExpression type)
 Writes the field inicialization. More...
 
override void WriteEndOfField ()
 Writes the field termination More...
 
override void WriteStartBlock (int indent)
 Writes the block inicialization More...
 
override void WriteEndOfBlock (int indent)
 Writes the termination token More...
 
override void WriteLNMethodHeader (int indent, string name, MethodType type)
 Writes the method header. More...
 
virtual void WriteMethodTypeOfAccess (string name, MethodType type)
 
virtual void WriteMethodParameters (MethodType type)
 
override void WriteEndOfMethod (int indent, string name)
 Writes the method termination. It writes also en end of line More...
 
override void WriteParams (MethodType memberType, AST.CompoundExpression arguments)
 
override void AddLocalVariable (string name, TypeExpression type)
 Stores the information of the local variable. More...
 
override void WriteLocalVariable (int indent)
 Writes the information of local variables. More...
 
override void WriteAuxiliarLocalVariable (int indent, string id, string type)
 Writes the information of local variables. More...
 
override void WriteEntryPoint (int indent)
 Writes the entrypoint directive. More...
 
override void WriteTryDirective (int indent)
 
override void WriteOpenBraceTry (int indent)
 
override void WriteCloseBraceTry (int indent)
 
void WriteRethrow (int indent)
 
override void WriteCatch (int indent, String type, String var)
 
override void WriteOpenBraceCatch (int indent)
 
override void WriteCloseBraceCatch (int indent)
 
override void WriteFinally (int indent)
 
override void WriteOpenBraceFinally (int indent)
 
override void WriteCloseBraceFinally (int indent)
 
virtual void WriteThrowMissingMethodException (int indent, string method)
 
virtual void WriteThrowNonSuitableObjectException (int indent, string klass, string method)
 
void AddExceptionCode (DynamicExceptionManager typeException)
 Adds the information of specified exception to include in intermediate code file. More...
 
virtual void Exit (int indent, int res)
 Checks if the union type can to promote to the specified type. More...
 
void Promotion (int indent, TypeExpression typeExp1, TypeExpression certainType1, TypeExpression typeExp2, TypeExpression certainType2, bool unidirectionalConversion, bool makeBoxing)
 Writes the il code to promote typeExp1 to typeExp2 More...
 
override void WriteThrowException (int indent, DynamicExceptionManager dynException)
 Writes the generation code to throw a specified exception. More...
 
override void WriteThrowException (int indent, string ex, string[] msg)
 Writes the code to throw an exception derived from Exception without using DynamicExceptionManager . More...
 
void ldobj (int indent, TypeExpression val)
 Writes the ldobj instruction. More...
 
void ldstr (int indent, string val)
 Writes the ldstr instruction. More...
 
void ldnull (int indent)
 Writes the ldnull instruction. More...
 
void newobj (int indent, MethodType memberType, TypeExpression obj, string member)
 Writes the newobj instruction. More...
 
void newobj (int indent, string klass, string[] args)
 Writes the newobj instruction More...
 
void castclass (int indent, TypeExpression token)
 Writes the castclass instruction. More...
 
void WriteThrow (int indent)
 Writes the throw instruction. More...
 
void ldarg (int indent, int argNumber)
 ldarg <unsigned int16>=""> Load the argument number <unsigned int16>=""> on the stack. The argument enumeration is zero-based, but it’s important to remember that instance methods have an 'invisible' argument not specified in the method signature: the class instance pointer, this, which is always argument number 0. Because static methods don’t have such an 'invisible' argument, for them argument number 0 is the first argument specified in More...
 
void ldarg (int indent, string argName)
 Writes the ldarg instruction. Unsing argument names instead of numbers. See ldar(int, int) above More...
 
void ldarga (int indent, string argName)
 Writes the ldarga instruction, that loads the direction of argument with name argName. More...
 
void starg (int indent, int argNumber)
 starg <unsigned int16>=""> Take a value from the stack and store it in argument slot number <unsigned int16>="">. The value on the stack must be of the same type as the argument slot or must be convertible to the type of the argument slot. The convertibility rules and effects are the same as those for conversion operations, discussed earlier in this chapter. With vararg methods, the starg instruction cannot target the arguments of the variable part of the signature. More...
 
void starg (int indent, string argNumber)
 Writes the starg instruction. More...
 
void arglist (int indent)
 Writes the arglist instruction. More...
 
void add (int indent)
 Writes the add instruction. More...
 
void concat (int indent)
 Writes the concat instruction for string types. More...
 
void mul (int indent)
 Writes the mul instruction. More...
 
void div (int indent)
 Writes the div instruction. More...
 
void neg (int indent)
 Writes the neg instruction. More...
 
void rem (int indent)
 Writes the rem instruction. More...
 
void sub (int indent)
 Writes the sub instruction. More...
 
void and (int indent)
 Writes the and instruction. More...
 
void or (int indent)
 Writes the or instruction. More...
 
void xor (int indent)
 Writes the xor instruction. More...
 
void not (int indent)
 Bitwise inversion (unary). This operation, rather than neg, is recommended for integer sign inversion because neg has a problem with the maximum negative numbers: More...
 
override void Box (int indent, TypeExpression type)
 Writes the Box instruction More...
 
override void BoxIfNeeded (int indent, TypeExpression type)
 Makes sure to convert a type to an object More...
 
virtual void UnBoxIfNeeded (int indent, TypeExpression type)
 Convert and OBject to a valuetype if is not an reference type /// More...
 
override void Unbox (int indent, TypeExpression type)
 Writes the Unbox instruction More...
 
override void Call (int indent, MethodType memberType, TypeExpression obj, string member)
 Writes the call instruction. More...
 
override void Call (int indent, PropertyType memberType, TypeExpression obj, string member, bool setProperty)
 Writes the call instruction. More...
 
override void Call (int indent, string methodType, string result, string klass, string memberName, string[] args)
 Writes the call instruction More...
 
override void CallVirt (int indent, MethodType memberType, TypeExpression klass, string member, AST.CompoundExpression arguments)
 Writes the CallVirt instruction. More...
 
override void CallVirt (int indent, PropertyType memberType, TypeExpression obj, string member, bool setProperty)
 Writes the CallVirt instruction. More...
 
override void CallVirt (int indent, string methodType, string result, string klass, string memberName, string[] args)
 Writes the CallVirt instruction More...
 
void beq (int indent, string label)
 Writes the beq instruction. More...
 
void bne (int indent, string label)
 Writes the bne instruction. More...
 
void bge (int indent, string label)
 Writes the bge instruction. More...
 
void bgt (int indent, string label)
 Writes the bgt instruction. More...
 
void ble (int indent, string label)
 Writes the ble instruction. More...
 
void blt (int indent, string label)
 Writes the blt instruction. More...
 
void ldci4 (int indent, int val)
 Writes the ldc.i4 instruction. More...
 
void ldcr8 (int indent, string val)
 Writes the ldc.i8 instruction. More...
 
void ldc (int indent, bool val)
 Writes the ldc instruction. More...
 
void ldtoken (int indent, string ILType)
 Writes the ldtoken instruction. More...
 
void constructorCall (int indent, MethodType memberType, TypeExpression obj, string member)
 Writes the call instruction. More...
 
void constructorCall (int indent, TypeExpression obj, string member)
 Writes the call instruction. More...
 
void convToInt (int indent)
 Writes the conv.i4 instruction. More...
 
void convToChar (int indent)
 Writes the conv.u2 instruction. More...
 
void convToDouble (int indent)
 Writes the conv.r8 instruction. More...
 
void ldfld (int indent, TypeExpression type, string classId, string fieldName)
 Writes the ldfld instruction. More...
 
void ldsfld (int indent, TypeExpression type, string classId, string fieldName)
 Writes the ldsfld instruction. More...
 
void ldflda (int indent, TypeExpression type, string classId, string fieldName)
 Writes the ldflda instruction. More...
 
void ldflda (int indent, string token)
 Writes the ldflda instruction. More...
 
void ldsflda (int indent, TypeExpression type, string classId, string fieldName)
 Writes the ldsflda instruction. More...
 
void ldsflda (int indent, string token)
 Writes the ldsflda instruction. More...
 
void stfld (int indent, TypeExpression type, string classId, string fieldName)
 Writes the stfld instruction. More...
 
void stsfld (int indent, TypeExpression type, string classId, string fieldName)
 Writes the stsfld instruction. More...
 
void ret (int indent)
 Writes the ret instruction. More...
 
void ldloc (int indent, int locNumber)
 Writes the ldloc instruction. More...
 
void ldloc (int indent, string locVar)
 Writes the ldloc instruction. More...
 
void ldloca (int indent, int locNumber)
 Writes the ldloca instruction. More...
 
void ldloca (int indent, string locVar)
 Writes the ldloca instruction. More...
 
void ldloca_s (int indent, string tmpVar)
 loads the content of variable tmpVar in the top of the stack More...
 
void stloc (int indent, int locNumber)
 Writes the stloc instruction. More...
 
void stloc_s (int indent, string variable)
 Writes the stloc.s instruction. More...
 
void stloc (int indent, string locVar)
 Writes the ldloc instruction. More...
 
void ceq (int indent)
 Writes the ceq instruction. More...
 
void cgt (int indent)
 Writes the cgt instruction. More...
 
void clt (int indent)
 Writes the clt instruction. More...
 
void isinst (int indent, TypeExpression token)
 Writes the isinst instruction. About the isinst Instruction. It takes two arguments: an object reference and a metadata token representing the type of reference desired. It generates code that examines the object's type handle to determine whether or not the object's type is compatible with the requested type. If the test succeeds, it leaves the object reference on the evaluation stack. If the test fails, puts a null reference onto the evaluation stack if the test fails More...
 
void shl (int indent)
 Writes the shl instruction. More...
 
void shr (int indent)
 Writes the shr instruction. More...
 
void nop (int indent)
 Writes a nop instruction. More...
 
void dup (int indent)
 Writes a dup instruction. More...
 
void pop (int indent)
 Writes a pop instruction. More...
 
void WriteLeave (int indentation, string label)
 Write leave.s label More...
 
void br (int indent, string label)
 Writes the br instruction. More...
 
void brfalse (int indent, string label)
 Writes the brfalse instruction. More...
 
void brtrue (int indent, string label)
 Writes the brtrue instruction. More...
 
virtual void newarr (int indent, TypeExpression token)
 Writes the newarr instruction. More...
 
virtual void newarr (int indent, string type)
 Writes the newarr instruction. More...
 
virtual void ldlen (int indent, TypeExpression token)
 Writes the ldlen instruction. More...
 
virtual void ldelemInt (int indent)
 Writes the ldelem.i4 instruction. More...
 
virtual void ldelemChar (int indent)
 Writes the ldelem.u2 instruction. More...
 
virtual void ldelemDouble (int indent)
 Writes the ldelem.r8 instruction. More...
 
virtual void ldelemRef (int indent)
 Writes the ldelem.ref instruction. More...
 
virtual void stelemInt (int indent)
 Writes the stelem.i4 instruction. More...
 
virtual void stelemDouble (int indent)
 Writes the stelem.r8 instruction. More...
 
virtual void stelemRef (int indent)
 Writes the stelem.ref instruction. More...
 
void WriteLine (int indentation, string msg)
 
void WriteLine ()
 
- Public Member Functions inherited from CodeGeneration.CodeGenerator
 CodeGenerator (TextWriter writer)
 Constructor of CodeGenerator. More...
 
virtual void WriteLNFieldInitialization (string init)
 Writes the field inicialization expression. More...
 
virtual void WriteCodeOfExceptions ()
 Implements Template Method Pattern Writes the intermediate code for each exceptions to include More...
 
virtual void WriteEntryPoint ()
 
void Close ()
 Close the writer More...
 
virtual TypeExpression MakeCall (int indent, InvocationExpression node, Object o, MethodType actualMethodCalled, FieldAccessExpression fieldAccessExpression, object arg)
 

Additional Inherited Members

- Protected Member Functions inherited from CodeGeneration.ILCodeGenerator
virtual void WriteLNMethodEndOfHeader ()
 
virtual void WriteMethodModifiers (int indent, MethodType type)
 
bool IsValueType (TypeExpression exp)
 
override void WriteCodeOfExceptionsTemplateMethod (DynamicExceptionManager d)
 Implements Template Method More...
 
virtual void WriteCallArguments (MethodType memberType, TypeExpression klass, string member, AST.CompoundExpression arguments)
 Writes the 'token' of call instructions. More...
 
virtual void WriteCall (MethodType memberType, TypeExpression klass, string member, AST.CompoundExpression arguments)
 Writes the 'token' of call instructions. More...
 
- Protected Attributes inherited from CodeGeneration.ILCodeGenerator
ILStatementsCodeGeneration ilStamentsCodeGeneration
 
- Protected Attributes inherited from CodeGeneration.CodeGenerator
TextWriter output
 Writer to write the intermediate code. More...
 
StringBuilder currentLocalVars
 Stores the current information about local variables. More...
 
int currentLabel
 Represents the value of the current label. More...
 
Dictionary< string,
DynamicExceptionManager
exceptions
 List of exceptions that is necessary to include in intermediate code file. More...
 
- Properties inherited from CodeGeneration.ILCodeGenerator
override string NewLabel [get]
 
int LocalVariableIndex [get, set]
 
- Properties inherited from CodeGeneration.CodeGenerator
abstract string NewLabel [get]
 Gets the value of the current label More...
 

Detailed Description

This class encapsulates the IL CLR code generator IL.

Definition at line 27 of file CLRCodeGenerator.cs.

Constructor & Destructor Documentation

CodeGeneration.CLRCodeGenerator.CLRCodeGenerator ( TextWriter  writer)

Constructor of CodeGenerator.

Parameters
writerWriter to write the intermediate code.

Definition at line 33 of file CLRCodeGenerator.cs.

Member Function Documentation

override void CodeGeneration.CLRCodeGenerator.CallVirt ( int  indent,
MethodType  memberType,
TypeExpression  klass,
string  member,
AST.CompoundExpression  arguments 
)

Writes the CallVirt instruction.

Parameters
indentIndentation to use.
memberTypeMember type.
klassClass to access to the member.
memberMember to call.
argumentsActual arguments

Definition at line 93 of file CLRCodeGenerator.cs.

override void CodeGeneration.CLRCodeGenerator.UnboxAny ( int  indent,
TypeExpression  type 
)
virtual

Writes the Unbox and ldobj instruction (Unbox.any = Unbox + ldobj)

Parameters
indentIndentation to use.
typeValue type to revert.

Implements CodeGeneration.ILCodeGenerator.

Definition at line 49 of file CLRCodeGenerator.cs.


The documentation for this class was generated from the following file: