public override Runlet Weave(Runlet continuation, GlobalDictionary g) { if (this.Scope == "global") { Ident ident = g.Get(Name); if (this.Reftype == "get") { return(new PushIdentRunlet(ident, continuation)); } else { throw new UnimplementedNutmegException(); } } else if (this.Scope == "local" && this.Slot >= 0) { if (this.Reftype == "get") { return(new PushSlotRunlet(this.Slot, continuation)); } else { throw new UnimplementedNutmegException(); } } else { throw new UnimplementedNutmegException(); } }
public override void UpdateLinkNotification() { while (this._next is JumpRunlet j && j.Next != null) { this._next = j.Next; } }
public RunletWithNext(Runlet next) { while (next is JumpRunlet j && j.Next != null) { next = j.Next; } this._next = next?.Track(this); }
public void UpdateLink(Runlet runlet) { this._next = runlet; foreach (var r in this._tracked) { r.UpdateLinkNotification(); } }
public override Runlet Weave(Runlet continuation, GlobalDictionary g) { for (int i = Body.Length - 1; i >= 0; i -= 1) { Codelet codelet = Body[i]; continuation = codelet.Weave(continuation, g); } return(continuation); }
public override Runlet Weave(Runlet continuation, GlobalDictionary g) { if (long.TryParse(this.Value, out var n)) { return(new PushQRunlet(n, continuation)); } else { throw new Exception($"Invalid int value: {Value}"); } }
public override void UpdateLinkNotification() { while (this.ThenPart is JumpRunlet thenj && thenj.Next != null) { this.ThenPart = thenj.Next; } while (this.ElsePart is JumpRunlet elsej && elsej.Next != null) { this.ElsePart = elsej.Next; } }
public void StartFromCodelet(Runlet codelet, bool useEvaluate) { TextWriter stdErr = Console.Error; if (codelet is FunctionRunlet fwc) { if (Debug) { stdErr.WriteLine($"Running codelet ..."); } try { Runlet currentInstruction = new LockRunlet(new CallQRunlet(fwc, new HaltRunlet())); if (Debug) { while (true) { Console.WriteLine($"Instruction: {currentInstruction}"); currentInstruction = currentInstruction.ExecuteRunlet(this); } } else { while (true) { currentInstruction = currentInstruction.ExecuteRunlet(this); } } } catch (NormalExitNutmegException) { // Normal exit. } finally { if (Debug) { stdErr.WriteLine($"Bye, bye ..."); } } } else { stdErr.WriteLine("Entry point {id} is not a function"); } }
public LTESystemFunction(Runlet next) : base(next) { }
public SubtractSystemFunction(Runlet next) : base(next) { }
public CallSRunlet(Runlet next) : base(next) { }
public abstract Runlet Weave(Runlet continuation, GlobalDictionary g);
public override Runlet Weave(Runlet continuation, GlobalDictionary g) { return(TestPart.Weave(new ForkRunlet(ThenPart.Weave(continuation, g), ElsePart.Weave(continuation, g)), g)); }
public override Runlet Weave(Runlet continuation, GlobalDictionary g) { return(new LockRunlet(Arguments.Weave(Funarg.Weave(new CallSRunlet(continuation), g), g))); }
public ForkRunlet(Runlet thenPart, Runlet elsePart) { this.ThenPart = thenPart.Track(this); this.ElsePart = elsePart.Track(this); }
public override Runlet Track(Runlet runlet) { this._tracked.Add(runlet); return(this); }
public JumpRunlet(Runlet next) : base(next) { }
public PushQRunlet(object value, Runlet next) : base(next) { this._value = value; }
public override Runlet Weave(Runlet continuation, GlobalDictionary g) { return(new FunctionRunlet(Nargs, Nlocals, this.Body.Weave(new ReturnRunlet(), g), continuation)); }
public virtual Runlet Track(Runlet runlet) { return(this); }
public PushIdentRunlet(Ident ident, Runlet next) : base(next) { this._ident = ident; }
public PrintlnSystemFunction(Runlet next) : base(next) { }
public override Runlet Weave(Runlet continuation, GlobalDictionary g) { return(new LockRunlet(Arguments.Weave(_systemFunction(continuation), g))); }
public AddSystemFunction(Runlet next) : base(next) { }
public override Runlet Weave(Runlet continuation, GlobalDictionary g) { return(new PushQRunlet(this.Value, continuation)); }
public SumSystemFunction(Runlet next) : base(next) { }
public void Start(string idName, bool useEvaluate) { Runlet codelet = (Runlet)(this._dictionary.Get(idName).Value); StartFromCodelet(codelet, useEvaluate); }
public SystemFunction(Runlet next) { this.Next = next; }
public void PushReturnAddress(Runlet next) { this._callStack.Push(next); }
public FunctionRunlet(int nargs, int nlocals, Runlet startCodelet, Runlet next) : base(next) { this.Nargs = nargs; this.Nlocals = nlocals; this._startCodelet = startCodelet; }