public object Evaluate(ExecutionState state, Token contextToken) { // ensure that the variable has been set to some value first if(!state.HasVariable(variableToken.Value)) throw new InstructionExecutionException("I can't evaluate the word \"" + variableToken.Value + "\". Either it doesn't mean anything or you forgot to assign it a value.", variableToken); return state.GetVariable(variableToken.Value); }
public object Evaluate(Token contextToken, List<ExpressionArgument> args, ExecutionState state) { object o = state.HasVariable(variableToken.Value) ? state.GetVariable(variableToken.Value) : null; if (o is IArgumentListEvaluatorExpression) return ((IArgumentListEvaluatorExpression)o).Evaluate(contextToken, args, state); else return SystemTypeEvaluator.EvaluateArguments(state, o, args, contextToken); }
public object Evaluate(ExecutionState state, Token contextToken) { // ensure that the variable has been set to some value first if (!state.HasVariable(variableToken.Value)) { throw new InstructionExecutionException("I can't evaluate the word \"" + variableToken.Value + "\". Either it doesn't mean anything or you forgot to assign it a value.", variableToken); } return(state.GetVariable(variableToken.Value)); }
public object Evaluate(Token contextToken, List <ExpressionArgument> args, ExecutionState state) { object o = state.HasVariable(variableToken.Value) ? state.GetVariable(variableToken.Value) : null; if (o is IArgumentListEvaluatorExpression) { return(((IArgumentListEvaluatorExpression)o).Evaluate(contextToken, args, state)); } else { return(SystemTypeEvaluator.EvaluateArguments(state, o, args, contextToken)); } }
public object EvaluateProperty(string propertyName, Token token, ExecutionState state) { object o = state.HasVariable(variableToken.Value) ? state.GetVariable(variableToken.Value) : null; if (o is IPropertyEvaluatorExpression) { object val = ((IPropertyEvaluatorExpression)o).EvaluateProperty(propertyName, token, state); if(val != null) if (val.ToString() == VariableExpression.InvalidProperty) throw new InstructionExecutionException("\"" + propertyName + "\" is not a valid property of this variable.", token); return val; } else return SystemTypeEvaluator.EvaluateProperty(o, propertyName, token); }
public void Execute(ExecutionState state) { IList list; if (expr is IListExpression) list = ((IListExpression)expr).GetList(state); else { list = expr.Evaluate(state, listToken) as IList; if (list == null) throw new InstructionExecutionException("\"" + listToken.Value + "\" doesn't contain a list of anything.", listToken); } if (state.HasVariable(iteratorToken.Value)) throw new InstructionExecutionException("\"" + iteratorToken.Value + "\" already equates to something else. You should use a different word.", iteratorToken); foreach (object item in list) { state.Variables[iteratorToken.Value] = item; instructions.Execute(state); } state.Variables.Remove(iteratorToken.Value); }
public object EvaluateProperty(string propertyName, Token token, ExecutionState state) { object o = state.HasVariable(variableToken.Value) ? state.GetVariable(variableToken.Value) : null; if (o is IPropertyEvaluatorExpression) { object val = ((IPropertyEvaluatorExpression)o).EvaluateProperty(propertyName, token, state); if (val != null) { if (val.ToString() == VariableExpression.InvalidProperty) { throw new InstructionExecutionException("\"" + propertyName + "\" is not a valid property of this variable.", token); } } return(val); } else { return(SystemTypeEvaluator.EvaluateProperty(o, propertyName, token)); } }