The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
RrotorCodeGenerator.cs
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
3 // Project rROTOR
4 // --------------------------------------------------------------------------
5 // File: RrotorCodeGenerator.cs
6 // Author: Francisco Ortin - francisco.ortin@gmail.com
7 // Description:
8 // This class encapsulates the IL CLR code generator IL.
9 // Inheritance: CodeGenerator
10 // Implements Factory method [Abstract Product].
11 // --------------------------------------------------------------------------
12 // Create date: 21-08-2007
13 // Modification date: 21-08-2007
15 
16 using System;
17 using System.Collections.Generic;
18 using System.IO;
19 using System.Text;
20 
21 using TypeSystem;
22 
23 namespace CodeGeneration {
28  #region Constructor
29  public RrotorCodeGenerator(TextWriter writer)
34  : base(writer) {
35  }
36  #endregion
37 
38  #region UnboxAny
39  // Unbox <token>
40  // Revert a boxed value type instance from the object form to its value type form. <token> specifies the value type being converted and must be a valid TypeDef or TypeRef token.
41  // This instruction takes an object reference from the stack and puts a managed pointer to the value type instance on the stack.
42 
48  public override void UnboxAny(int indent, TypeExpression type) {
49  this.ilStamentsCodeGeneration.WriteIndentation(indent);
50  this.ilStamentsCodeGeneration.WriteLine("Unbox\t{0}", type.ILType());
51  this.ilStamentsCodeGeneration.WriteLine("ldobj\t{0}", type.ILType());
52  }
53  #endregion
54 
55  #region CallVirt <token>
56  // CallVirt <token>
57  // Call the virtual method specified by <token>.
58 
67  public override void CallVirt(int indent, MethodType memberType, TypeExpression klass, string member, AST.CompoundExpression arguments) {
68  this.ilStamentsCodeGeneration.WriteIndentation(indent);
69  this.ilStamentsCodeGeneration.Write("CallVirt\t");
70  this.WriteCall(memberType, klass, member, arguments);
71  this.ilStamentsCodeGeneration.WriteLine();
72  }
73  #endregion
74  }
75 }
RrotorCodeGenerator(TextWriter writer)
Constructor of CodeGenerator.
This class encapsulates the IL CLR code generator IL.
Abstract class that represents all different types.
Representa a method type.
Definition: MethodType.cs:37
override void UnboxAny(int indent, TypeExpression type)
Writes the Unbox and ldobj instruction
override void CallVirt(int indent, MethodType memberType, TypeExpression klass, string member, AST.CompoundExpression arguments)
Writes the CallVirt instruction.