示例#1
0
        // Private Methods 

        CompileResult Compile(string filename)
        {
            var compileState = new CompileState();
            var langVisitor  = new LangVisitor(compileState)
            {
                throwNotImplementedException = true
            };

            compileState.Context.KnownTypes = CompileState.GetAllTypes(_referencedAssemblies);
            SyntaxTree tree = SyntaxFactory.ParseSyntaxTree(File.ReadAllText(filename));
            // .ParseFile(filename);
            var root = (CompilationUnitSyntax)tree.GetRoot();
            var x    = langVisitor.Visit(root) as CompilationUnit;

            return(new CompileResult(filename, x));
        }
示例#2
0
        public TranslationInfo ParseCsSource()
        {
            // must be public
            var knownTypes = GetKnownTypes();

            CheckRequiredTranslator();

            var translationInfo = new TranslationInfo(Sandbox);

            translationInfo.TranslationAssemblies.AddRange(_translationAssemblies);
            translationInfo.Prepare();
            // Console.WriteLine("======================");

            foreach (var tree in ProjectCompilation.SyntaxTrees)
            {
                var now = DateTime.Now;
                Console.WriteLine("parse file {0}", tree.FilePath);
                var root  = (CompilationUnitSyntax)tree.GetRoot();
                var state = new CompileState
                {
                    Context =
                    {
                        RoslynCompilation = ProjectCompilation,
                        RoslynModel       = ProjectCompilation.GetSemanticModel(tree)
                    }
                };
                translationInfo.State = state;

                var langVisitor = new LangVisitor(state)
                {
                    throwNotImplementedException = true
                };
                state.Context.KnownTypes = knownTypes;
                var compilationUnit = langVisitor.Visit(root) as CompilationUnit;
                translationInfo.Compiled.Add(compilationUnit);
                Console.WriteLine("    {0:0.0} sek", DateTime.Now.Subtract(now).TotalSeconds);
            }

            Console.WriteLine("Parsowanie c# skończone, mamy drzewo definicji");
            translationInfo.FillClassTranslations(knownTypes);
            return(translationInfo);
        }
示例#3
0
		// Private Methods 

        CompileResult Compile(string filename)
        {
            var compileState = new CompileState();
            var langVisitor = new LangVisitor(compileState)
            {
                throwNotImplementedException = true
            };
            compileState.Context.KnownTypes = CompileState.GetAllTypes(_referencedAssemblies);
            SyntaxTree tree = SyntaxFactory.ParseSyntaxTree(File.ReadAllText(filename));
            // .ParseFile(filename);
            var root = (CompilationUnitSyntax)tree.GetRoot();
            var x = langVisitor.Visit(root) as CompilationUnit;
            return new CompileResult(filename, x);

        }
示例#4
0
        public TranslationInfo ParseCsSource()
        {
            // must be public
            var knownTypes = GetKnownTypes();

            CheckRequiredTranslator();

            var translationInfo = new TranslationInfo(_sandbox);
            translationInfo.TranslationAssemblies.AddRange(_translationAssemblies);
            translationInfo.Prepare();
            // Console.WriteLine("======================");

            foreach (var tree in _projectCompilation.SyntaxTrees)
            {
                var now = DateTime.Now;
                Console.WriteLine("parse file {0}", tree.FilePath);
                var root = (CompilationUnitSyntax)tree.GetRoot();
                var state = new CompileState
                {
                    Context =
                    {
                        RoslynCompilation = _projectCompilation,
                        RoslynModel = _projectCompilation.GetSemanticModel(tree)
                    }
                };
                translationInfo.State = state;

                var langVisitor = new LangVisitor(state)
                {
                    throwNotImplementedException = true
                };
                state.Context.KnownTypes = knownTypes;
                var compilationUnit = langVisitor.Visit(root) as CompilationUnit;
                translationInfo.Compiled.Add(compilationUnit);
                Console.WriteLine("    {0:0.0} sek", DateTime.Now.Subtract(now).TotalSeconds);
            }
            Console.WriteLine("Parsowanie c# skończone, mamy drzewo definicji");
            translationInfo.FillClassTranslations(knownTypes);
            return translationInfo;
        }