Пример #1
0
 public object Invoke(Script script, Scope scope, object[] arguments)
 {
     var localScope = new Scope(scope);
     // Init our locals.
     for (int i = 0; i < Parameters.Count; i++)
     {
         localScope.Locals[Parameters[i]] = arguments[i];
     }
     return new Code(Code, script).Evaluate(localScope, true);
 }
Пример #2
0
 /// <summary>
 /// Creates a new instance of Code.
 /// </summary>
 /// <param name="code">The block of code.</param>
 /// <param name="script">The reference to the script.</param>
 public Code(List<List<List<Token>>> code, Script script)
 {
     _code = code;
     _script = script;
 }
Пример #3
0
 /// <summary>
 /// Set's the script reference.
 /// </summary>
 /// <param name="script"></param>
 public void SetScript(Script script)
 {
     _script = script;
 }
Пример #4
0
 /// <summary>
 /// Creates a new chunk.
 /// </summary>
 /// <param name="tokens">The tokens that make up the chunk.</param>
 /// <param name="script">Reference to the script.</param>
 public Chunk(List<Token> tokens, Script script)
 {
     _tokens = tokens;
     _script = script;
 }
Пример #5
0
 /// <summary>
 /// Late build...
 /// </summary>
 /// <param name="engine"></param>
 /// <param name="sourceCode"></param>
 /// <param name="script"></param>
 /// <returns></returns>
 public virtual Token LateBuild(ScriptEngine engine, ref SourceCode sourceCode, ref Script script)
 {
     return null;
 }
Пример #6
0
 /// <summary>
 /// This is called if condition match is true, and SimpleBuild is set to true. When called, the method should return a token that will be inserted into the call structure.
 /// </summary>
 /// <param name="lastToken"></param>
 /// <param name="engine"></param>
 /// <param name="script"></param>
 /// <param name="sourceCode"></param>
 /// <returns></returns>
 public virtual Token Build(Token lastToken, ScriptEngine engine, Script script, ref SourceCode sourceCode)
 {
     return null;
 }
Пример #7
0
 /// <summary>
 /// This is called if condition match is true, and SimpleBuild is set to false, you can use this to build custom handlers to events, but shouldn't be added to the call structure.
 /// For example, a configuration handler would use AdvnacedBuild to get the details it needs from the code, and not have it listed in the call structure.
 /// 
 /// For an example of how this is used, look at ConfigBuilder.
 /// </summary>
 /// <seealso cref="ConfigBuilder"/>
 /// <param name="engine"></param>
 /// <param name="sourceCode"></param>
 /// <param name="script"></param>
 /// <returns></returns>
 public virtual bool AdvancedBuild(ScriptEngine engine, ref SourceCode sourceCode, ref Script script)
 {
     return true;
 }