private void Set() { RequiresText( name => { FiclStackEntry.Item item = FiclFifo.Pop(); // take from stack Contexts.Top[1][name] = () => FiclFifo.Push(item); // and save as word }); }
private void If() { CompilingStarter("If"); Code.Push( () => { if (!FiclFifo.Pop().True()) { codePointer++; // skip leave } }); Leave(); // this gets hit if the if statement is false }
private Runtime() { ResetContext(); ActorDictionary immediate = Core[0]; ActorDictionary word = Core[1]; #region Arithmetic word["+"] = FiclFifo.Add; word["-"] = FiclFifo.Subtract; word["*"] = FiclFifo.Multiply; word["/"] = FiclFifo.Divide; word["dec"] = FiclFifo.Decrement; word["inc"] = FiclFifo.Increment; #endregion #region Boolean Operators word["and"] = FiclFifo.And; word["not"] = FiclFifo.Not; word["or"] = FiclFifo.Or; #endregion #region Comparators word[">"] = FiclFifo.GreaterThan; word["<"] = FiclFifo.LessThan; word[">="] = FiclFifo.GreaterThanOrEqual; word["<="] = FiclFifo.LessThanOrEqual; word["="] = FiclFifo.Equals; #endregion #region Debugging word[".d"] = Debugging; word[".s"] = StackDump; #endregion #region Define New Words immediate[":"] = Colon; word["return"] = Return; immediate[";"] = Semicolon; #endregion #region Flow Control immediate["begin"] = Begin; immediate["leave"] = Leave; immediate["again"] = Again; immediate["end"] = End; immediate["if"] = If; immediate["else"] = Else; immediate["then"] = End; #endregion #region I/O word["."] = () => log(FiclFifo.Pop().ToString()); #endregion #region Stack Control word["drop"] = FiclFifo.Drop; word["dup"] = FiclFifo.Dup; word["swap"] = FiclFifo.Swaps; word["over"] = FiclFifo.Over; #endregion #region Arrays, strings, comments and other objects word["["] = ListStart; immediate["]:"] = ListEnd; immediate["\""] = DoubleQuote; immediate["'"] = SingleQuote; immediate["("] = OpenBracket; #endregion #region Variables immediate["set:"] = Set; immediate[":on-update"] = FiclFifo.OnUpdate; immediate["ref:"] = FiclFifo.Ref; #endregion }