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