Ejemplo n.º 1
0
        public CompilerResult Compile(ElaProgram prog, CompilerOptions options, ExportVars builtins, CodeFrame frame, Scope globalScope)
        {
            Options = options;
            var helper = new Builder(frame, this, builtins, globalScope);

            try
            {
                helper.CompileUnit(prog);
            }
            catch (TerminationException)
            {
                //Nothing should be done here. This was thrown to stop compilation.
            }
#if !DEBUG
            catch (Exception ex)
            {
                if (ex is ElaCompilerException)
                {
                    throw;
                }

                throw new ElaCompilerException(Strings.GetMessage("Ice", ex.Message), ex);
            }
#endif

            frame.Symbols = frame.Symbols == null ? helper.Symbols :
                            helper.Symbols != null?frame.Symbols.Merge(helper.Symbols) : frame.Symbols;

            frame.GlobalScope = globalScope;
            return(new CompilerResult(frame, helper.Success, helper.Errors.ToArray()));
        }
Ejemplo n.º 2
0
        public CompilerResult Compile(ElaProgram prog, CompilerOptions options, ExportVars builtins, CodeFrame frame, Scope globalScope)
        {
            Options = options;
            var helper = new Builder(frame, this, builtins, globalScope);

            try
            {
                helper.CompileUnit(prog);
            }
            catch (TerminationException)
            {
                //Nothing should be done here. This was thrown to stop compilation.
            }
            #if !DEBUG
            catch (Exception ex)
            {
                if (ex is ElaCompilerException)
                    throw;

                throw new ElaCompilerException(Strings.GetMessage("Ice", ex.Message), ex);
            }
            #endif

            frame.Symbols = frame.Symbols == null ? helper.Symbols :
                helper.Symbols != null ? frame.Symbols.Merge(helper.Symbols) : frame.Symbols;
            frame.GlobalScope = globalScope;
            return new CompilerResult(frame, helper.Success, helper.Errors.ToArray());
        }
Ejemplo n.º 3
0
        private ExportVars exports;                      //Exports for current module

        //globalScope is not empty (e.g. new Scope()) only if we are resuming in interactive mode
        internal Builder(CodeFrame frame, ElaCompiler comp, ExportVars exportVars, Scope globalScope)
        {
            this.frame       = frame;
            this.options     = comp.Options;
            this.exports     = exportVars;
            this.comp        = comp;
            this.cw          = new CodeWriter(frame.Ops, frame.OpData);
            this.globalScope = globalScope;

            CurrentScope = globalScope;
            debug        = options.GenerateDebugInfo;
            opt          = options.Optimize;

            stringLookup = new Dictionary <String, Int32>();
            cleans.Push(true);

            ResumeIndexer();
            Success = true;
        }
Ejemplo n.º 4
0
        private Dictionary<String, Int32> stringLookup; //String table

        #endregion Fields

        #region Constructors

        //globalScope is not empty (e.g. new Scope()) only if we are resuming in interactive mode
        internal Builder(CodeFrame frame, ElaCompiler comp, ExportVars exportVars, Scope globalScope)
        {
            this.frame = frame;
            this.options = comp.Options;
            this.exports = exportVars;
            this.comp = comp;
            this.cw = new CodeWriter(frame.Ops, frame.OpData);
            this.globalScope = globalScope;

            CurrentScope = globalScope;
            debug = options.GenerateDebugInfo;
            opt = options.Optimize;

            stringLookup = new Dictionary<String,Int32>();
            cleans.Push(true);

            ResumeIndexer();
            Success = true;
        }
Ejemplo n.º 5
0
        public CompilerResult Compile(ElaProgram prog, CompilerOptions options, ExportVars builtins)
        {
            var frame = new CodeFrame();

            return(Compile(prog, options, builtins, frame, new Scope(false, null)));
        }
Ejemplo n.º 6
0
 public CompilerResult Compile(ElaProgram prog, CompilerOptions options, ExportVars builtins)
 {
     var frame = new CodeFrame();
     return Compile(prog, options, builtins, frame, new Scope(false, null));
 }