1 using TypeSystem.Operations;
6 using System.Collections.Generic;
7 using CodeGeneration.ExceptionManagement;
9 namespace CodeGeneration.Operations {
13 internal class CGVisitDefinitionNodeOperation<T> :
AstOperation where T : ILCodeGenerator {
18 private T codeGenerator;
26 private object argument;
27 private VisitorILCodeGeneration<T> visitor;
36 public CGVisitDefinitionNodeOperation(VisitorILCodeGeneration<T> visitor,
Definition node, T codeGenerator,
int indent,
object argument) {
38 this.codeGenerator = codeGenerator;
40 this.visitor = visitor;
41 this.argument = argument;
45 this.BeginOfOperation();
47 if (methodType != null) {
49 if (this.node.Init.ILTypeExpression.IsValueType() && !methodType.Return.IsValueType())
50 this.codeGenerator.Promotion(this.indent, methodType.Return, methodType.Return, this.node.TypeExpr, this.node.ILTypeExpression,
true, this.visitor.CheckMakeAnUnbox(this.node.Init));
52 this.codeGenerator.Promotion(this.indent, this.node.Init.ExpressionType, this.node.Init.ILTypeExpression, this.node.TypeExpr, this.node.ILTypeExpression,
true, this.visitor.CheckMakeAnUnbox(this.node.Init));
54 return this.EndOfOperation();
56 public override object Exec(
AstNode exp,
object arg) {
57 this.BeginOfOperation();
58 this.codeGenerator.Promotion(this.indent, this.node.Init.ExpressionType, this.node.Init.ILTypeExpression, this.node.TypeExpr, this.node.ILTypeExpression,
true, this.visitor.CheckMakeAnUnbox(this.node.Init));
59 return this.EndOfOperation();
61 protected virtual object EndOfOperation() {
62 this.codeGenerator.stloc(this.indent, this.node.ILName);
63 this.codeGenerator.WriteLine();
66 protected virtual void BeginOfOperation() {
67 this.node.Init.Accept(this.visitor, this.argument);
Encapsulates a invocation expression.
Encapsulates a definition.
This class represent the entry wnen sending a message to an operation object. derived from AstNode ...
Abstract class for all nodes that compounds the abstract syntax tree.
Representa a method type.