Beispiel #1
0
        public CodePart Compile(int startLineNum, ParseTree tree, Context context, CompilerOptions options)
        {
            InitCompileFlags();

            part = new CodePart();
            this.context = context;
            this.options = options;
            this.startLineNum = startLineNum;

            ++context.NumCompilesSoFar;

            try
            {
                if (tree.Nodes.Count > 0)
                {
                    PreProcess(tree);
                    CompileProgram(tree);
                }
            }
            catch (KOSException kosException)
            {
                if (lastNode != null)
                {
                    throw;  // TODO something more sophisticated will go here that will
                    // attach source/line information to the exception before throwing it upward.
                    // that's why this seemingly pointless "catch and then throw again" is here.
                }
                SafeHouse.Logger.Log("Exception in Compiler: " + kosException.Message);
                SafeHouse.Logger.Log(kosException.StackTrace);
                throw;  // throw it up in addition to logging the stack trace, so the kOS terminal will also give the user some message.
            }

            return part;
        }
Beispiel #2
0
        public CodePart Compile(int startLineNum, ParseTree tree, Context context, CompilerOptions options)
        {
            InitCompileFlags();

            part = new CodePart();
            this.context = context;
            this.options = options;
            this.startLineNum = startLineNum;

            ++context.NumCompilesSoFar;

            if (tree.Nodes.Count > 0)
            {
                PreProcess(tree);
                CompileProgram(tree);
            }
            return part;
        }
Beispiel #3
0
 private void LoadContext(string contextId)
 {
     if (contextId != string.Empty)
     {
         if (contexts.ContainsKey(contextId))
         {
             currentContext = contexts[contextId];
         }
         else
         {
             currentContext = new Context();
             contexts.Add(contextId, currentContext);
         }
     }
     else
     {
         currentContext = new Context();
     }
 }