/// <summary> /// Finds a symbol in the expression /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public SymbolRef FindSymbol(ScriptExecutionContext context) { this.CheckScriptOwnership(context.GetScript()); if (m_Exp != null) return m_Exp.FindDynamic(context); return null; }
/// <summary> /// Evaluates the expression /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public DynValue Evaluate(ScriptExecutionContext context = null) { context = context ?? OwnerScript.CreateDynamicExecutionContext(); this.CheckScriptOwnership(context.GetScript()); if (m_Constant != null) return m_Constant; return m_Exp.Eval(context); }
/// <summary> /// Resumes the coroutine /// </summary> /// <param name="context">The ScriptExecutionContext.</param> /// <param name="args">The arguments.</param> /// <returns></returns> public DynValue Resume(ScriptExecutionContext context, params object[] args) { DynValue[] dargs = new DynValue[args.Length]; for (int i = 0; i < dargs.Length; i++) { dargs[i] = DynValue.FromObject(context.GetScript(), args[i]); } return(Resume(context, dargs)); }
/// <summary> /// Evaluates the expression /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public DynValue Evaluate(ScriptExecutionContext context) { this.CheckScriptOwnership(context.GetScript()); if (m_Constant.IsValid) { return(m_Constant); } return(m_Exp.Eval(context)); }
/// <summary> /// Finds a symbol in the expression /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public SymbolRef FindSymbol(ScriptExecutionContext context) { this.CheckScriptOwnership(context.GetScript()); if (m_Exp != null) { return(m_Exp.FindDynamic(context)); } else { return(null); } }
/// <summary> /// Evaluates the expression /// </summary> /// <param name="context">The context.</param> /// <returns></returns> public DynValue Evaluate(ScriptExecutionContext context = null) { context = context ?? OwnerScript.CreateDynamicExecutionContext(); this.CheckScriptOwnership(context.GetScript()); if (m_Constant != null) { return(m_Constant); } return(m_Exp.Eval(context)); }
/// <summary> /// Evaluates the expression /// </summary> /// <param name="context">The context.</param> public DynValue Evaluate(ScriptExecutionContext context = null) { context ??= this.OwnerScript.CreateDynamicExecutionContext(ExecutionControlToken.Dummy); this.CheckScriptOwnership(context.GetScript()); if (_constant != null) { return(_constant); } return(_exp.Eval(context)); }
/// <summary> /// Invokes the callback function /// </summary> /// <param name="executionContext">The execution context.</param> /// <param name="args">The arguments.</param> /// <param name="isMethodCall">if set to <c>true</c> this is a method call.</param> /// <returns></returns> public DynValue Invoke(ScriptExecutionContext executionContext, IList<DynValue> args, bool isMethodCall = false) { if (isMethodCall) { var colon = executionContext.GetScript().Options.ColonOperatorClrCallbackBehaviour; if (colon == ColonOperatorBehaviour.TreatAsColon) isMethodCall = false; else if (colon == ColonOperatorBehaviour.TreatAsDotOnUserData) isMethodCall = (args.Count > 0 && args[0].Type == DataType.UserData); } return ClrCallback(executionContext, new CallbackArguments(args, isMethodCall)); }
/// <summary> /// Invokes the callback function /// </summary> /// <param name="executionContext">The execution context.</param> /// <param name="args">The arguments.</param> /// <param name="isMethodCall">if set to <c>true</c> this is a method call.</param> /// <returns></returns> public DynValue Invoke(ScriptExecutionContext executionContext, IList <DynValue> args, bool isMethodCall = false) { if (isMethodCall) { var colon = executionContext.GetScript().Options.ColonOperatorClrCallbackBehaviour; if (colon == ColonOperatorBehaviour.TreatAsColon) { isMethodCall = false; } else if (colon == ColonOperatorBehaviour.TreatAsDotOnUserData) { isMethodCall = (args.Count > 0 && args[0].Type == DataType.UserData); } } return(ClrCallback(executionContext, new CallbackArguments(args, isMethodCall))); }
/// <summary> /// Gets the specified argument as a string, calling the __tostring metamethod if needed, in a NON /// yield-compatible way. /// </summary> /// <param name="executionContext">The execution context.</param> /// <param name="argNum">The argument number.</param> /// <param name="funcName">Name of the function.</param> /// <exception cref="ScriptRuntimeException">'tostring' must return a string to '{0}'</exception> public string AsStringUsingMeta(ScriptExecutionContext executionContext, int argNum, string funcName) { if ((this[argNum].Type == DataType.Table) && (this[argNum].Table.MetaTable != null) && (this[argNum].Table.MetaTable.RawGet("__tostring") != null)) { var v = executionContext.GetScript() .Call(this[argNum].Table.MetaTable.RawGet("__tostring"), this[argNum]); if (v.Type != DataType.String) { throw new ScriptRuntimeException("'tostring' must return a string to '{0}'", funcName); } return(v.ToPrintString()); } return(this[argNum].ToPrintString()); }
/// <summary> /// Finds a symbol in the expression /// </summary> /// <param name="context">The context.</param> public SymbolRef FindSymbol(ScriptExecutionContext context) { this.CheckScriptOwnership(context.GetScript()); return(_exp?.FindDynamic(context)); }