Beispiel #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));
        }
Beispiel #2
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);

        }
Beispiel #3
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;
        }