Exemple #1
0
 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();
     }
 }
Exemple #2
0
 public override void UpdateLinkNotification()
 {
     while (this._next is JumpRunlet j && j.Next != null)
     {
         this._next = j.Next;
     }
 }
Exemple #3
0
 public RunletWithNext(Runlet next)
 {
     while (next is JumpRunlet j && j.Next != null)
     {
         next = j.Next;
     }
     this._next = next?.Track(this);
 }
Exemple #4
0
 public void UpdateLink(Runlet runlet)
 {
     this._next = runlet;
     foreach (var r in this._tracked)
     {
         r.UpdateLinkNotification();
     }
 }
Exemple #5
0
 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);
 }
Exemple #6
0
 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}");
     }
 }
Exemple #7
0
 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;
     }
 }
Exemple #8
0
        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");
            }
        }
Exemple #9
0
 public LTESystemFunction(Runlet next) : base(next)
 {
 }
Exemple #10
0
 public SubtractSystemFunction(Runlet next) : base(next)
 {
 }
Exemple #11
0
 public CallSRunlet(Runlet next) : base(next)
 {
 }
Exemple #12
0
 public abstract Runlet Weave(Runlet continuation, GlobalDictionary g);
Exemple #13
0
 public override Runlet Weave(Runlet continuation, GlobalDictionary g)
 {
     return(TestPart.Weave(new ForkRunlet(ThenPart.Weave(continuation, g), ElsePart.Weave(continuation, g)), g));
 }
Exemple #14
0
 public override Runlet Weave(Runlet continuation, GlobalDictionary g)
 {
     return(new LockRunlet(Arguments.Weave(Funarg.Weave(new CallSRunlet(continuation), g), g)));
 }
Exemple #15
0
 public ForkRunlet(Runlet thenPart, Runlet elsePart)
 {
     this.ThenPart = thenPart.Track(this);
     this.ElsePart = elsePart.Track(this);
 }
Exemple #16
0
 public override Runlet Track(Runlet runlet)
 {
     this._tracked.Add(runlet);
     return(this);
 }
Exemple #17
0
 public JumpRunlet(Runlet next) : base(next)
 {
 }
Exemple #18
0
 public PushQRunlet(object value, Runlet next) : base(next)
 {
     this._value = value;
 }
Exemple #19
0
 public override Runlet Weave(Runlet continuation, GlobalDictionary g)
 {
     return(new FunctionRunlet(Nargs, Nlocals, this.Body.Weave(new ReturnRunlet(), g), continuation));
 }
Exemple #20
0
 public virtual Runlet Track(Runlet runlet)
 {
     return(this);
 }
Exemple #21
0
 public PushIdentRunlet(Ident ident, Runlet next) : base(next)
 {
     this._ident = ident;
 }
Exemple #22
0
 public PrintlnSystemFunction(Runlet next) : base(next)
 {
 }
Exemple #23
0
 public override Runlet Weave(Runlet continuation, GlobalDictionary g)
 {
     return(new LockRunlet(Arguments.Weave(_systemFunction(continuation), g)));
 }
Exemple #24
0
 public AddSystemFunction(Runlet next) : base(next)
 {
 }
Exemple #25
0
 public override Runlet Weave(Runlet continuation, GlobalDictionary g)
 {
     return(new PushQRunlet(this.Value, continuation));
 }
Exemple #26
0
 public SumSystemFunction(Runlet next) : base(next)
 {
 }
Exemple #27
0
        public void Start(string idName, bool useEvaluate)
        {
            Runlet codelet = (Runlet)(this._dictionary.Get(idName).Value);

            StartFromCodelet(codelet, useEvaluate);
        }
Exemple #28
0
 public SystemFunction(Runlet next)
 {
     this.Next = next;
 }
Exemple #29
0
 public void PushReturnAddress(Runlet next)
 {
     this._callStack.Push(next);
 }
Exemple #30
0
 public FunctionRunlet(int nargs, int nlocals, Runlet startCodelet, Runlet next) : base(next)
 {
     this.Nargs         = nargs;
     this.Nlocals       = nlocals;
     this._startCodelet = startCodelet;
 }