1 using TypeSystem.Operations;
6 using System.Collections.Generic;
7 using CodeGeneration.ExceptionManagement;
8 namespace CodeGeneration.Operations {
10 internal class CGArithmeticOperation<T> : CGBinaryOperation<T> where T :
ILCodeGenerator {
14 private static UnionType GenerateAllUnionTypes() {
16 unions.AddType(CharType.Instance);
17 unions.AddType(IntType.Instance);
18 unions.AddType(DoubleType.Instance);
22 private static UnionType allUnions = GenerateAllUnionTypes();
47 case ArithmeticOperator.Minus:
48 this.codeGenerator.sub(this.indent);
50 case ArithmeticOperator.Plus:
52 this.codeGenerator.concat(
this.indent);
54 this.codeGenerator.add(this.indent);
56 case ArithmeticOperator.Mult:
57 this.codeGenerator.mul(this.indent);
59 case ArithmeticOperator.Div:
60 this.codeGenerator.div(this.indent);
62 case ArithmeticOperator.Mod:
63 this.codeGenerator.rem(this.indent);
66 this.codeGenerator.Comment(string.Format(
"Error operation {0} {1} {2}", cga.info[0].typeExpression.FullName, ( (
ArithmeticExpression)node ).Operator, cga.info[1].typeExpression.FullName));
72 ErrorManager.Instance.NotifyError(
new CodeGenerationError(
"No se ha definido la operación solicitada"));
static StringType Instance
Gets the unique instance of StringType
Encapsulates a binary expression of our programming language.
It typechecks the runtime arguments, embeded in a method call, with the parametes of this method...
This class walks the AST to obtain the IL code.
Encapsulates arithmetic binary expressions.
Abstract class that represents all different types.
Represents a error produced when a MethodType has class information and tries to assign other class i...
ArithmeticOperator
Arithmetic binary operators