The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
VisitorCodeGenerationBase.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 
46 
47 
48 
49 
50 
51 
53 // -------------------------------------------------------------------------- //
54 // Project rROTOR //
55 // -------------------------------------------------------------------------- //
56 // File: VisitorCodeGenerationBase.cs //
57 // Author: //
58 // Description: //
59 // This class walks the AST to obtain the IL code. //
60 // Inheritance: VisitorAdapter //
61 // Implements Visitor pattern [Concrete Visitor]. //
62 // Implements Factory method (the constructor) [Creator]. //
63 // -------------------------------------------------------------------------- //
64 // Create date: 28-05-2007 //
65 // Modification date: 21-08-2007 //
67 
68 using System;
69 using System.Collections.Generic;
70 using System.IO;
71 using System.Text;
72 
73 using AST;
74 using Tools;
75 using TypeSystem;
76 using ErrorManagement;
77 
78 namespace CodeGeneration
79 {
94  // helper methods
95  //public abstract void AddExceptionCode();
96 
97  public abstract void Close();
98  public abstract void AddExceptionCode();
99  }
100 }
abstract void Close()
Class used to generate de intermediate code We implement explicitly covariance in this attribute by m...
This class walks the AST to to obtain intermediate code Thisis a layer adapter class and is the base ...
Abstract class to define different visits over the abstract syntax tree. It makes a deep walker...