The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
CGVisitArithmeticalOp.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 using AST.Operations;
9 namespace CodeGeneration.Operations {
13  internal class CGVisitArithmeticalOp<T> : TypeSystemOperation where T : ILCodeGenerator {
14 
18  private T codeGenerator;
22  private int indent;
23  //visitor argument
24  private object obj;
25  private ArithmeticExpression node;
26  private VisitorILCodeGeneration<T> visitor;
27  // * TypeExpression alias abvreviate operand1 and operand2
28  //private TypeExpression t1, t2;
29 
37  string globalEnd;
38  string FirstOperatorLabel;
39  public CGVisitArithmeticalOp(VisitorILCodeGeneration<T> visitor, ArithmeticExpression node, T codeGenerator, int indent, object obj) {
40  this.node = node;
41  this.codeGenerator = codeGenerator;
42  this.indent = indent;
43  this.visitor = visitor;
44  this.node = node;
45  this.obj = obj;
46  this.globalEnd = codeGenerator.NewLabel;
47  this.FirstOperatorLabel = codeGenerator.NewLabel;
48 
49  }
51 
52  //public override object Exec(AstNode a, object arg) {
53  // CheckFirstOperand();
54 
55  //}
58  //private void CheckFirstOperand() {
59  // TypeExpression t1 = node.FirstOperand.ExpressionType;
60  // this.node.Accept(this.visitor, this.obj);
61  // if ( TypeExpression.Is<UnionType>(t1) )
62  // FirstOperandAsUnion(TypeExpression.As<UnionType>(t1));
63  // else
64  // CheckSecondOperand(t1);
65 
66  //}
67 
68 
74  //private void CheckSecondOperand(TypeExpression typeExpression) {
75  // // this accept is done in order to push the second operand in the top of the stack
76  // // but it will be neccesary to pop it out if a promotion in the first operand is needed
77  // // that,is because the first operand is now just behind the second operand in the stack
78  // node.SecondOperand.Accept(this.visitor, this.obj);
79  // TypeExpression t2 = node.FirstOperand.ExpressionType;
80  // if ( TypeExpression.Is<UnionType>(t2) )
81  // SecondOperandAsUnion(t1, TypeExpression.As<UnionType>(t2));
82  // else
83  // FirstAndSecondOperandAsNonUnionTypes(t1, t2);
84  //}
85 
86  //private void FirstOperandAsUnion(UnionType ut) {
87  // foreach ( TypeExpression ti in ut.TypeSet )
88  // if ( TypeExpression.Is<UnionType>(ti) )
89  // FirstOperandAsUnion(TypeExpression.As<UnionType>(ti));
90  // else {
91  // string skipFirstOperandLabel = this.codeGenerator.NewLabel;
92  // this.codeGenerator.dup(this.indent);
93  // this.codeGenerator.isinst(this.indent, ti);
94  // this.codeGenerator.brfalse(this.indent, skipFirstOperandLabel);
95  // CheckSecondOperand(ti);
96  // this.codeGenerator.WriteLabel(this.indent, skipFirstOperandLabel);
97  // }
98  //}
99  //private void SecondOperandAsUnion(TypeExpression t1, UnionType ut) {
100  // foreach ( TypeExpression ti in ut.TypeSet )
101  // if ( TypeExpression.Is<UnionType>(ti) )
102  // SecondOperandAsUnion(TypeExpression.As<UnionType>(ti));
103  // else {
104  // string skipSecondOperandLabel = this.codeGenerator.NewLabel;
105 
106  // this.codeGenerator.dup(this.indent);
107  // this.codeGenerator.isinst(this.indent, ti);
108  // this.codeGenerator.brfalse(this.indent, skipSecondOperandLabel);
109  // // now in the top of the stack there's only First Operand
110  // this.codeGenerator.pop();
111  // t1.AcceptOperation
112  // this.codeGenerator.WriteLabel(this.indent, skipSecondOperandLabel);
113  // }
114  //}
115 
116  //private TypeExpression CheckSecondOperand(TypeExpression t1, TypeExpression t2) {
117 
118  // if ( TypeExpression.Is<UnionType>(t2) ) {
119  // UnionType ut = t1 as UnionType;
120  // foreach ( TypeExpression ti in ut.TypeSet )
121  // CheckSecondOperand(t1, ti);
122 
123  // } else { // iS an integral TYPE
124  // IntegralTypeAsSecondOperand(t1, t2);
125  // GenerateOperator(t1, t2);
126  // }
127  // return null;
128  //}
129 
130  //private void GenerateOperator(TypeExpression t1, TypeExpression t2) {
131  // throw new System.NotImplementedException();
132  //}
133 
134  //public void IntegralTypeAsFirstOperand(TypeExpression t1) {
135  // node.FirstOperand.Accept(this.visitor, obj);
136  // GenerateFirstOperandCode(t1);
137  //}
138  //public void IntegralTypeAsSecondOperand(TypeExpression t1, TypeExpression t2) {
139  // node.FirstOperand.Accept(this.visitor, obj);
140  // GenerateSecondOperandCode(t1);
141  //}
142  //private void GenerateFirstOperandCode(TypeExpression t1) {
143  // throw new System.NotImplementedException();
144  //}
145 
146  //private void GenerateSecondOperandCode(TypeExpression t2) {
147  // throw new System.NotImplementedException();
148  //}
149 
150 
151  }
152 }
This class represent the entry wnen sending a message to an operation object derived from TypeExpress...
Encapsulates arithmetic binary expressions.