/// <summary> /// Simple static helper to evaluate an expression (typically a pure expression without side effects). /// </summary> /// <param name="e">The expression to evaluate.</param> /// <param name="ctx">The <see cref="GlobalContext"/>. When null, a new default GlobalContext is used.</param> /// <returns>The result of the evaluation.</returns> public static RuntimeObj Evaluate( Expr e, GlobalContext ctx = null ) { EvalVisitor v = new EvalVisitor( ctx ?? new GlobalContext() ); return v.VisitExpr( e ).Result; }
/// <summary> /// Initializes a new <see cref="ScriptEngine"/>, optionally bound to an existing <see cref="GlobalContext"/>. /// </summary> /// <param name="ctx">Optional global context to use.</param> /// <param name="breakPointManager">Optional <see cref="BreakpointManager"/> instance to use.</param> /// <param name="scopeManager">Optional <see cref="DynamicScope"/> to use.</param> public ScriptEngine( GlobalContext ctx = null, BreakpointManager breakPointManager = null, DynamicScope scopeManager = null ) { _breakpoints = breakPointManager ?? new BreakpointManager(); _globalContext = ctx ?? new GlobalContext(); _visitor = new EvalVisitor( _globalContext, _breakpoints.MustBreak, scopeManager ); }
/// <summary> /// Simple static helper to evaluate a string (typically a pure expression without side effects). /// </summary> /// <param name="s">The string to evaluate.</param> /// <param name="ctx">The <see cref="GlobalContext"/>. When null, a new default GlobalContext is used.</param> /// <returns>The result of the evaluation.</returns> public static RuntimeObj Evaluate( string s, GlobalContext ctx = null ) { return Evaluate( ExprAnalyser.AnalyseString( s ) ); }
public override object ToNative(GlobalContext c) => _value;
/// <summary> /// Initializes a new <see cref="ScriptEngine"/>, optionally bound to an existing <see cref="GlobalContext"/>. /// </summary> /// <param name="ctx">Optional global context to use.</param> /// <param name="breakPointManager">Optional <see cref="BreakpointManager"/> instance to use.</param> /// <param name="scopeManager">Optional <see cref="DynamicScope"/> to use.</param> public ScriptEngine(GlobalContext ctx = null, BreakpointManager breakPointManager = null, DynamicScope scopeManager = null) { _breakpoints = breakPointManager ?? new BreakpointManager(); _globalContext = ctx ?? new GlobalContext(); _visitor = new EvalVisitor(_globalContext, _breakpoints.MustBreak, scopeManager); }
/// <summary> /// Simple static helper to evaluate an expression (typically a pure expression without side effects). /// </summary> /// <param name="e">The expression to evaluate.</param> /// <param name="ctx">The <see cref="GlobalContext"/>. When null, a new default GlobalContext is used.</param> /// <returns>The result of the evaluation.</returns> public static RuntimeObj Evaluate(Expr e, GlobalContext ctx = null) { EvalVisitor v = new EvalVisitor(ctx ?? new GlobalContext()); return(v.VisitExpr(e).Result); }
/// <summary> /// Simple static helper to evaluate a string (typically a pure expression without side effects). /// </summary> /// <param name="s">The string to evaluate.</param> /// <param name="ctx">The <see cref="GlobalContext"/>. When null, a new default GlobalContext is used.</param> /// <returns>The result of the evaluation.</returns> public static RuntimeObj Evaluate(string s, GlobalContext ctx = null) { return(Evaluate(ExprAnalyser.AnalyseString(s))); }