Exemple #1
0
        public static List<Error> Resolve(IfStatement ifs)
        {
            var errors = new List<Error>();

            IType typeLeft, typeRight;
            errors.AddRange(ExpressionResolver.ResloveExpression(ifs, ifs.Cond.Left, out typeLeft));
            errors.AddRange(ExpressionResolver.ResloveExpression(ifs, ifs.Cond.Right, out typeRight));

            if (typeLeft.ToString() != typeRight.ToString())
                errors.Add(new Error(ifs.GetSourceIdentifier(), ifs.Cond.Left.List.First(),
                                     string.Format(ErrorMessages.TypeMismatch, typeLeft.ToString(), typeRight.ToString())));

            foreach (var sts in ifs.GetSpecifiedChildren<Body>().First().Statements)
            {
                errors.AddRange(StatementResolver.Resolve(sts));
            }

            return errors;
        }
Exemple #2
0
 private static void EmitIfStatement(IfStatement ifst)
 {
     Source += "if (" + MakeString(ifst.Cond) + ")\n{";
     foreach (var st in ifst.GetSpecifiedChildren<Statement>())
     {
         Emit(st);
     }
     Source += "}";
 }