The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
CGLoadArrayElementOperation.cs
Go to the documentation of this file.
1 using TypeSystem.Operations;
2 using TypeSystem;
3 namespace CodeGeneration.Operations {
7  internal class CGLoadArrayElementOperation<T> : TypeSystemOperation where T : ILCodeGenerator {
8 
12  private T codeGenerator;
16  private int indent;
17 
18 
19  public CGLoadArrayElementOperation(T codeGenerator, int indent) {
20  this.codeGenerator = codeGenerator;
21  this.indent = indent;
22  }
23  public override object Exec(ClassType ct, object arg) {
24  this.codeGenerator.ldelemRef(this.indent);
25  return null;
26  }
27  public override object Exec(StringType s, object arg) {
28  this.codeGenerator.ldelemRef(this.indent);
29  return null;
30  }
31  public override object Exec(ArrayType a, object arg) {
32  this.codeGenerator.ldelemRef(this.indent);
33  return null;
34  }
35  public override object Exec(TypeVariable t, object arg)
36  {
37  if(t.Substitution != null && !t.Substitution.IsValueType())
38  this.codeGenerator.ldelemRef(this.indent);
39  else
40  this.codeGenerator.CallVirt(this.indent, "instance", "class [mscorlib]System.Object", "class [mscorlib]System.Array", "GetValue", new string[] { "int32" });
41  return null;
42  }
43 
44  public override object Exec(UnionType t, object arg) {
45  this.codeGenerator.ldelemRef(this.indent);
46  return null;
47  }
48  public override object Exec(DoubleType d, object arg) {
49  this.codeGenerator.ldelemDouble(this.indent);
50  return null;
51  }
52  public override object Exec(CharType c, object arg)
53  {
54  this.codeGenerator.ldelemChar(this.indent);
55  return null;
56  }
57  public override object Exec(TypeExpression t, object arg) {
58  this.codeGenerator.ldelemInt(this.indent);
59  return null;
60  }
61  }
62 
63 }
Representa a union type.
Definition: UnionType.cs:36
Representa an array type.
Definition: ArrayType.cs:35
Represent a string type.
Definition: StringType.cs:36
This class represent the entry wnen sending a message to an operation object derived from TypeExpress...
Represent a character type.
Definition: CharType.cs:38
Abstract class that represents all different types.
Represents a generic type expression
Definition: TypeVariable.cs:36
abstract bool IsValueType()
True if type expression is a ValueType. Otherwise, false.
Represents a double type.
Definition: DoubleType.cs:36
TypeExpression Substitution
Gets the substitution; null if it does not exist
Represents a class type.
Definition: ClassType.cs:35