public List<AphidExpression> ExpandForExpression(ForExpression expression) { var body = new List<AphidExpression>(expression.Body); body.Add(expression.Afterthought); return new List<AphidExpression>() { expression.Initialization, new WhileExpression(MutateCondition(expression.Condition), body), }; }
public static ForExpression Create( AphidExpressionContext context_aphidExpressionContext, AphidExpression initialization_aphidExpression, AphidExpression condition_aphidExpression1, AphidExpression afterthought_aphidExpression2, List <AphidExpression> body_list, int value_i, int value_i1 ) { ForExpression forExpression = new ForExpression (context_aphidExpressionContext, initialization_aphidExpression, condition_aphidExpression1, afterthought_aphidExpression2, body_list); ((AphidExpression)forExpression).Index = value_i; ((AphidExpression)forExpression).Length = value_i1; return(forExpression); // TODO: Edit factory method of ForExpression // This method should be able to configure the object in all possible ways. // Add as many parameters as needed, // and assign their values to each field by using the API. }
private AphidObject InterpretForExpression(ForExpression expression) { EnterChildScope(); var init = InterpretExpression(expression.Initialization); while ((InterpretExpression(expression.Condition) as AphidObject).GetBool()) { EnterChildScope(); Interpret(expression.Body, false); InterpretExpression(expression.Afterthought); if (LeaveChildScope(true) || _isBreaking) { _isBreaking = false; break; } } LeaveChildScope(true); return null; }