当前位置: 首页>>代码示例>>C#>>正文


C# IScriptContext.RemoveLocalScope方法代码示例

本文整理汇总了C#中IScriptContext.RemoveLocalScope方法的典型用法代码示例。如果您正苦于以下问题:C# IScriptContext.RemoveLocalScope方法的具体用法?C# IScriptContext.RemoveLocalScope怎么用?C# IScriptContext.RemoveLocalScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IScriptContext的用法示例。


在下文中一共展示了IScriptContext.RemoveLocalScope方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Evaluate

    //TODO: Refactor
    public override void Evaluate(IScriptContext context)
    {
      if (ChildNodes.Count == 0) return;

      //Create local scope
      if (ShouldCreateScope)
      {
        IScriptScope scope = RuntimeHost.ScopeFactory.Create(ScopeTypes.Local, context.Scope);
        context.CreateScope(scope);
      }

      try
      {
        int index = 0;
        while (index < ChildNodes.Count)
        {
          var node = (ScriptAst)ChildNodes[index];
          node.Evaluate(context);

          if (context.IsBreak() || context.IsReturn() || context.IsContinue())
          {
            break;
          }

          index++;
        }
      }
      finally
      {
        if (ShouldCreateScope)
          context.RemoveLocalScope();
      }
    }
开发者ID:eightrivers,项目名称:SSharp,代码行数:34,代码来源:ScriptCompoundStatement.cs

示例2: Invoke

        public object Invoke(IScriptContext context, object[] args)
        {
            string code = (String)args[0];
              ScriptAst result = null;

              LanguageCompiler compiler = (LanguageCompiler) context.GetItem("Compiler", true);
              RuntimeHost.Lock();

              try
              {
            result = Script.Parse(code + ";", false) as ScriptAst;
            //TODO: Create LocalOnlyScope that can't change Parent's variables
            //No, need for doing these. It is already done
            context.CreateScope();
              }
              finally
              {
            RuntimeHost.UnLock();
              }

              result.Evaluate(context);
              context.RemoveLocalScope();

              return context.Result;
        }
开发者ID:Temperament,项目名称:FiestaShark,代码行数:25,代码来源:EvalFunc.cs

示例3: Invoke

    public object Invoke(IScriptContext context, object[] args)
    {
        var functionScope = (INotifyingScope)RuntimeHost.ScopeFactory.Create(ScopeTypes.Function, context.Scope, context);
        context.CreateScope(functionScope);

        Expando values=args.FirstOrDefault() as Expando;
        if (values != null) {
            foreach (var field in values.Fields) {
                context.SetItem(field, values[field]);
            }
        } else {
            if (args.Length > 0)
                throw new ScriptExecutionException("Wrong type of arguments passed to Program Invokation");
        }

        try {
            Evaluate(context);
        }
        finally {
            context.RemoveLocalScope();
            context.ResetControlFlags();
        }

        return context.Result;
    }
开发者ID:eightrivers,项目名称:SSharp,代码行数:25,代码来源:ScriptProg.cs

示例4: Invoke

    public object Invoke(IScriptContext context, object[] args)
    {
      bool scopeOwner = false;
      
      if (args != null)
      {
        if (args.Length > 1) throw new ArgumentException("Number of arguments ");
        if (args.Length == 1)
        {
          var assigner = args[0] as ISupportAssign;
          if (assigner == null) throw new NotSupportedException("Given type of argument is not supported");
          assigner.AssignTo(context.CreateScope());
          scopeOwner = true;
        }
      }

      try
      {
        context.ResetControlFlags();

        _metaProg.Evaluate(context);
        
        return context.Result;
      }
      finally
      {
        if (scopeOwner)
          context.RemoveLocalScope();

        context.ResetControlFlags();
      }
    }
开发者ID:eightrivers,项目名称:SSharp,代码行数:32,代码来源:ScriptMetaExpr.cs

示例5: Evaluate

        public override void Evaluate(IScriptContext context)
        {
            name.Evaluate(context);

              context.CreateScope(RuntimeHost.ScopeFactory.Create(ScopeTypes.Using, context.Scope, context.Result));
            statement.Evaluate(context);
              context.RemoveLocalScope();
        }
开发者ID:Zepheus,项目名称:Fiesta_Utils,代码行数:8,代码来源:ScriptUsingStatement.cs

示例6: Invoke

        public object Invoke(IScriptContext context, object[] args)
        {
            activeContext = context;
            object result = RuntimeHost.NullValue;

            INotifyingScope functionScope = (INotifyingScope)RuntimeHost.ScopeFactory.Create(ScopeTypes.Function, context.Scope, context);
            context.CreateScope(functionScope);

            try
            {
              if (Parameters != null)
              {
            context.Result = args;
            Parameters.Evaluate(context);
              }

              functionScope.BeforeSetItem += ScopeBeforeSetItem;

              if (Contract != null)
              {
            functionScope.AfterSetItem += CheckContractInvariant;
            Contract.CheckPre(context);
            Contract.CheckInv(context);
              }

              context.Result = RuntimeHost.NullValue;
              Body.Evaluate(context);
              result = context.Result;

              if (Contract != null)
              {
            functionScope.AfterSetItem -= CheckContractInvariant;
            Contract.CheckInv(context);
            Contract.CheckPost(context);
              }
            }
            finally
            {
              context.RemoveLocalScope();
              context.SetBreak(false);
              context.SetContinue(false);
              context.SetReturn(false);
              context.Result = result;

              functionScope.BeforeSetItem -= ScopeBeforeSetItem;
              activeContext = null;
            }

            return result;
        }
开发者ID:2yangk23,项目名称:MapleShark,代码行数:50,代码来源:ScriptFunctionDefinition.cs

示例7: Invoke

            public object Invoke(IScriptContext context, object[] args)
            {
                context.CreateScope();
                context.SetItem("me", scriptable.Instance);
                context.SetItem("body", scriptable);

                object rez = RuntimeHost.NullValue;
                try
                {
                  rez = dynamicMethod.Invoke(context, arguments);
                }
                finally
                {
                  context.RemoveLocalScope();
                }

                if (rez != RuntimeHost.NullValue)
                {
                  return rez;
                }
                else
                {
                  throw new ScriptException(string.Format("Dynamic method call failed in object {0}", scriptable.ToString()));
                }
            }
开发者ID:2yangk23,项目名称:MapleShark,代码行数:25,代码来源:ObjectBinderExtended.cs

示例8: Evaluate

    public override void Evaluate(IScriptContext context)
    {
      var result = RuntimeHost.NullValue;

      //Create local scope
      var scope = RuntimeHost.ScopeFactory.Create(ScopeTypes.Local, context.Scope);
      context.CreateScope(scope);

      try
      {
        _init.Evaluate(context);
        _cond.Evaluate(context);
        bool condBool = context.Result == null ? true : (bool)context.Result;

        while (condBool)
        {
          _statement.Evaluate(context);
          result = context.Result;

          if (context.IsBreak() || context.IsReturn())
          {
            context.SetBreak(false);
            break;
          }

          if (context.IsContinue())
          {
            context.SetContinue(false);
          }


          _next.Evaluate(context);
          _cond.Evaluate(context);
          condBool = context.Result == null ? true : (bool)context.Result;
        }

        context.Result = result;
      }
      finally
      {
        context.RemoveLocalScope();
      }
    }
开发者ID:eightrivers,项目名称:SSharp,代码行数:43,代码来源:ScriptForStatement.cs

示例9: Invoke

      public object Invoke(IScriptContext context, object[] args)
      {
        context.CreateScope();
        context.SetItem("me", _scriptable.Instance);
        context.SetItem("body", _scriptable);

        var rez = RuntimeHost.NullValue;
        try
        {
          rez = _dynamicMethod.Invoke(context, _arguments);
        }
        finally
        {
          context.RemoveLocalScope();
        }

        if (rez != RuntimeHost.NullValue) return rez;
        throw new ScriptExecutionException(string.Format(Strings.DynamicObjectMethodCallError, _scriptable));
      }
开发者ID:eightrivers,项目名称:SSharp,代码行数:19,代码来源:DefaultObjectBinding.cs


注:本文中的IScriptContext.RemoveLocalScope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。