Esempio n. 1
0
        public ParseCompileAndRunErrors Run(IProject project, Processors processors = null)
        {
            var compileResult = Compile(project);

            if (compileResult.Any(c => c.HasErrors))
            {
                var result = new ParseAndCompileResult();
                foreach (var error in compileResult.SelectMany(e => e.Errors))
                {
                    result.Errors.Add(error);
                }
                return(result);
            }

            return(Start(processors, project.Libs(), compileResult));
        }
Esempio n. 2
0
        public ParseCompileAndRunErrors Start(
            Processors processors,
            IEnumerable <ILibrary> libs,
            List <ParseAndCompileResult> compileResult)
        {
            var result = new ParseAndCompileResult();

            if (processors == null)
            {
                processors = new Processors();
            }

            _runtime = new Runtime(processors);

            //// link
            foreach (var library in libs)
            {
                _runtime.Link(library);
            }

            //// compile all methods across all files
            foreach (var binary in compileResult)
            {
                _runtime.EvaluateFunctionDeclatrations(binary.Compilation);
                if (_runtime.Errors.Any())
                {
                    break;
                }
            }

            //// start code processing
            foreach (var binary in compileResult)
            {
                _runtime.Evaluate(binary.Compilation);
                if (_runtime.Errors.Any())
                {
                    break;
                }
            }

            foreach (var runtimeError in _runtime.Errors)
            {
                result.Errors.Add(runtimeError);
            }

            return(result);
        }