AjTalk.Loader.LoadAndExecute C# (CSharp) Method

LoadAndExecute() public method

public LoadAndExecute ( Machine machine ) : void
machine Machine
return void
        public void LoadAndExecute(Machine machine)
        {
            string blocktext;

            blocktext = this.GetBlockText();

            while (blocktext != null)
            {
                bool isprocessor = false;

                string trimmed = blocktext.Trim();

                if (trimmed.StartsWith("!"))
                {
                    trimmed = trimmed.Substring(1);
                    isprocessor = true;
                }

                if (String.IsNullOrEmpty(trimmed))
                {
                    blocktext = this.GetBlockText();
                    continue;
                }

                Block block = this.compiler.CompileBlock(trimmed);
                var value = block.Execute(machine, null);

                if (isprocessor)
                    ((ChunkReaderProcessor)value).Process(this.reader, machine, this.compiler);

                blocktext = this.GetBlockText();
            }

            this.reader.Close();
            this.reader = null;
        }

Usage Example

Ejemplo n.º 1
0
        public void ExecuteCommentBlock()
        {
            Loader loader = new Loader(new StringReader("\"comment\""), new SimpleCompiler());
            Machine machine = new Machine();

            loader.LoadAndExecute(machine);
        }
All Usage Examples Of AjTalk.Loader::LoadAndExecute