diff --git a/forge/sf.lisp b/forge/sf.lisp index 986b65d..8fd11cb 100644 --- a/forge/sf.lisp +++ b/forge/sf.lisp @@ -6,7 +6,7 @@ (:use :common-lisp) (:local-nicknames (:iter :scopes/util/iter) (:util :scopes/util)) - (:export #:forge-env #:vocabulary #:stack + (:export #:forge-env #:vocabulary #:stack #:current-package #:*forge-env* #:*input* #:*code* #:word #:comp-word #:exec-list #:exec-input #:comp-input #:call @@ -21,7 +21,8 @@ (defclass forge-env () ((vocabulary :reader vocabulary :initform (make-hash-table)) (func-index :reader func-index :initform (make-hash-table)) - (stack :accessor stack :initform nil))) + (stack :accessor stack :initform nil) + (current-package :accessor current-package :initform :sf-builtin))) (defvar *forge-env* (make-instance 'forge-env)) @@ -54,10 +55,11 @@ (comp-item v))))) (defun find-word (sym) - (multiple-value-bind (val found) (gethash sym (vocabulary *forge-env*)) - (when (not found) - (util:lgw "not found" sym)) - val)) + (let ((sym (find-symbol (symbol-name sym) (current-package *forge-env*)))) + (multiple-value-bind (val found) (gethash sym (vocabulary *forge-env*)) + (when (not found) + (util:lgw "not found" sym)) + val))) ;;;; class word @@ -99,8 +101,9 @@ (funcall fn)))) (defun reg (sym fn &optional (cls 'word)) - (setf (gethash sym (vocabulary *forge-env*)) (make-instance cls :func fn)) - (setf (gethash fn (func-index *forge-env*)) sym)) + (let ((sym (intern (symbol-name sym) (current-package *forge-env*)))) + (setf (gethash sym (vocabulary *forge-env*)) (make-instance cls :func fn)) + (setf (gethash fn (func-index *forge-env*)) sym))) (defun reg1 (sym fn) (reg sym #'(lambda () (pushd (funcall fn (popd))))))