コード例 #1
0
        public override void CheckSemantics(Scope scope, Report report)
        {
            LeftOperand.CheckSemantics(scope, report);
            RightOperand.CheckSemantics(scope, report);

            //No tener errores en los operandos
            if (LeftOperand.returnType.isError || RightOperand.returnType.isError)
            {
                returnType = scope.FindType("error");
                return;
            }

            //Verificar que sean del mismo tipo
            if (!LeftOperand.returnType.Alike(RightOperand.returnType))
            {
                report.Add(LeftOperand.Line, LeftOperand.CharPositionInLine, string.Format("Can't apply operator {0} between types {1} and {2}", Text, LeftOperand.returnType.name, RightOperand.returnType.name));
                returnType = scope.FindType("error");
                return;
            }

            returnType = LeftOperand.returnType;
        }