コード例 #1
0
ファイル: RubyOps.cs プロジェクト: mscottford/ironruby
        public static RubyTopLevelScope/*!*/ CreateMainTopLevelScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language,
            out object self, out RuntimeFlowControl/*!*/ rfc, string dataPath, int dataOffset) {
            Assert.NotNull(locals, globalScope, language);

            GlobalScopeExtension rubyGlobalScope = (GlobalScopeExtension)language.EnsureScopeExtension(globalScope);

            RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, null, locals);
            scope.Initialize(new RuntimeFlowControl(), RubyMethodAttributes.PrivateInstance, rubyGlobalScope.MainObject);
            scope.SetDebugName(rubyGlobalScope.IsHosted ? "top-primary-hosted" : "top-primary");

            // define TOPLEVEL_BINDING constant:
            if (!rubyGlobalScope.IsHosted) {
                var objectClass = rubyGlobalScope.Context.ObjectClass;
                    
                objectClass.SetConstant("TOPLEVEL_BINDING", new Binding(scope));
                if (dataOffset >= 0) {
                    RubyFile dataFile;
                    if (File.Exists(dataPath)) {
                        dataFile = new RubyFile(rubyGlobalScope.Context, dataPath, RubyFileMode.RDONLY);
                        dataFile.Seek(dataOffset, SeekOrigin.Begin);
                    } else {
                        dataFile = null;
                    }

                    objectClass.SetConstant("DATA", dataFile);
                }
            }

            self = scope.SelfObject;
            rfc = scope.RuntimeFlowControl;

            return scope;
        }
コード例 #2
0
ファイル: RubyOps.cs プロジェクト: tnachen/ironruby
        public static RubyTopLevelScope/*!*/ CreateMainTopLevelScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language,
            out object self, out RuntimeFlowControl/*!*/ rfc, string dataPath, int dataOffset) {
            Assert.NotNull(locals, globalScope, language);

            RubyContext context = (RubyContext)language;
            RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, false);

            RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, null, locals);
            scope.Initialize(new RuntimeFlowControl(), RubyMethodAttributes.PrivateInstance, rubyGlobalScope.MainObject);
            scope.SetDebugName("top-main");

            var objectClass = context.ObjectClass;
            objectClass.SetConstant("TOPLEVEL_BINDING", new Binding(scope));
            if (dataOffset >= 0) {
                RubyFile dataFile;
                if (context.DomainManager.Platform.FileExists(dataPath)) {
                    dataFile = new RubyFile(context, dataPath, RubyFileMode.RDONLY);
                    dataFile.Seek(dataOffset, SeekOrigin.Begin);
                } else {
                    dataFile = null;
                }

                objectClass.SetConstant("DATA", dataFile);
            }

            self = scope.SelfObject;
            rfc = scope.RuntimeFlowControl;

            return scope;
        }
コード例 #3
0
ファイル: RubyOps.cs プロジェクト: mscottford/ironruby
        public static RubyTopLevelScope/*!*/ CreateTopLevelScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language,
            out object self, out RuntimeFlowControl/*!*/ rfc) {

            RubyTopLevelScope scope = CreateTopLevelScopeInternal(locals, globalScope, language);
            self = scope.SelfObject;
            rfc = scope.RuntimeFlowControl;
            return scope;
        }
コード例 #4
0
ファイル: RubyOps.cs プロジェクト: teejayvanslyke/ironruby
        public static RubyModuleScope/*!*/ CreateModuleScope(LocalsDictionary/*!*/ locals, RubyScope/*!*/ parent,
            RuntimeFlowControl/*!*/ rfc, RubyModule/*!*/ module) {
            Assert.NotNull(locals, parent, rfc, module);

            RubyModuleScope scope = new RubyModuleScope(parent, module, false, rfc, module);
            scope.SetDebugName((module.IsClass ? "class" : "module") + " " + module.Name);

            scope.Frame = locals;
            return scope;
        }
コード例 #5
0
ファイル: RubyOps.cs プロジェクト: tnachen/ironruby
        public static RubyTopLevelScope/*!*/ CreateTopLevelHostedScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language,
            out object self, out RuntimeFlowControl/*!*/ rfc) {

            RubyContext context = (RubyContext)language;
            RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, true);

            // reuse existing top-level scope if available:
            RubyTopLevelScope scope = rubyGlobalScope.TopLocalScope;
            if (scope == null) {
                scope = new RubyTopLevelScope(rubyGlobalScope, null, locals);
                scope.Initialize(new RuntimeFlowControl(), RubyMethodAttributes.PrivateInstance, rubyGlobalScope.MainObject);
                scope.SetDebugName("top-level-hosted");
                rubyGlobalScope.TopLocalScope = scope;
            }

            self = scope.SelfObject;
            rfc = scope.RuntimeFlowControl;
            return scope;
        }
コード例 #6
0
ファイル: DebugFrame.cs プロジェクト: andreakn/ironruby
        internal IAttributesCollection GetLocalsScope() {
            ScopeData scopeData = CurrentScopeData;
            IAttributesCollection scope = scopeData.Scope;
            if (scope == null) {
                Debug.Assert(_liftedLocals != null);

                List<SymbolId> visibleSymbols = new List<SymbolId>();
                List<VariableInfo> visibleLocals = new List<VariableInfo>();

                // Add parameters
                for (int i = 0; i < _funcInfo.Variables.Count; i++) {
                    if (_funcInfo.Variables[i].IsParameter && !_funcInfo.Variables[i].Hidden) {
                        visibleSymbols.Add(_funcInfo.Variables[i].Symbol);
                        visibleLocals.Add(_funcInfo.Variables[i]);
                    }
                }

                // Add locals
                foreach (VariableInfo varInfo in LocalsInCurrentScope) {
                    if (!varInfo.Hidden) {
                        visibleSymbols.Add(varInfo.Symbol);
                        visibleLocals.Add(varInfo);
                    }
                }

                IRuntimeVariables scopedLocals = new ScopedRuntimeVariables(visibleLocals, _liftedLocals);

                scope = new LocalsDictionary(scopedLocals, visibleSymbols.ToArray());

                scopeData.Scope = scope;
            }

            return scope;
        }
コード例 #7
0
ファイル: RubyOps.cs プロジェクト: tnachen/ironruby
        public static RubyBlockScope/*!*/ CreateBlockScope(LocalsDictionary/*!*/ locals, RubyScope/*!*/ parent, 
            BlockParam/*!*/ blockParam, object selfObject) {
            Assert.NotNull(locals, parent, blockParam);

            RubyBlockScope scope = new RubyBlockScope(parent, locals);
            // TODO: used to inherit parent.MethodAttributes
            scope.Initialize(parent.RuntimeFlowControl, RubyMethodAttributes.PublicInstance, selfObject); 
            scope.BlockParameter = blockParam;

            return scope;
        }
コード例 #8
0
ファイル: RubyOps.cs プロジェクト: tnachen/ironruby
        public static RubyMethodScope/*!*/ CreateMethodScope(LocalsDictionary/*!*/ locals, RubyScope/*!*/ parent, 
            RubyMethodInfo/*!*/ methodDefinition, RuntimeFlowControl/*!*/ rfc, object selfObject, Proc blockParameter) {

            Assert.NotNull(locals, parent, methodDefinition, rfc);

            RubyMethodScope scope = new RubyMethodScope(parent, locals, methodDefinition, blockParameter);
            scope.Initialize(rfc, RubyMethodAttributes.PublicInstance, selfObject);

            scope.SetDebugName("method " + 
                methodDefinition.DefinitionName +
                ((blockParameter != null) ? "&" : null)
            );

            return scope;
        }
コード例 #9
0
ファイル: RubyOps.cs プロジェクト: tnachen/ironruby
        public static RubyTopLevelScope/*!*/ CreateWrappedTopLevelScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language,
            out object self, out RuntimeFlowControl/*!*/ rfc) {

            RubyContext context = (RubyContext)language;

            RubyModule module = context.CreateModule(null, null, null, null, null, null, null);
            object mainObject = new Object();
            RubyClass mainSingleton = context.CreateMainSingleton(mainObject, new[] { module });

            RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, false);
            RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, null, locals);
            scope.Initialize(new RuntimeFlowControl(), RubyMethodAttributes.PrivateInstance, rubyGlobalScope.MainObject);
            scope.SetDebugName("top-level-wrapped");
            scope.SelfObject = mainObject;
            scope.SetModule(module);

            self = scope.SelfObject;
            rfc = scope.RuntimeFlowControl;
            return scope;
        }
コード例 #10
0
ファイル: RubyOps.cs プロジェクト: tnachen/ironruby
        public static RubyTopLevelScope/*!*/ CreateTopLevelScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language,
            out object self, out RuntimeFlowControl/*!*/ rfc) {

            RubyContext context = (RubyContext)language;
            RubyGlobalScope rubyGlobalScope = context.InitializeGlobalScope(globalScope, false);

            RubyTopLevelScope scope = new RubyTopLevelScope(rubyGlobalScope, null, locals);
            scope.Initialize(new RuntimeFlowControl(), RubyMethodAttributes.PrivateInstance, rubyGlobalScope.MainObject);
            scope.SetDebugName("top-level");

            self = scope.SelfObject;
            rfc = scope.RuntimeFlowControl;
            return scope;
        }
コード例 #11
0
ファイル: RubyOps.cs プロジェクト: jcteague/ironruby
        public static RubyMethodScope/*!*/ CreateMethodScope(LocalsDictionary/*!*/ locals, RubyScope/*!*/ parent,
            RubyMethodInfo/*!*/ methodDefinition, RuntimeFlowControl/*!*/ rfc, object selfObject, Proc blockParameter) {

            RubyMethodScope scope = new RubyMethodScope(parent, methodDefinition, blockParameter, rfc, selfObject);
            scope.SetDebugName("method " + methodDefinition.DefinitionName + ((blockParameter != null) ? "&" : null));

            scope.Frame = locals;
            return scope;
        }
コード例 #12
0
ファイル: RubyOps.cs プロジェクト: jcteague/ironruby
 public static RubyScope/*!*/ InitializeScope(RubyScope/*!*/ scope, LocalsDictionary/*!*/ locals) {
     if (scope.Frame == null) {
         scope.Frame = locals;
     }
     return scope;
 }
コード例 #13
0
ファイル: RubyOps.cs プロジェクト: mscottford/ironruby
        public static RubyTopLevelScope/*!*/ CreateWrappedTopLevelScope(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language,
            out object self, out RuntimeFlowControl/*!*/ rfc) {

            RubyTopLevelScope scope = CreateTopLevelScopeInternal(locals, globalScope, language);

            RubyModule module = scope.RubyGlobalScope.Context.CreateModule(null, null, null, null, null);

            object mainObject = new Object();
            RubyClass mainSingleton = scope.RubyContext.CreateMainSingleton(mainObject);
            mainSingleton.SetMixins(new RubyModule[] { module });

            scope.SelfObject = mainObject;
            scope.SetModule(module);

            self = scope.SelfObject;
            rfc = scope.RuntimeFlowControl;
            return scope;
        }
コード例 #14
0
ファイル: RubyOps.cs プロジェクト: teejayvanslyke/ironruby
        public static RubyBlockScope/*!*/ CreateBlockScope(LocalsDictionary/*!*/ locals, RubyScope/*!*/ parent,
            BlockParam/*!*/ blockParam, object selfObject, InterpretedFrame interpretedFrame) {
            Assert.NotNull(locals, parent, blockParam);

            RubyBlockScope scope = new RubyBlockScope(parent, parent.RuntimeFlowControl, blockParam, selfObject);
            scope.MethodAttributes = RubyMethodAttributes.PublicInstance;
            scope.Frame = locals;
            scope.InterpretedFrame = interpretedFrame;
            return scope;
        }
コード例 #15
0
ファイル: RubyOps.cs プロジェクト: tnachen/ironruby
 public static RubyModuleScope/*!*/ CreateModuleEvalScope(LocalsDictionary/*!*/ locals, RubyScope/*!*/ parent, object self, RubyModule module) {
     RubyModuleScope scope = new RubyModuleScope(parent, locals, module, true);
     scope.Initialize(parent.RuntimeFlowControl, RubyMethodAttributes.PublicInstance, self);
     scope.SetDebugName("top-module/instance-eval");                
     return scope;
 }
コード例 #16
0
ファイル: RubyOps.cs プロジェクト: teejayvanslyke/ironruby
 public static void InitializeScope(RubyScope/*!*/ scope, LocalsDictionary/*!*/ locals, InterpretedFrame interpretedFrame) {
     if (scope.Frame == null) {
         scope.Frame = locals;
     }
     scope.InterpretedFrame = interpretedFrame;
 }
コード例 #17
0
ファイル: RubyOps.cs プロジェクト: tnachen/ironruby
        public static RubyModuleScope/*!*/ CreateModuleScope(LocalsDictionary/*!*/ locals, RubyScope/*!*/ parent, 
            RuntimeFlowControl/*!*/ rfc, RubyModule/*!*/ module) {
            Assert.NotNull(locals, parent, rfc, module);

            // TODO:
            RubyModuleScope scope = new RubyModuleScope(parent, locals, null, false);
            scope.Initialize(rfc, RubyMethodAttributes.PublicInstance, module);
            scope.SetModule(module);
            scope.SetDebugName((module.IsClass ? "class" : "module") + " " + module.Name);

            return scope;
        }
コード例 #18
0
ファイル: RubyOps.cs プロジェクト: teejayvanslyke/ironruby
        public static RubyMethodScope/*!*/ CreateMethodScope(LocalsDictionary/*!*/ locals,
            RubyScope/*!*/ parentScope, RubyModule/*!*/ declaringModule, string/*!*/ definitionName,
            RuntimeFlowControl/*!*/ rfc, object selfObject, Proc blockParameter,
            InterpretedFrame interpretedFrame) {

            RubyMethodScope scope = new RubyMethodScope(parentScope, declaringModule, definitionName, blockParameter, rfc, selfObject);
            scope.SetDebugName("method " + definitionName + ((blockParameter != null) ? "&" : null));

            scope.Frame = locals;
            scope.InterpretedFrame = interpretedFrame;
            return scope;
        }
コード例 #19
0
ファイル: RubyOps.cs プロジェクト: mscottford/ironruby
        private static RubyTopLevelScope/*!*/ CreateTopLevelScopeInternal(LocalsDictionary/*!*/ locals, Scope/*!*/ globalScope, LanguageContext/*!*/ language) {
            GlobalScopeExtension rubyGlobalScope = (GlobalScopeExtension)language.EnsureScopeExtension(globalScope);
            RubyTopLevelScope result = new RubyTopLevelScope(rubyGlobalScope, null, locals);
            result.Initialize(new RuntimeFlowControl(), RubyMethodAttributes.PrivateInstance, rubyGlobalScope.MainObject);
            result.SetDebugName("top-level");

            return result;
        }