コード例 #1
0
ファイル: Orange.cs プロジェクト: toddcoder/Orange
        public string Execute()
        {
            CompilerState.Reset();
            IDEColors.Clear();
            Coloring       = true;
            MessagingState = new MessageManager();
            block          = Compile(source);
            verboseText    = "";
            Coloring       = false;
            if (AutoVariable)
            {
                block.Add(new End());
                block.Add(new Push(new Variable("$out")));
                block.Add(new Assign());
                block.Add(new Push(new Variable("sys")));
                block.Add(new SendMessage("dump", new Arguments()));
                block.Add(new End());
            }
            var runtime = new OrangeRuntime(block, Text, fileCache, console)
            {
                ModuleFolders = ModuleFolders
            };

            try
            {
                var result = runtime.Execute();
                LastValue = runtime.LastValue;
                LastType  = runtime.LastType;
                return(result);
            }
            catch (Stop.StopException exception)
            {
                LastValue = exception.Message;
                LastType  = "Stopped";
                return($"Stopped: {exception.Message}");
            }
        }