Ejemplo n.º 1
0
 internal override void SemanticValidation(Semantic.SemanticContext semanticContext)
 {
     Expression.SemanticValidation(semanticContext);
     if (!(Expression.GetIRType() is BoolType))
     {
         throw new Semantic.SemanticValidationException("No se puede negar");
     }else
         returnType = new BoolType(); //a exp tiene que poder negarse
 }
Ejemplo n.º 2
0
 internal override void SemanticValidation(Semantic.SemanticContext semanticContext)
 {
     Expression.SemanticValidation(semanticContext);
     if (!(Expression.GetIRType() is NumericType))
     {
         throw new Semantic.SemanticValidationException("No se puede negar");
     }
     else
         returnType = new PointerType();
 }
Ejemplo n.º 3
0
 private string GetTypeString(DemoNavi.IntermediateRepresentation.Types.IRType type)
 {
     if (type is IntType)
     {
         return("Int32");
     }
     else if (type is CharType)
     {
         return("Char");
     }
     return("");
 }
Ejemplo n.º 4
0
 private int GetTypeSizeInWords(IRType type)
 {
     if (type is IntType)
     {
         return 1;
     }
     else if (type is StructType)
     {
         var strucType = type as StructType;
         return strucType.DeclarationStatement.OfType<IdDeclarationStatement>().Sum(dec => GetTypeSizeInWords(dec.Type));
     }
     return 0;
 }
        internal override void SemanticValidation(Semantic.SemanticContext semanticContext)
        {
            Left.SemanticValidation(semanticContext);
            Right.SemanticValidation(semanticContext);

            if (!(Left.GetIRType() is NumericType && Right.GetIRType() is NumericType))
            {
                throw new Semantic.SemanticValidationException("No se puede asignar");
            }
            else
            {
                returnType = Left.GetIRType(); //evaluar cual tipo de podría asignar dependiendo de su tamanio
            }
        }
Ejemplo n.º 6
0
        internal override void SemanticValidation(Semantic.SemanticContext semanticContext)
        {
            Left.SemanticValidation(semanticContext);
            Right.SemanticValidation(semanticContext);

            if (!(Left.GetIRType() is NumericType && Right.GetIRType() is NumericType))
            {
                throw new Semantic.SemanticValidationException("No se puede operar");
            }
            else
            {
                returnType = Left.GetIRType();
            }
        }
 public IdDeclarationStatement(string id, Expression initializationExpression, IRType type)
 {
     this.Id = id;
     this.InitializationExpression = initializationExpression;
     this.Type = type;
 }
Ejemplo n.º 8
0
 internal override void SemanticValidation(IntermediateRepresentation.Semantic.SemanticContext semanticContext)
 {
     semanticContext.IdExistInScope(this.id);
     returnType = semanticContext.GetIdType(this.id);
 }
Ejemplo n.º 9
0
 public PointerType(IRType baseType)
 {
     this.baseType = baseType;
 }
Ejemplo n.º 10
0
 private int GetTypeSizeInBytes(IRType type)
 {
     return GetTypeSizeInWords(type) * 4;
 }
Ejemplo n.º 11
0
 internal override void SemanticValidation(Semantic.SemanticContext semanticContext)
 {
     returnType = new FloatType();
 }
Ejemplo n.º 12
0
 public VarDeclaration(string id, Expression initializationExpression, IRType type)
 {
     this.Id = id;
     this.InitializationExpression = initializationExpression;
     this.Type = type;
 }
Ejemplo n.º 13
0
 public PointerType(IRType baseType)
 {
     this.baseType = baseType;
 }
Ejemplo n.º 14
0
 public Parameter(IRType type, string id)
 {
     // TODO: Complete member initialization
     this.type = type;
     this.id = id;
 }