The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
CGConstantFieldDefinitionInitializationOperation.cs
Go to the documentation of this file.
1 using TypeSystem.Operations;
2 using TypeSystem;
3 using ErrorManagement;
4 using AST;
5 using Tools;
6 using System.Collections.Generic;
7 using CodeGeneration.ExceptionManagement;
8 namespace CodeGeneration.Operations {
12  internal class CGConstantFieldDefinitionInitializationOperation<T> : TypeSystemOperation where T: ILCodeGenerator{
13 
17  private T codeGenerator;
21  private ConstantFieldDefinition node;
25  private object argument;
32  public CGConstantFieldDefinitionInitializationOperation(T codeGenerator, ConstantFieldDefinition node, object argument) {
33  this.codeGenerator = codeGenerator;
34  this.node = node;
35  this.argument = argument;
36  }
42  public override object Exec(NullType n, object arg) {
43  this.codeGenerator.WriteLNFieldInitialization(" = nullref");
44  return null;
45  }
51  public override object Exec(TypeExpression t, object arg) {
52  // In the following call the argument could be node.Init.ILTypeExpression, but is the same of
53  // the argument due to the dispatcher call
54  this.codeGenerator.WriteLNFieldInitialization(t);
55  this.codeGenerator.WriteLNFieldInitialization((string)this.node.Init.Accept(new VisitorCodeGeneration2(), this.argument));
56  this.codeGenerator.WriteEndOfField();
57  return null;
58  }
59 
60  }
61 }
This class represent the entry wnen sending a message to an operation object derived from TypeExpress...
Encapsulates a constant field definition.
Abstract class that represents all different types.
Represent a null type.
Definition: NullType.cs:36