Script Scope represents a tree of local scopes. Scopes stores variables and types tables. Run-time queries ScriptScope through ScriptContext for: Resolving names of types and variables; Resolving names of functions; Adding new function into scope; Assigning values to variables.
Inheritance: IScriptScope
Ejemplo n.º 1
0
        private void SetBaseItems(ScriptScope result)
        {
            //Process only root scopes
              if (result.Parent != null) return;

              //Variables
              result.SetItem("Scope", this);
              result.SetItem("Compiler", ScriptdotnetGrammar.Compiler);

              ////Custom Functions
              //AppendAst
              result.SetItem(ScriptNET.CustomFunctions.AppendFunc.FunctionName, ScriptNET.CustomFunctions.AppendFunc.FunctionDefinition);
              //ReplaceAst
              result.SetItem(ScriptNET.CustomFunctions.ReplaceFunc.FunctionName, ScriptNET.CustomFunctions.ReplaceFunc.FunctionDefinition);
              //eval
              result.SetItem(ScriptNET.CustomFunctions.EvalFunc.FunctionName, ScriptNET.CustomFunctions.EvalFunc.FunctionDefinition);
              //About
              result.SetItem(ScriptNET.CustomFunctions.AboutFunc.FunctionName, ScriptNET.CustomFunctions.AboutFunc.FunctionDefinition);
              //Console
              result.SetItem(ScriptNET.CustomFunctions.RunConsole.FunctionName, ScriptNET.CustomFunctions.RunConsole.FunctionDefinition);
              //Array
              result.SetItem(ScriptNET.CustomFunctions.ArrayFunc.FunctionName, ScriptNET.CustomFunctions.ArrayFunc.FunctionDefinition);
              //Char
              result.SetItem(ScriptNET.CustomFunctions.CharFunc.FunctionName, ScriptNET.CustomFunctions.CharFunc.FunctionDefinition);
        }
Ejemplo n.º 2
0
        public IScriptScope Create(IScriptScope parent, params object[] args)
        {
            if (args == null || args.Length == 0)
              {
            ScriptScope result = new ScriptScope(parent);
            SetBaseItems(result);
            return result;
              }

              throw new NotSupportedException();
        }