public void Compile() { if (mBytecode != null) { throw new InvalidOperationException("Can only compile a script once."); } var compiler = new Compiler(mForeign); compiler.FunctionStarted = mDebug.StartFunction; // add the source files foreach (var sourceFile in GetSourceFiles(mPath)) { compiler.AddSourceFile(sourceFile); } using (var stream = new MemoryStream()) { // compile the code mErrors = compiler.Compile(stream); // bail if there were compile errors if (mErrors.Count > 0) { return; } mBytecode = new Magpie.Interpreter.BytecodeFile(stream.ToArray()); } }
public Value Interpret(BytecodeFile file, DebugInfo debug, string argument) { if (file.FindFunction("Main String") != -1) { return Interpret(file, debug, "Main String", new Value(argument)); } else { // no main that takes a string, so look for one with no string return Interpret(file, debug, "Main ()", null); } }
public Value Interpret(BytecodeFile file, DebugInfo debug, string argument) { if (file.FindFunction("Main String") != -1) { return(Interpret(file, debug, "Main String", new Value(argument))); } else { // no main that takes a string, so look for one with no string return(Interpret(file, debug, "Main ()", null)); } }
public Value Interpret(BytecodeFile file, DebugInfo debug, string function, Value argument) { mFile = file; mDebug = debug; int functionOffset = file.FindFunction(function); if (argument != null) { // push the argument Push(argument); Push(functionOffset); Call(1, false); } else { Push(functionOffset); Call(0, false); } return Interpret(); }
public Value Interpret(BytecodeFile file, DebugInfo debug, string function, Value argument) { mFile = file; mDebug = debug; int functionOffset = file.FindFunction(function); if (argument != null) { // push the argument Push(argument); Push(functionOffset); Call(1, false); } else { Push(functionOffset); Call(0, false); } return(Interpret()); }
public void Compile() { if (mBytecode != null) throw new InvalidOperationException("Can only compile a script once."); var compiler = new Compiler(mForeign); compiler.FunctionStarted = mDebug.StartFunction; // add the source files foreach (var sourceFile in GetSourceFiles(mPath)) { compiler.AddSourceFile(sourceFile); } using (var stream = new MemoryStream()) { // compile the code mErrors = compiler.Compile(stream); // bail if there were compile errors if (mErrors.Count > 0) return; mBytecode = new Magpie.Interpreter.BytecodeFile(stream.ToArray()); } }
public Script(byte[] bytecode) { mBytecode = new Magpie.Interpreter.BytecodeFile(bytecode); mErrors = new List<CompileError>(); }
public Value Interpret(BytecodeFile file) { return Interpret(file, null, String.Empty); }
public Value Interpret(BytecodeFile file) { return(Interpret(file, null, String.Empty)); }
public Script(byte[] bytecode) { mBytecode = new Magpie.Interpreter.BytecodeFile(bytecode); mErrors = new List <CompileError>(); }