/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { var left = Left.Evaluate(scope, environment); var right = Right.Evaluate(scope, environment); return(new DoubleValue(!left.Equals(right))); }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { IMoValue array = Array.Evaluate(scope, environment); if (array is VariableStruct vs) { MoScope subScope = new MoScope(scope.Runtime); foreach (IMoValue value in vs.Map.Values) { subScope.IsContinue = false; subScope.IsBreak = false; Variable.Assign( subScope, environment, value is VariableStruct vss ? vss.Map.FirstOrDefault().Value : value); Body.Evaluate(subScope, environment); if (subScope.ReturnValue != null) { return(subScope.ReturnValue); } else if (subScope.IsBreak) { break; } } } return(DoubleValue.Zero); }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { var index = (int)Index.Evaluate(scope, environment).AsDouble(); MoPath path; if (Array is NameExpression nameExpression) { var p = nameExpression.Name; path = p; } else { var eval = Array.Evaluate(scope, environment); path = new MoPath($"{eval.AsString()}"); } var array = environment.GetValue(path); if (array is ArrayStruct asArray) { return(asArray[index]); } return(environment.GetValue(path)); }
public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { IMoValue result = DoubleValue.Zero; // MoScope scope = new MoScope(this); foreach (IExpression expression in Parameters) { if (expression == null) { continue; } try { result = expression.Evaluate(scope, environment); if (scope.ReturnValue != null) { result = scope.ReturnValue; break; } } catch (Exception ex) { throw new MoLangRuntimeException( expression, "An error occured while evaluating the expression", ex); } } return(result); }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { int loop = (int)Count.Evaluate(scope, environment).AsDouble(); MoScope subScope = new MoScope(scope.Runtime) { Runtime = scope.Runtime }; while (loop > 0) { subScope.IsContinue = false; subScope.IsBreak = false; Body.Evaluate(subScope, environment); loop--; if (subScope.ReturnValue != null) { return(subScope.ReturnValue); } else if (subScope.IsBreak) { break; } } return(DoubleValue.Zero); }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { IMoValue eval = Parameters[0].Evaluate(scope, environment); scope.ReturnValue = eval; return(eval); }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { var leftEnv = Left.Evaluate(scope, environment); if (leftEnv is MoLangEnvironment leftMolangEnvironment) { return(Right.Evaluate(scope, leftMolangEnvironment)); } return(null); }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { try { return(new DoubleValue( Left.Evaluate(scope, environment).AsDouble() + Right.Evaluate(scope, environment).AsDouble())); } catch (Exception ex) { throw new MoLangRuntimeException(this, "An unexpected error occured.", ex); } }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { if (Condition.Evaluate(scope, environment).Equals(DoubleValue.One)) { return(ThenExpr == null?Condition.Evaluate(scope, environment) : ThenExpr.Evaluate(scope, environment)); } else if (ElseExpr != null) { return(ElseExpr.Evaluate(scope, environment)); } return(DoubleValue.Zero); }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { //List<IExpression> p = Args.ToList(); MoPath name = Name; /* Name is NameExpression expression ? expression.Name : * new MoPath(Name.Evaluate(scope, environment).ToString());*/ IMoValue[] arguments = new IMoValue[Parameters.Length]; for (int i = 0; i < arguments.Length; i++) { arguments[i] = Parameters[i].Evaluate(scope, environment); } return(environment.GetValue(name, new MoParams(arguments))); }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { IMoValue evalLeft = Left.Evaluate(scope, environment); //IMoValue value = environment.GetValue(new MoPath(evalLeft.AsString())); if (evalLeft == null || !evalLeft.AsBool()) { return(Right.Evaluate(scope, environment)); } else { return(evalLeft); } }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { foreach (IExpression expression in Parameters) { expression.Evaluate(scope, environment); if (scope.ReturnValue != null) { return(scope.ReturnValue); } else if (scope.IsBreak || scope.IsContinue) { break; } } return(DoubleValue.Zero); }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { return(_value); }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { return(new DoubleValue(-(Parameters[0].Evaluate(scope, environment).AsDouble()))); }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { return(environment.ThisVariable); // environment.GetValue(_this); }
/// <inheritdoc /> public virtual void Assign(MoScope scope, MoLangEnvironment environment, IMoValue value) { throw new Exception("Cannot assign a value to " + this.GetType()); }
/// <inheritdoc /> public abstract IMoValue Evaluate(MoScope scope, MoLangEnvironment environment);
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { return(environment.GetValue(Name)); }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { return(Parameters[0].Evaluate(scope, environment).AsBool() ? DoubleValue.Zero : DoubleValue.One); // .Equals(DoubleValue.One) ? DoubleValue.Zero : DoubleValue.One; }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { scope.IsBreak = true; return(DoubleValue.Zero); }
/// <inheritdoc /> public override void Assign(MoScope scope, MoLangEnvironment environment, IMoValue value) { environment.SetValue(Name, value); }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { return(new DoubleValue( Left.Evaluate(scope, environment).AsBool() || Right.Evaluate(scope, environment).AsBool())); }
/// <inheritdoc /> public override IMoValue Evaluate(MoScope scope, MoLangEnvironment environment) { Variable.Assign(scope, environment, Expression.Evaluate(scope, environment)); return(DoubleValue.Zero); }