/// <summary> /// Gets a value based on its image /// </summary> /// <param name="image"></param> /// <returns></returns> public override Values.IValue getValue(string image) { Values.IValue retVal = null; Interpreter.Expression expression = EFSSystem.Parser.Expression(this, image); Types.Type type = expression.GetExpressionType() as Types.Type; if (type != null && Match(type)) { retVal = expression.GetValue(new Interpreter.InterpretationContext()); } return(retVal); }
/// <summary> /// Ensures that the parameter provided corresponds to a function double->double /// </summary> /// <param name="root">Element on which the errors shall be attached</param> /// <param name="context">The context used to evaluate the expression</param> /// <param name="expression">The expression which references the function</param> /// <param name="count">the expected number of parameters</param> protected virtual void CheckFunctionalParameter(ModelElement root, Interpreter.InterpretationContext context, Interpreter.Expression expression, int count) { Types.Type type = expression.GetExpressionType(); Function function = type as Function; if (function != null) { if (function.FormalParameters.Count == count) { foreach (Parameter parameter in function.FormalParameters) { if (!parameter.Type.IsDouble()) { root.AddError(expression.ToString() + " does not takes a double for parameter " + parameter.Name); } } } else { root.AddError(expression.ToString() + " does not take " + count + "parameter(s) as input"); } if (!function.ReturnType.IsDouble()) { root.AddError(expression.ToString() + " does not return a double"); } } else { if (!type.IsDouble()) { root.AddError(expression.ToString() + " type is not double"); } } }