1 using TypeSystem.Operations;
4 namespace CodeGeneration.Operations {
11 private T codeGenerator;
15 this.codeGenerator = codeGenerator;
19 public override object Exec(
IntType operand,
object arg) {
27 this.codeGenerator.dup(this.indent);
28 this.codeGenerator.isinst(this.indent, CharType.Instance);
30 string notACharLabel = this.codeGenerator.NewLabel;
32 this.codeGenerator.brfalse(this.indent, notACharLabel);
33 this.codeGenerator.UnboxAny(this.indent, CharType.Instance);
35 string endLabel = this.codeGenerator.NewLabel;
37 this.codeGenerator.br(this.indent, endLabel);
38 this.codeGenerator.WriteLabel(this.indent, notACharLabel);
39 this.codeGenerator.UnboxAny(this.indent, IntType.Instance);
40 this.codeGenerator.WriteLabel(this.indent, endLabel);
47 public override object Exec(
DoubleType operand,
object arg) {
56 this.codeGenerator.dup(this.indent);
57 this.codeGenerator.isinst(this.indent, CharType.Instance);
59 string notACharLabel = this.codeGenerator.NewLabel;
61 this.codeGenerator.brfalse(this.indent, notACharLabel);
62 this.codeGenerator.UnboxAny(this.indent, CharType.Instance);
63 this.codeGenerator.convToDouble(this.indent);
65 string endLabel = codeGenerator.NewLabel;
67 this.codeGenerator.br(this.indent, endLabel);
68 this.codeGenerator.WriteLabel(this.indent, notACharLabel);
69 this.codeGenerator.dup(this.indent);
70 this.codeGenerator.isinst(this.indent, IntType.Instance);
72 string notAInt32Label = this.codeGenerator.NewLabel;
74 this.codeGenerator.brfalse(this.indent, notAInt32Label);
75 this.codeGenerator.UnboxAny(this.indent, IntType.Instance);
76 this.codeGenerator.convToDouble(this.indent);
77 this.codeGenerator.br(this.indent, endLabel);
78 this.codeGenerator.WriteLabel(this.indent, notAInt32Label);
79 this.codeGenerator.UnboxAny(this.indent, DoubleType.Instance);
80 this.codeGenerator.WriteLabel(this.indent, endLabel);
87 #region TypeVariable ...
88 public override object Exec(
TypeVariable operand,
object arg) {
105 #region TypeExpression ...
115 codeGenerator.UnboxAny(this.indent, operand);
121 public override object Exec(
StringType s,
object arg) {
127 codeGenerator.WriteLine(this.indent,
"callvirt\tinstance string [mscorlib]System.Object::ToString()");
133 ErrorManager.Instance.NotifyError(
new CodeGenerationError(
"No se ha definido la operación solicitada"));
override bool IsValueType()
True if type expression is a ValueType. Otherwise, false.
This class represent the entry wnen sending a message to an operation object derived from TypeExpress...
Abstract class that represents all different types.
Represents a generic type expression
Represent a integer type.
Represents a error produced when a MethodType has class information and tries to assign other class i...
abstract bool IsValueType()
True if type expression is a ValueType. Otherwise, false.
Represents a double type.