switch `miracle` back to `getattr`, nab `builtins` using `__import__` in `eval`

master
cynic 3 years ago
parent a1119479aa
commit 240e0f865f
  1. 2
      lib.py
  2. 4
      lib/kokoro.klambda
  3. 2
      lib/lists.klambda
  4. 4
      lib/string.klambda

@ -65,7 +65,7 @@ def execute(program):
return subs
elif ctx[0] == _ident("miracle"):
return _box(eval(_destr(subs[1]))[_destr(subs[2])](*[(i if type(i) == type([]) else i[1]) for i in _fixarr(subs[3])]))
return _box(getattr(eval(_destr(subs[1])), _destr(subs[2]))(*[(i if type(i) == type([]) else i[1]) for i in _fixarr(subs[3])]))
elif ctx[0] == _ident("def"):
ids[ctx[1]] = subs[2]
return ids[ctx[1]]

@ -1,10 +1,10 @@
(def spit (lambda (cunny)
(miracle
"__builtins__" "print" (id cunny))))
"__import__('builtins')" "print" (id cunny))))
(def input (lambda ()
(miracle
"__builtins__" "input" (""))))
"__import__('builtins')" "input" (""))))
(def thesis (lambda ()
(spit
("this language belongs to makise kurisu. there are many like it, but this one is hers."))))

@ -1,6 +1,6 @@
(def length (lambda (cunny)
(miracle
"__builtins__" "len" (cunny))))
"__import__('builtins')" "len" (cunny))))
(def append (lambda (item, victim)
(insert (length victim) item victim)))

@ -1,3 +1,3 @@
(def str2lst (lambda (l)
(def str2lst (lambda (s)
(miracle
"__builtins__" "list" (l))))
"__import__('builtins')" "list" (s))))

Loading…
Cancel
Save