mirror of
https://github.com/russolsen/sallyforth
synced 2025-01-13 08:01:56 +01:00
Cleanup.
This commit is contained in:
parent
6273bdfde7
commit
66a4e271d8
2 changed files with 18 additions and 2 deletions
|
@ -15,7 +15,9 @@
|
||||||
|
|
||||||
\ Basic aliases
|
\ Basic aliases
|
||||||
|
|
||||||
: ->inline { *last-word* inline }
|
: ->inline { *last-word* inline }
|
||||||
|
: ->static { false *last-word* dynamic }
|
||||||
|
: ->dynamic { true *last-word* dynamic }
|
||||||
|
|
||||||
: -- { 1 - } ->inline
|
: -- { 1 - } ->inline
|
||||||
: ++ { 1 + } ->inline
|
: ++ { 1 + } ->inline
|
||||||
|
|
|
@ -10,6 +10,7 @@ def dynamic(forth):
|
||||||
name = forth.stack.pop()
|
name = forth.stack.pop()
|
||||||
isdyn = forth.stack.pop()
|
isdyn = forth.stack.pop()
|
||||||
var = forth.ns[name]
|
var = forth.ns[name]
|
||||||
|
print(f'name: {name} var: {var} dyn: {isdyn}')
|
||||||
var.dynamic = isdyn
|
var.dynamic = isdyn
|
||||||
|
|
||||||
@word()
|
@word()
|
||||||
|
@ -25,6 +26,18 @@ def native(forth):
|
||||||
wrapped_f = native_word(native_f, name, n, has_return)
|
wrapped_f = native_word(native_f, name, n, has_return)
|
||||||
forth.set(name, wrapped_f)
|
forth.set(name, wrapped_f)
|
||||||
|
|
||||||
|
@word("function")
|
||||||
|
def function_word(forth):
|
||||||
|
name = forth.stack.pop()
|
||||||
|
var = forth.ns[name]
|
||||||
|
word_f = var.value
|
||||||
|
def native_f(*args):
|
||||||
|
forth.stack.push(args)
|
||||||
|
word_f(forth)
|
||||||
|
result = forth.stack.pop()
|
||||||
|
return result
|
||||||
|
forth.stack.push(native_f)
|
||||||
|
|
||||||
@word('raise')
|
@word('raise')
|
||||||
def w_raise(forth):
|
def w_raise(forth):
|
||||||
ex = forth.stack.pop()
|
ex = forth.stack.pop()
|
||||||
|
@ -134,7 +147,7 @@ def stack(forth):
|
||||||
@word()
|
@word()
|
||||||
def ns(forth):
|
def ns(forth):
|
||||||
print(forth.ns.name)
|
print(forth.ns.name)
|
||||||
print(forth.ns.contents)
|
pprint(forth.ns.contents)
|
||||||
|
|
||||||
@word(':', True)
|
@word(':', True)
|
||||||
def colon(forth):
|
def colon(forth):
|
||||||
|
@ -147,6 +160,7 @@ def colon(forth):
|
||||||
@word()
|
@word()
|
||||||
def inline(forth):
|
def inline(forth):
|
||||||
name = forth.stack.pop()
|
name = forth.stack.pop()
|
||||||
|
print('name', name)
|
||||||
var = forth.ns[name]
|
var = forth.ns[name]
|
||||||
value = var.value
|
value = var.value
|
||||||
if not value.forth_primitive:
|
if not value.forth_primitive:
|
||||||
|
|
Loading…
Reference in a new issue