public EarleStackFrameExecutor(EarleFunction function, EarleStackFrame parentFrame, int callerIp, EarleValue target, IEarleRuntimeScope superScope, EarleDictionary locals) : base(target) { Frame = parentFrame.SpawnChild(function, this, callerIp); Scopes.Push(new EarleRuntimeScope(superScope, locals)); }
public EarleStackFrame(EarleRuntime runtime, EarleFunction function, IEarleStackFrameExecutor executor, int callerIp, EarleStackFrame superFrame, EarleThread thread) { if (runtime == null) throw new ArgumentNullException(nameof(runtime)); if (thread == null) throw new ArgumentNullException(nameof(thread)); Runtime = runtime; ParentFrame = superFrame; Executor = executor; CallerIP = callerIp; Function = function; Thread = thread; }
public void Register(EarleFunction native) { if (native == null) throw new ArgumentNullException(nameof(native)); _natives.Add(native); }
internal EarleStackFrame SpawnChild(EarleFunction function, IEarleStackFrameExecutor executor, int callerIp) { return new EarleStackFrame(Runtime, function, executor, callerIp, this, Thread); }
public IEnumerable<string> GetDebugInformation(EarleFunction function) { if (function == null) throw new ArgumentNullException(nameof(function)); yield return $"Function {function.File.Name}::{function.Name} compiled to ({function.PCode.Length:000000} bytes):"; for (var index = 0; index < function.PCode.Length; index++) { var b = function.PCode[index]; var o = (OpCode) b; var a = o.GetCustomAttribute<OpCodeAttribute>(); yield return a.BuildString(function.PCode, ref index); } yield return string.Empty; }