public static List<Error> Resolve(ForStatement fs) { var errors = new List<Error>(); IType type, typeInit, typeOut; errors.AddRange(IdentifierResolver.ResloveIdentifierType(fs, new List<IToken> {fs.Identifier}, out type)); errors.AddRange(ExpressionResolver.ResloveExpression(fs, fs.Fs.InitExpr, out typeInit)); errors.AddRange(ExpressionResolver.ResloveExpression(fs, fs.Fs.FinalExpr, out typeOut)); if (type.ToString() != typeInit.ToString()) errors.Add(new Error(fs.GetSourceIdentifier(), fs.Identifier, string.Format(ErrorMessages.TypeMismatch, type.ToString(), typeInit.ToString()))); if (type.ToString() != typeOut.ToString()) errors.Add(new Error(fs.GetSourceIdentifier(), fs.Identifier, string.Format(ErrorMessages.TypeMismatch, type.ToString(), typeOut.ToString()))); if (typeInit.ToString() != typeOut.ToString()) errors.Add(new Error(fs.GetSourceIdentifier(), fs.Identifier, string.Format(ErrorMessages.TypeMismatch, typeInit.ToString(), typeOut.ToString()))); foreach (var sts in fs.GetSpecifiedChildren<Body>().First().Statements) { errors.AddRange(StatementResolver.Resolve(sts)); } return errors; }
private static void EmitForStatement(ForStatement fst) { Source += "for (" + MakeString(fst.Fs, fst.Identifier.Text) + ")\n{"; foreach (var st in fst.GetSpecifiedChildren<Statement>()) { Emit(st); } Source += "}"; }