Esempio n. 1
0
        public static List<Error> Resolve(WhileStatement wh)
        {
            var errors = new List<Error>();

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

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

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

            return errors;
        }
Esempio n. 2
0
 private static void EmitWhileStatement(WhileStatement wst)
 {
     Source += "while (" + MakeString(wst.Cond) + ")\n{";
     foreach (var st in wst.GetSpecifiedChildren<Statement>())
     {
         Emit(st);
     }
     Source += "}";
 }