17 using System.Collections.Generic;
23 namespace CodeGeneration {
51 this.UnboxAny(indent, type as UnionType);
53 this.WriteLNUnaryCommand(indent,
"unbox.any", type.
ILType());
54 else if(((TypeVariable)type).Substitution != null)
55 this.WriteLNUnaryCommand(indent,
"unbox.any", type.
ILType());
60 String finalLabel = this.NewLabel;
61 String nextLabel =
"";
62 for (
int i = 0; i < type.TypeSet.Count; i++)
64 if (!String.IsNullOrEmpty(nextLabel))
66 if (i != type.
TypeSet.Count - 1)
68 nextLabel = this.NewLabel;
70 this.isinst(indent, type.TypeSet[i]);
71 this.brfalse(indent, nextLabel);
73 this.WriteLNUnaryCommand(indent,
"unbox.any", type.TypeSet[i].ILType());
74 if (i != type.
TypeSet.Count - 1)
75 this.br(indent, finalLabel);
77 this.WriteLabel(indent, finalLabel);
81 #region CallVirt <token>
94 this.ilStamentsCodeGeneration.WriteIndentation(indent);
95 this.ilStamentsCodeGeneration.Write(
"callvirt\t");
96 this.WriteCall(memberType, klass, member, null);
97 this.ilStamentsCodeGeneration.WriteLine();
override void UnboxAny(int indent, TypeExpression type)
Writes the Unbox and ldobj instruction (Unbox.any = Unbox + ldobj)
override string ILType()
Gets the type name to use in IL code.
override void WriteLabel(int indentation, string label)
Writes a label in il. Format –indentation– LABEL:
Abstract class that represents all different types.
Represents a generic type expression
This class encapsulates the IL CLR code generator IL.
CLRCodeGenerator(TextWriter writer)
Constructor of CodeGenerator.
virtual string ILType()
Gets the type name to use in IL code.
override void CallVirt(int indent, MethodType memberType, TypeExpression klass, string member, AST.CompoundExpression arguments)
Writes the CallVirt instruction.
Representa a method type.
IList< TypeExpression > TypeSet
Gets the list of type expressions