From ca797f9e49cfb201b060a419e510b4ac1102ac99 Mon Sep 17 00:00:00 2001 From: Starfflame Date: Tue, 11 May 2021 01:01:38 -0500 Subject: [PATCH] Added basic WordInfo implementation --- ForthDictionary.tl | 10 ++++++---- ForthWordInfo.tl | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 ForthWordInfo.tl diff --git a/ForthDictionary.tl b/ForthDictionary.tl index 2352ebb..8f48fa3 100644 --- a/ForthDictionary.tl +++ b/ForthDictionary.tl @@ -1,13 +1,15 @@ local state = require("ForthState") +local wordinfo = require("ForthWordInfo") local ForthDictionary = {} + + global type Dictionary = record - contents: {string: function(State)} + contents: {string: WordInfo} end - -function Dictionary:define(word: string, instructions: function(State)) - self.contents[word] = instructions +function Dictionary:define(word: string, info: WordInfo) + self.contents[word] = info end local dict_mt = {__index = Dictionary} function Dictionary:new(): Dictionary diff --git a/ForthWordInfo.tl b/ForthWordInfo.tl new file mode 100644 index 0000000..e28d39f --- /dev/null +++ b/ForthWordInfo.tl @@ -0,0 +1,20 @@ +local state = require("ForthState") + +local ForthWordInfo = {} + + +global type WordInfo = record + func: function(State) + immediate: boolean +end +local wordi_mt = {__index = WordInfo} +function WordInfo:new(funct: State, imm: boolean): WordInfo + return setmetatable({func = funct, immediate = imm} as WordInfo, wordi_mt) +end + + +local s = State:new() +print(s) +return ForthWordInfo + +