Example #1
0
		internal TransientModuleBuilder(int id, EvalKinds kind, TransientCompilationUnit/*!*/ compilationUnit,
			TransientAssemblyBuilder/*!*/ assemblyBuilder, TransientModule containingModule, string sourcePath)
            : base(id, kind, compilationUnit, assemblyBuilder.TransientAssembly, containingModule, sourcePath)
		{
			this.assemblyBuilder = assemblyBuilder;

			if (!compilationUnit.IsDynamic)
			{
				this.globalBuilder = assemblyBuilder.RealModuleBuilder.DefineType(MakeName("<Global>", true),
					TypeAttributes.SpecialName | TypeAttributes.Class | TypeAttributes.Public);
			}
			else
			{
				this.globalBuilder = null;
			}
		}
Example #2
0
        internal TransientModuleBuilder(int id, EvalKinds kind, TransientCompilationUnit /*!*/ compilationUnit,
                                        TransientAssemblyBuilder /*!*/ assemblyBuilder, TransientModule containingModule, string sourcePath)
            : base(id, kind, compilationUnit, assemblyBuilder.TransientAssembly, containingModule, sourcePath)
        {
            this.assemblyBuilder = assemblyBuilder;

            if (!compilationUnit.IsDynamic)
            {
                this.globalBuilder = assemblyBuilder.RealModuleBuilder.DefineType(MakeName("<Global>", true),
                                                                                  TypeAttributes.SpecialName | TypeAttributes.Class | TypeAttributes.Public);
            }
            else
            {
                this.globalBuilder = null;
            }
        }
Example #3
0
		/// <summary>
		/// Called before 'Compile' to initialize module &amp; assembly builders, so they can be used by the caller.
		/// </summary>
		internal bool PreCompile(CompilationContext/*!*/ context, ScriptContext/*!*/ scriptContext,
			SourceCodeDescriptor descriptor, EvalKinds kind, DTypeDesc referringType)
		{
			this.resolvingScriptContext = scriptContext;
			this.referringType = referringType;

			// TODO: isDynamic is tricky...
			//  .. we need to define module_builder before any type/etc.. is reduced from the parser
			//  .. but we don't know whether it will be dynamic in advance!

			this.assembly_builder = scriptContext.ApplicationContext.TransientAssemblyBuilder;
			this.module_builder = assembly_builder.DefineModule(this, context.Config.Compiler.Debug,
				descriptor.ContainingTransientModuleId, kind, descriptor.ContainingSourcePath);
			this.module = module_builder;
			this.evalKind = kind;

            sourceUnit.Parse(
                context.Errors, this,
                new Position(descriptor.Line, descriptor.Column, 0, descriptor.Line, descriptor.Column, 0),
                context.Config.Compiler.LanguageFeatures);

			if (context.Errors.AnyFatalError) return false;

			// any declaration implies non-dynamicity:
			// TODO: this mode needs to be checked...
			// isDynamic = types == null && functions == null && constants == null;

			return true;
		}