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
 }
 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();
 }
Example #3
0
 private string GetTypeString(DemoNavi.IntermediateRepresentation.Types.IRType type)
 {
     if (type is IntType)
     {
         return("Int32");
     }
     else if (type is CharType)
     {
         return("Char");
     }
     return("");
 }
Example #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
            }
        }
Example #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;
 }
Example #8
0
 internal override void SemanticValidation(IntermediateRepresentation.Semantic.SemanticContext semanticContext)
 {
     semanticContext.IdExistInScope(this.id);
     returnType = semanticContext.GetIdType(this.id);
 }
Example #9
0
 public PointerType(IRType baseType)
 {
     this.baseType = baseType;
 }
Example #10
0
 private int GetTypeSizeInBytes(IRType type)
 {
     return GetTypeSizeInWords(type) * 4;
 }
Example #11
0
 internal override void SemanticValidation(Semantic.SemanticContext semanticContext)
 {
     returnType = new FloatType();
 }
Example #12
0
 public VarDeclaration(string id, Expression initializationExpression, IRType type)
 {
     this.Id = id;
     this.InitializationExpression = initializationExpression;
     this.Type = type;
 }
Example #13
0
 public PointerType(IRType baseType)
 {
     this.baseType = baseType;
 }
Example #14
0
 public Parameter(IRType type, string id)
 {
     // TODO: Complete member initialization
     this.type = type;
     this.id = id;
 }