コード例 #1
0
        private void InitializeEnvironment()
        {
            //// Install the Standard Class Library
            //if (this.IncludeStandardClassLibrary)
            //{
            //    ResourceStreamContentProvider contentProvider = new ResourceStreamContentProvider(this.GetType(), "IronSmalltalk.ist");
            //    SourceUnit sourceUnit = this.CreateSourceUnit(contentProvider, null, this.DefaultEncoding, SourceCodeKind.Statements);
            //    ErrorSinkWrapper errorSink = new ErrorSinkWrapper(sourceUnit, ErrorSink.Default);
            //    InternalCompilerService service = new InternalCompilerService(this.SmalltalkEnvironment.Runtime);
            //    service.Install(new DelegateFileInInformation(() => sourceUnit.GetReader(), errorSink));
            //}

            //// Install the rest that is to be filed-in
            //this.SmalltalkEnvironment.CompilerService.Install(this.FileInCommands.Select(command =>
            //{
            //    SourceUnit sourceUnit = command.GetSourceUnit(this);
            //    ErrorSinkWrapper errorSink = new ErrorSinkWrapper(sourceUnit, ErrorSink.Default);
            //    return new DelegateFileInInformation(() => sourceUnit.GetReader(), errorSink);
            //}));

            // Install the Standard Class Library
            IEnumerable <FileInInformation> ist = new FileInInformation[0];

            if (this.IncludeStandardClassLibrary)
            {
                ResourceStreamContentProvider contentProvider = new ResourceStreamContentProvider(this.GetType(), "IronSmalltalk.ist");
                SourceUnit        sourceUnit = this.CreateSourceUnit(contentProvider, null, this.DefaultEncoding, SourceCodeKind.Statements);
                ErrorSinkWrapper  errorSink  = new ErrorSinkWrapper(sourceUnit, ErrorSink.Default);
                FileInInformation fileIn     = new DelegateFileInInformation(() => sourceUnit.GetReader(), errorSink, sourceUnit.Document);
                // BUG BUG - Can't get the InternalCompilerService to work yet.
                //InternalCompilerService service = new InternalCompilerService(this.SmalltalkEnvironment.Runtime);
                //service.Install(fileIn);

                // File in normally
                ist = new FileInInformation[] { fileIn };
            }

            var fileIns = this.FileInCommands.Select(command =>
            {
                SourceUnit sourceUnit      = command.GetSourceUnit(this);
                ErrorSinkWrapper errorSink = new ErrorSinkWrapper(sourceUnit, ErrorSink.Default);
                return(new DelegateFileInInformation(() => sourceUnit.GetReader(), errorSink, sourceUnit.Document));
            });

            // Install the rest that is to be filed-in
            this.SmalltalkEnvironment.CompilerService.Install(ist.Concat(fileIns));
        }
コード例 #2
0
            public void AddInstallError(string installErrorMessage, ISourceReference sourceReference)
            {
                if (sourceReference == null)
                {
                    throw new ArgumentNullException("sourceReference");
                }
                FileInInformation sourceObject = sourceReference.Service.SourceObject as FileInInformation;

#if DEBUG
                System.Diagnostics.Debug.Assert(sourceObject != null);
#endif
                if (sourceObject == null)
                {
                    return; // This is like having no error sink
                }
                if (sourceObject.ErrorSink == null)
                {
                    return;
                }
                sourceObject.ErrorSink.AddInstallError(sourceReference.StartPosition, sourceReference.StopPosition, installErrorMessage);
            }