public static void Create(Forth f) { string word = f.getWord(' '); f.Define(word, MakeLiteralOp((long)f.here)); }
public static void Backslash(Forth f) { f.getWord('\n'); }
public static void LParen(Forth f) { f.getWord(')'); }
public static void PfBytes(Forth f) { if (f.isCompiling) { string hex = f.getWord(' '); f.AppendCode(MakeLiteralOp(HexToBytes(hex))); } else { string hex = f.getWord(' '); f.dStack.Push(HexToBytes(hex)); } }
public static void DotQuote(Forth f) { if (f.isCompiling) { string str = f.getWord('"'); f.AppendCode ( delegate(Forth g) { Console.Write(str); } ); } else { string str = f.getWord('"'); Console.Write(str); } }
public static void CreateVocabulary(Forth f) { string name = f.getWord(' '); Dictionary<string, ForthDictionaryEntry> dict = f.definitions.Dict; if (dict.ContainsKey(name)) dict.Remove(name); dict.Add(name, new ForthDictionaryEntry(new Vocabulary(name))); }
public static void BracketTick(Forth f) { if (!f.isCompiling) throw new InvalidOperationException("bracket-tick is only valid when compiling"); string word = f.getWord(' '); ForthDictionaryEntry fde = f.SearchVocabularies(word); if (fde == null) throw new InvalidOperationException("attempt to bracket-tick undefined word " + word); f.AppendCode(MakeLiteralOp(fde.Proc)); }
public static void Tick(Forth f) { string word = f.getWord(' '); ForthDictionaryEntry fde = f.SearchVocabularies(word); if (fde == null) throw new InvalidOperationException("attempt to tick undefined word " + word); f.dStack.Push(fde.Proc); }
public static void Postpone(Forth f) { if (!f.isCompiling) throw new InvalidOperationException("postpone is only valid when compiling"); string word = f.getWord(' '); ForthDictionaryEntry fde = f.SearchVocabularies(word); if (fde == null) throw new InvalidOperationException("attempt to postpone undefined word " + word); if (fde.IsImmediate) { f.AppendCode(fde.Proc); } else { f.AppendCode(MakeLiteralOp(fde.Proc)); f.AppendCode(new ExecutionToken(PopAndAppendCode)); } }
public static void Define(Forth f) { if (!f.compileStack.IsEmpty) throw new InvalidOperationException("Nested definitions are not permitted"); f.isCompiling = true; string localWordBeingCompiled = f.getWord(' '); f.compileStack.Push ( new CompileState ( new CompositeWord(), delegate(CompositeWord finishedWord) { f.Define(localWordBeingCompiled, new ExecutionToken(finishedWord.Run)); } ) ); }