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

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