コード例 #1
0
 /// <summary>
 /// Create a new SmalltalkScriptCode.
 /// </summary>
 /// <param name="code">Initializer code representing the code to be execution.</param>
 /// <param name="runtime">The IronSmalltalk Runtime this source is bound to.</param>
 /// <param name="sourceUnit">SourceUnit that resulted in the generated code.</param>
 public SmalltalkScriptCode(CompiledInitializer code, SmalltalkRuntime runtime, SourceUnit sourceUnit)
     : base(sourceUnit)
 {
     if (code == null)
     {
         throw new ArgumentNullException("code");
     }
     if (runtime == null)
     {
         throw new ArgumentNullException("runtime");
     }
     if (sourceUnit == null)
     {
         throw new ArgumentNullException("sourceUnit");
     }
     this.Code    = code;
     this.Runtime = runtime;
 }
コード例 #2
0
        internal static InitializerGenerator GetInitializerGenerator(NativeCompiler compiler, CompiledInitializer initializer)
        {
            if (initializer == null)
            {
                throw new ArgumentNullException("initializer");
            }
            switch (initializer.Type)
            {
            case InitializerType.ProgramInitializer:
                RuntimeProgramInitializer programInitializer = initializer as RuntimeProgramInitializer;
                if (programInitializer == null)
                {
                    throw new Exception("Expected to see a RuntimeProgramInitializer");     // ... since we have compiled everything ourself.
                }
                return(new ProgramInitializerGenerator(compiler, programInitializer));

            case InitializerType.GlobalInitializer:
                RuntimeGlobalInitializer globalInitializer = initializer as RuntimeGlobalInitializer;
                if (globalInitializer == null)
                {
                    throw new Exception("Expected to see a RuntimeGlobalInitializer");     // ... since we have compiled everything ourself.
                }
                return(new GlobalInitializerGenerator(compiler, globalInitializer));

            case InitializerType.ClassInitializer:
                RuntimeGlobalInitializer classInitializer = initializer as RuntimeGlobalInitializer;
                if (classInitializer == null)
                {
                    throw new Exception("Expected to see a RuntimeGlobalInitializer");     // ... since we have compiled everything ourself.
                }
                return(new ClassInitializerGenerator(compiler, classInitializer));

            case InitializerType.PoolVariableInitializer:
                RuntimePoolItemInitializer poolItemInitializer = initializer as RuntimePoolItemInitializer;
                if (poolItemInitializer == null)
                {
                    throw new Exception("Expected to see a RuntimePoolItemInitializer");     // ... since we have compiled everything ourself.
                }
                return(new PoolVariableInitializerGenerator(compiler, poolItemInitializer));

            default:
                throw new Exception(String.Format("Unrecognized initializer type {0}", initializer.Type));
            }
        }
コード例 #3
0
 void ISmalltalkNameScopeVisitor.Visit(CompiledInitializer initializer)
 {
     this.Initializers.Add(InitializerGenerator.GetInitializerGenerator(this.Compiler, initializer));
 }
コード例 #4
0
 void IDefinitionInstallerContext.AddInitializer(CompiledInitializer initializer)
 {
     this.NameScope.Initializers.Add(initializer);
 }