The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
|
This class encapsulates the instruction used to generate the code. More...
Public Member Functions | |||||
CodeGenerator (TextWriter writer) | |||||
Constructor of CodeGenerator. More... | |||||
abstract void | InitialComment () | ||||
abstract void | Comment (string msg) | ||||
Writes the specified message stored in msg in a comment wrapped in the proper format of the target langage. More... | |||||
abstract void | Comment (int indent, string msg) | ||||
Writes the specified message stored in msg in a comment wrapped in the proper format of the target langage. More... | |||||
abstract void | WriteLabel (int indent, string label) | ||||
Writes the specified label. More... | |||||
abstract void | WriteType (TypeExpression type) | ||||
Writes the current type information More... | |||||
abstract void | WriteHeader (string fileName) | ||||
Writes the header of the object code file. More... | |||||
abstract void | WriteNamespaceHeader (int indent, string name) | ||||
Writes the namespace header. More... | |||||
abstract void | WriteLNClassHeader (int indent, string name, ClassType type) | ||||
Writes the class header. More... | |||||
abstract void | WriteEndOfClass (int indent, string name) | ||||
Writes the class termination More... | |||||
abstract void | WriteInterfaceHeader (int indent, string name, InterfaceType type) | ||||
Writes the interface header More... | |||||
abstract void | WriteEndOfInterface (int indent, string name) | ||||
Writes the interface termination More... | |||||
abstract void | WriteLNMethodHeader (int indent, string name, MethodType type) | ||||
Writes the method header. More... | |||||
abstract void | WriteEndOfMethod (int indent, string name) | ||||
Writes the method termination More... | |||||
abstract void | WriteParams (MethodType memberType, AST.CompoundExpression arguments) | ||||
Writes the parameters of a method More... | |||||
abstract void | WriteField (int indent, string name, FieldType type, bool constantField) | ||||
Writes the field header. More... | |||||
abstract void | WriteLNFieldInitialization (TypeExpression type) | ||||
Writes the field inicialization. More... | |||||
virtual void | WriteLNFieldInitialization (string init) | ||||
Writes the field inicialization expression. More... | |||||
abstract void | WriteEndOfField () | ||||
Writes the field termination More... | |||||
abstract void | WriteStartBlock (int indent) | ||||
Writes the class inicialization More... | |||||
abstract void | WriteEndOfBlock (int indent) | ||||
Writes the termination token More... | |||||
abstract void | AddLocalVariable (string name, TypeExpression type) | ||||
abstract void | WriteLocalVariable (int indent) | ||||
Writes the information of local variables. More... | |||||
abstract void | WriteAuxiliarLocalVariable (int indent, string id, string type) | ||||
Writes the information of local variables. More... | |||||
virtual void | WriteCodeOfExceptions () | ||||
Implements Template Method Pattern Writes the intermediate code for each exceptions to include More... | |||||
abstract void | WriteEntryPoint (int indent) | ||||
Writes the entrypoint directive. More... | |||||
virtual void | WriteEntryPoint () | ||||
abstract void | WriteTryDirective (int indent) | ||||
abstract void | WriteOpenBraceTry (int indent) | ||||
abstract void | WriteCloseBraceTry (int indent) | ||||
abstract void | WriteCatch (int indent, String type, String var) | ||||
abstract void | WriteOpenBraceCatch (int indent) | ||||
abstract void | WriteCloseBraceCatch (int indent) | ||||
abstract void | WriteFinally (int indent) | ||||
abstract void | WriteOpenBraceFinally (int indent) | ||||
abstract void | WriteCloseBraceFinally (int indent) | ||||
abstract void | WriteThrowException (int indent, DynamicExceptionManager dynException) | ||||
Checks if the type variable on the stack is a specified type or can be to promotion.
| |||||
abstract void | WriteThrowException (int indent, string ex, string[] msg) | ||||
abstract void | Box (int indent, TypeExpression type) | ||||
Writes the Box instruction More... | |||||
abstract void | BoxIfNeeded (int indent, TypeExpression type) | ||||
Makes sure to convert a type to an object More... | |||||
abstract void | UnboxAny (int indent, TypeExpression type) | ||||
Writes the Unbox instruction More... | |||||
abstract void | Unbox (int indent, TypeExpression type) | ||||
Writes the Unbox instruction More... | |||||
abstract void | CallVirt (int indent, MethodType memberType, TypeExpression klass, string member, AST.CompoundExpression arguments) | ||||
Writes the CallVirt instruction. More... | |||||
abstract void | CallVirt (int indent, PropertyType memberType, TypeExpression obj, string member, bool setProperty) | ||||
Writes the CallVirt instruction. More... | |||||
abstract void | CallVirt (int indent, string methodType, string result, string klass, string memberName, string[] args) | ||||
Writes the CallVirt instruction More... | |||||
abstract void | Call (int indent, MethodType memberType, TypeExpression obj, string member) | ||||
Writes the call instruction. More... | |||||
abstract void | Call (int indent, PropertyType memberType, TypeExpression obj, string member, bool setProperty) | ||||
abstract void | Call (int indent, string methodType, string result, string klass, string memberName, string[] args) | ||||
Writes the call instruction More... | |||||
void | Close () | ||||
Close the writer More... | |||||
virtual TypeExpression | MakeCall (int indent, InvocationExpression node, Object o, MethodType actualMethodCalled, FieldAccessExpression fieldAccessExpression, object arg) | ||||
Protected Member Functions | |
abstract void | WriteCodeOfExceptionsTemplateMethod (DynamicExceptionManager d) |
Algorithm used in WriteCodeException More... | |
Protected Attributes | |
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 | |
abstract string | NewLabel [get] |
Gets the value of the current label More... | |
This class encapsulates the instruction used to generate the code.
Definition at line 32 of file CodeGenerator.cs.
CodeGeneration.CodeGenerator.CodeGenerator | ( | TextWriter | writer | ) |
Constructor of CodeGenerator.
writer | Writer to write the intermediate code. |
Definition at line 76 of file CodeGenerator.cs.
|
pure virtual |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the Box instruction
indent | Indentation to use. |
type | Converts to this object reference. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Makes sure to convert a type to an object
indent | Indentation level |
type | The type to be promoted |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the call instruction.
indent | Indentation to use. |
memberType | Member type. |
obj | Object to access to the member. |
member | Member to call. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the call instruction.
indent | Indentation to use. |
memberType | Member type. |
obj | Object to access to the member. |
member | Member to call. |
setProperty | True if it is a set property. False if it is a get property. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the call instruction
indent | Text Indentation |
methodType | Qualifiers of the method |
result | Return type |
klass | Class type |
memberName | Name of the member |
args | Types of parameters |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the CallVirt instruction.
indent | Indentation to use. |
memberType | Member type. |
klass | Class to access to the member. |
member | Member to call. |
arguments | Actual arguments |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the CallVirt instruction.
indent | Indentation to use. |
memberType | Member type. |
obj | Object to access to the member. |
member | Member to call. |
setProperty | True if it is a set property. False if it is a get property. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the CallVirt instruction
indent | Text Indentation |
methodType | Qualifiers of the method |
result | Return type |
klass | Class type |
memberName | Name of the member |
args | Types of parameters |
Implemented in CodeGeneration.ILCodeGenerator.
void CodeGeneration.CodeGenerator.Close | ( | ) |
Close the writer
Definition at line 568 of file CodeGenerator.cs.
|
pure virtual |
Writes the specified message stored in msg in a comment wrapped in the proper format of the target langage.
msg | comment to write. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the specified message stored in msg in a comment wrapped in the proper format of the target langage.
msg | comment to write. |
indent | indentation to use |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Implemented in CodeGeneration.ILCodeGenerator.
|
virtual |
Definition at line 575 of file CodeGenerator.cs.
|
pure virtual |
Writes the Unbox instruction
indent | Indentation to use. |
type | Value type to revert. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the Unbox instruction
indent | Indentation to use. |
type | Value type to revert. |
Implemented in CodeGeneration.ILCodeGenerator, CodeGeneration.CLRCodeGenerator, and CodeGeneration.RrotorCodeGenerator.
|
pure virtual |
Writes the information of local variables.
indent | Current indentation. |
id | Auxiliar local variable identifier. |
type | Auxiliar local variable type expression. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Implemented in CodeGeneration.ILCodeGenerator.
|
virtual |
Implements Template Method Pattern Writes the intermediate code for each exceptions to include
Definition at line 340 of file CodeGenerator.cs.
|
protectedpure virtual |
Algorithm used in WriteCodeException
d | The exception to write in the code |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the termination token
indent | Indentation to use. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the class termination
indent | Indentation to use. |
name | Name of the class to terminate. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the field termination
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the interface termination
indent | Indentation to use. |
name | Name of the interface to terminate. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the method termination
indent | Indentation to use. |
name | Name of the method to terminate. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the entrypoint directive.
indent | Indentation to use. |
Implemented in CodeGeneration.ILCodeGenerator.
|
virtual |
Definition at line 366 of file CodeGenerator.cs.
|
pure virtual |
Writes the field header.
indent | Indentation to use. |
name | Field name. |
type | Field type expression. |
constantField | True if the field is a constant. Otherwise, false. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the header of the object code file.
fileName | Name of the module. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the interface header
indent | Indentation to use. |
name | Interface name. |
type | Interface type expression. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the specified label.
label | Label to write. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the class header.
indent | Indentation to use. |
name | Class name. |
type | Class type expression. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the field inicialization.
type | WriteType Expression of the field inicialization. |
Implemented in CodeGeneration.ILCodeGenerator.
|
virtual |
Writes the field inicialization expression.
type | Expression of the field inicialization. |
Definition at line 273 of file CodeGenerator.cs.
|
pure virtual |
Writes the method header.
indent | Indentation to use. |
name | Method name. |
type | Method type expression. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the information of local variables.
indent | Current indentation. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the namespace header.
indent | Indentation to use. |
name | Namespace name. |
<,
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the parameters of a method
memberType | The type of the method |
arguments | Actual arguments |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the class inicialization
indent | Indentation to use. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Checks if the type variable on the stack is a specified type or can be to promotion.
indent | Indentation level |
typeExpression | The type expression to promote to |
public abstract void RuntimeIsInstruction(int indent, TypeExpression typeExpression);
Writes the generation code to throw a specified exception.
indent | Identation to use. |
dynException | Exception to throw. |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the code to throw an exception derived from Exception without using DynamicExceptionManager .
indent | indentation to use |
ex | Name of the exception to throw |
args | arguments of the exception. If the list is empty there won't be code generation about this param |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Implemented in CodeGeneration.ILCodeGenerator.
|
pure virtual |
Writes the current type information
type | WriteType expression with the type information. |
Implemented in CodeGeneration.ILCodeGenerator.
|
protected |
Represents the value of the current label.
Definition at line 50 of file CodeGenerator.cs.
|
protected |
Stores the current information about local variables.
Definition at line 45 of file CodeGenerator.cs.
|
protected |
List of exceptions that is necessary to include in intermediate code file.
Definition at line 55 of file CodeGenerator.cs.
|
protected |
Writer to write the intermediate code.
Definition at line 40 of file CodeGenerator.cs.
|
get |
Gets the value of the current label
Definition at line 64 of file CodeGenerator.cs.