예제 #1
0
        private FileModuleLiteral ConvertAndRegisterSourceFile(RuntimeModelContext runtimeModelContext, Workspace workspace, ISourceFile sourceFile, AbsolutePath path, bool isConfig)
        {
            var moduleLiteral = ModuleLiteral.CreateFileModule(path, FrontEndHost.ModuleRegistry, runtimeModelContext.Package, sourceFile.LineMap);

            var conversionContext = new AstConversionContext(runtimeModelContext, path, sourceFile, moduleLiteral);
            var converter         = AstConverter.Create(Context.QualifierTable, conversionContext, ConversionConfiguration, workspace);

            Script.SourceFile convertedSourceFile = null;
            if (!isConfig)
            {
                convertedSourceFile = converter.ConvertSourceFile().SourceFile;
            }
            else if (Kind == ConfigurationKind.PrimaryConfig)
            {
                converter.ConvertConfiguration();
            }
            else if (Kind == ConfigurationKind.ModuleConfig)
            {
                converter.ConvertPackageConfiguration();
            }
            else
            {
                throw Contract.AssertFailure(UnimplementedOperationForConfigKindErrorMessage);
            }

            runtimeModelContext.Package.AddParsedProject(path);

            if (!Logger.HasErrors)
            {
                RegisterSuccessfullyParsedModule(convertedSourceFile, moduleLiteral, runtimeModelContext.Package);
            }

            return(moduleLiteral);
        }
예제 #2
0
        private static IAstConverter CreateAstConverter(ISourceFile sourceFile, FileModuleLiteral module,
                                                        RuntimeModelContext runtimeModelContext, AbsolutePath specPath, AstConversionConfiguration conversionConfiguration, Workspace workspace)
        {
            var conversionContext = new AstConversionContext(runtimeModelContext, specPath, sourceFile, module);

            return(AstConverter.Create(runtimeModelContext.QualifierTable, conversionContext, conversionConfiguration, workspace));
        }