add word for VALUE
This commit is contained in:
parent
fa9daaebb0
commit
b31e6cffab
20
CoreWords.tl
20
CoreWords.tl
|
@ -357,6 +357,24 @@ local function forthTo(e: Environment)
|
|||
e.toMode = true
|
||||
end
|
||||
|
||||
local function forthValue(e: Environment)
|
||||
local val = e.activeDataStack:pop() as any
|
||||
helpers.skipSpaces(e)
|
||||
local valName = helpers.parseToken(e)
|
||||
local index = #e.values + 1
|
||||
local getValue = function(e: Environment)
|
||||
e.activeDataStack:push(e.values[index])
|
||||
end
|
||||
local setValue = function(e: Environment)
|
||||
local newValue = e.activeDataStack:pop()
|
||||
e.values[index] = newValue
|
||||
end
|
||||
defineWord(e.dictionaries[1], valName, getValue, false, setValue)
|
||||
e.values[index] = val
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function forth_local_(e: Environment)
|
||||
local localName = e.activeDataStack:pop() as string
|
||||
if localName == "" then
|
||||
|
@ -443,6 +461,8 @@ defineWord(CoreWords, "PARSE-NAME", parseName, true)
|
|||
defineWord(CoreWords, "EMPTYS", emptys, true)
|
||||
defineWord(CoreWords, "\"\"", emptys, false)
|
||||
|
||||
defineWord(CoreWords, "VALUE", forthValue, false)
|
||||
|
||||
defineWord(CoreWords,"<", cmplt, false)
|
||||
defineWord(CoreWords,"<=", cmplte, false)
|
||||
defineWord(CoreWords,"=", cmpe, false)
|
||||
|
|
|
@ -53,6 +53,7 @@ local type DataStructures = record
|
|||
toMode: boolean
|
||||
locals: Dictionary
|
||||
localBuffer: {function(integer, Environment)}
|
||||
values: {any}
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -123,7 +124,8 @@ function Environment:new(input: InputStream, dict: {Dictionary} ): Environment
|
|||
compileState = false,
|
||||
currentDefinition = {},
|
||||
locals = Dictionary:new(),
|
||||
localBuffer = {}
|
||||
localBuffer = {},
|
||||
values = {}
|
||||
} as Environment,
|
||||
state_mt)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue