Beispiel #1
0
        public CodeContext(TotemDictionary dict, ModuleContext moduleContext)
        {
            ContractUtils.RequiresNotNull(dict, "dict");
            ContractUtils.RequiresNotNull(moduleContext, "moduleContext");

            _moduleContext = moduleContext;
            _dict = dict;
        }
        protected override Microsoft.Scripting.Runtime.Scope CreateScope()
        {
            ModuleOptions options = ModuleOptions.None;
            var modCtx = new ModuleContext(new TotemDictionary(), TotemContext);
            modCtx.Features = options;
            modCtx.InitializeBuiltins();

            return modCtx.GlobalScope;
        }
 public TotemScopeExtension(TotemContext context, TotemModule module, ModuleContext moduleContext)
     : base(module.Scope)
 {
     _module = module;
     _moduleContext = moduleContext;
 }
 public TotemScopeExtension(TotemContext context, Scope scope)
     : base(scope)
 {
     _module = new TotemModule(context, scope);
     _moduleContext = new ModuleContext(_module, context);
 }
Beispiel #5
0
        internal override void FinishBind(TotemNameBinder binder)
        {
            base.FinishBind(binder);

            TotemGlobal[] globalArray = new TotemGlobal[_globalVars == null ? 0 : _globalVars.Count];
            Dictionary<string, TotemGlobal> globals = new Dictionary<string, TotemGlobal>();
            GlobalDictionaryStorage storage = new GlobalDictionaryStorage(globals, globalArray);
            var modContext = _moduleContext = new ModuleContext(new TotemDictionary(storage), TotemContext);

            //if (_mode == CompilationMode.ToDisk)
            //{
            //    _arrExpression = _globalArray;
            //}
            //else
            //{
                var newArray = new ConstantExpr(globalArray);
                newArray.Parent = this;
                _arrayExpression = newArray;
            //}

            if (_globalVars != null)
            {
                int globalIndex = 0;
                foreach (var variable in _globalVars)
                {
                    TotemGlobal global = new TotemGlobal(modContext.GlobalContext, variable.Name);
                    _globalVariables[variable] = CompilationMode.GetGlobal(GetGlobalContext(), globals.Count, variable, global);
                    globalArray[globalIndex++] = globals[variable.Name] = global;
                }
            }

            CompilationMode.PublishContext(modContext.GlobalContext, _contextInfo);
        }
Beispiel #6
0
        public TotemModule InitializeModule(string fileName, ModuleContext moduleContext, ScriptCode scriptCode, ModuleOptions options)
        {
            moduleContext.InitializeBuiltins();

            moduleContext.Features = options;

            if ((options & ModuleOptions.Initialize) != 0)
            {
                scriptCode.Run(moduleContext.GlobalScope);
            }

            return moduleContext.Module;
        }
Beispiel #7
0
        public TotemContext(ScriptDomainManager manager, IDictionary<string, object> options)
            : base(manager)
        {
            _options = new TotemOptions(options);
            _builtinModulesDict = CreateBuiltinTable();

            TotemDictionary defaultScope = new TotemDictionary();
            ModuleContext moduleContext = new ModuleContext(defaultScope, this);
            _defaultContext = moduleContext.GlobalContext;


            TotemBinder binder = new TotemBinder(this, _defaultContext);
            _sharedOverloadResolverFactory = new TotemOverloadResolverFactory(binder, Expression.Constant(_defaultContext));
            _binder = binder;

            if (DefaultContext._default == null)
            {
                DefaultContext.InitializeDefaults(_defaultContext);
            }

            RecursionLimit = _options.RecursionLimit;

            InitializeBuiltins();
        }