The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
VisitorCodeGeneration.cs
Go to the documentation of this file.
1 /* class CodeGenerator {
2  virtual public void comienzo() { }
3  }
4  class ILCodeGenerator : CodeGenerator {
5  override public void comienzo() { }
6  public void etiqueta() { }
7  }
8 
9  class CSharpCodeGenerator : CodeGenerator {
10  override public void comienzo() { }
11  public void whileStatment() { }
12  }
13 
14  abstract class Visitor {
15  abstract public void visit();
16  }
17 
18  class VisitorCodeGeneration<T>:Visitor where T : CodeGenerator {
19  protected T codeGenerator;
20  public VisitorCodeGeneration(T cg) { this.codeGenerator = cg; }
21  public override void visit() { this.codeGenerator.comienzo(); }
22  }
23 
24  class VisitorILCodeGeneration<T> : VisitorCodeGeneration<T> where T : ILCodeGenerator {
25  public VisitorILCodeGeneration(T cg) : base(cg) { }
26  public override void visit() {
27  this.codeGenerator.etiqueta();
28 
29  }
30  static void miMain() {
31  Visitor visitor =new VisitorILCodeGeneration<ILCodeGenerator>(new ILCodeGenerator());
32 
33  }
34  }
35  class VisitorCSharpCodeGeneration<T> : VisitorCodeGeneration<T> where T : CSharpCodeGenerator {
36  public VisitorCSharpCodeGeneration(T cg) : base(cg) { }
37  public override void visit() {
38  this.codeGenerator.whileStatment();
39  }
40  }
41 
42 */
43 
44 
45 
47 // -------------------------------------------------------------------------- //
48 // Project rROTOR //
49 // -------------------------------------------------------------------------- //
50 // File: VisitorCodeGeneration.cs //
51 // Author: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
52 // Francisco Ortin - francisco.ortin@gmail.com
53 // Daniel Zapico - daniel.zapico.rodriguez@gmail.com
54 // Description: //
55 // This class walks the AST to obtain the IL code. //
56 // Inheritance: VisitorAdapter //
57 // Implements Visitor pattern [Concrete Visitor]. //
58 // Implements Factory method (the constructor) [Creator]. //
59 // -------------------------------------------------------------------------- //
60 // Create date: 28-05-2007 //
61 // Modification date: 21-08-2007 //
63 
64 
65 
66 namespace CodeGeneration {
74  abstract class VisitorCodeGeneration<T> : VisitorCodeGenerationBase where T : CodeGenerator {
79  internal T codeGenerator;
80 
81  #region Properties
82 
83  protected virtual T CodeGenerator {
84  get { return this.codeGenerator; }
85  set { this.codeGenerator = value; }
86  }
87  #endregion
88 
89  public VisitorCodeGeneration(T codeGenerator) {
90  this.codeGenerator = codeGenerator;
91  }
92 
93  public override void Close() {
94  codeGenerator.Close();
95  }
96  public override void AddExceptionCode() {
97  this.codeGenerator.WriteCodeOfExceptions();
98  }
99 
100  }
101 }
This class walks the AST to to obtain intermediate code Thisis a layer adapter class and is the base ...
This class encapsulates the instruction used to generate the code.
override void Close()
Class used to generate de intermediate code We implement explicitly covariance in this attribute by m...