public override void CheckSemantics(TigerScope scope, Report report) { ContainingScope = scope; //Check child ExpressionNode.CheckSemantics(scope, report); if (!ExpressionNode.IsOK) { return; } //Check child type if (TigerType.AreCompatible(TigerType.Int, ExpressionNode.TigerType)) { TigerType = TigerType.Int; } else { report.AddError(SemanticErrors.ArithmeticOperandInvalidType(ExpressionNode, ExpressionNode.TigerType)); } }
public override void CheckSemantics(TigerScope scope, Report report) { ContainingScope = scope; //Check children LeftOperandNode.CheckSemantics(scope, report); RightOperandNode.CheckSemantics(scope, report); if (!LeftOperandNode.IsOK || !RightOperandNode.IsOK) { return; } TigerType = TigerType.Int; //Check children types if (!TigerType.AreCompatible(LeftOperandNode.TigerType, TigerType.Int)) { report.AddError(SemanticErrors.ArithmeticOperandInvalidType(LeftOperandNode, LeftOperandNode.TigerType)); } else if (!TigerType.AreCompatible(RightOperandNode.TigerType, TigerType.Int)) { report.AddError(SemanticErrors.ArithmeticOperandInvalidType(RightOperandNode, RightOperandNode.TigerType)); } }