예제 #1
0
        private static void RecompileClasses(SmalltalkNameScope scope)
        {
            List <SmalltalkClass> toRecompile = new List <SmalltalkClass>();

            foreach (ClassBinding cls in scope.Classes)
            {
                // Do not recompile classes that we are going to recompile anyway
                bool subclassOfRecompiled = false;
                foreach (ClassBinding c in scope.Classes)
                {
                    if (NativeLoadHelper.InheritsFrom(cls.Value, c.Value))
                    {
                        subclassOfRecompiled = true;
                        break;
                    }
                }
                if (!subclassOfRecompiled)
                {
                    toRecompile.Add(cls.Value);
                }
            }

            foreach (SmalltalkClass cls in toRecompile)
            {
                cls.Recompile();
            }
        }
예제 #2
0
        public static CompiledInitializer AddGlobalInitializer(SmalltalkRuntime runtime, SmalltalkNameScope scope, Type delegateType, string delegateName, string globalName)
        {
            GlobalVariableOrConstantBinding binding = scope.GetGlobalVariableOrConstantBinding(globalName);

            if (binding == null)
            {
                throw new ArgumentException(String.Format("Global variable or constant named {0} does not exist.", globalName));
            }
            return(NativeLoadHelper.AddInitializer(scope, InitializerType.GlobalInitializer, binding, delegateType, delegateName));
        }
예제 #3
0
        public static CompiledInitializer AddClassInitializer(SmalltalkRuntime runtime, SmalltalkNameScope scope, Type delegateType, string delegateName, string className)
        {
            ClassBinding binding = scope.GetClassBinding(className);

            if (binding == null)
            {
                throw new ArgumentException(String.Format("Class named {0} does not exist.", className));
            }
            return(NativeLoadHelper.AddInitializer(scope, InitializerType.ClassInitializer, binding, delegateType, delegateName));
        }
예제 #4
0
        public static CompiledInitializer AddPoolInitializer(SmalltalkRuntime runtime, SmalltalkNameScope scope, Type delegateType, string delegateName, string poolName, string poolItemName)
        {
            PoolBinding poolBinding = scope.GetPoolBinding(poolName);

            if ((poolBinding == null) || (poolBinding.Value == null))
            {
                throw new ArgumentException(String.Format("Pool named {0} does not exist.", poolName));
            }
            PoolVariableOrConstantBinding binding = poolBinding.Value[poolItemName];

            if (binding == null)
            {
                throw new ArgumentException(String.Format("Pool variable or constant named {0} does not exist in pool {1}.", poolItemName, poolName));
            }
            return(NativeLoadHelper.AddInitializer(scope, InitializerType.PoolVariableInitializer, binding, delegateType, delegateName));
        }
예제 #5
0
        public static SmalltalkRuntime CreateRuntime(bool initialize, Action <SmalltalkRuntime, SmalltalkNameScope> extensionScopeInitializer, Action <SmalltalkRuntime, SmalltalkNameScope> globalScopeInitializer)
        {
            if (extensionScopeInitializer == null)
            {
                throw new ArgumentNullException("extensionScopeInitializer");
            }
            if (globalScopeInitializer == null)
            {
                throw new ArgumentNullException("globalScopeInitializer");
            }

            SmalltalkRuntime runtime = new SmalltalkRuntime();

            ExecutionContext executionContext = new ExecutionContext(runtime);

            // Extension scope
            SmalltalkNameScope scope = runtime.ExtensionScope.Copy();

            extensionScopeInitializer(runtime, scope);
            runtime.SetExtensionScope(scope);
            runtime.SetGlobalScope(runtime.GlobalScope.Copy(scope));
            NativeLoadHelper.RecompileClasses(scope);
            if (initialize)
            {
                scope.ExecuteInitializers(executionContext);
            }

            // Global scope
            scope = runtime.GlobalScope.Copy();
            globalScopeInitializer(runtime, scope);
            runtime.SetGlobalScope(scope);
            NativeLoadHelper.RecompileClasses(scope);
            if (initialize)
            {
                scope.ExecuteInitializers(executionContext);
            }

            return(runtime);
        }
예제 #6
0
 public static NativeCompiledMethod AddInstanceMethod(Dictionary <Symbol, CompiledMethod> dictionary, SmalltalkClass cls, string selector, Type containingType, string nativeName)
 {
     return(NativeLoadHelper.AddMethod(dictionary, cls, selector, containingType, nativeName, CompiledMethod.MethodType.Instance));
 }
예제 #7
0
 public static CompiledInitializer AddProgramInitializer(SmalltalkRuntime runtime, SmalltalkNameScope scope, Type delegateType, string delegateName)
 {
     return(NativeLoadHelper.AddInitializer(scope, InitializerType.ProgramInitializer, null, delegateType, delegateName));
 }