combinators.short-circuit math.order math.private accessors
slots.private generic.single.private compiler.units
compiler.constants compiler.codegen.relocation fry locals
-bootstrap.image.syntax parser.notes ;
+bootstrap.image.syntax parser.notes namespaces.private ;
IN: bootstrap.image
: arch ( os cpu -- arch )
{
dictionary source-files builtins
update-map implementors-map
- } [ [ bootstrap-word ] [ get 1array ] bi ] H{ } map>assoc
+ } [ [ bootstrap-word ] [ get global-box boa ] bi ] H{ } map>assoc
{
class<=-cache class-not-cache classes-intersect-cache
class-and-cache class-or-cache next-method-quot-cache
- } [ H{ } clone 1array ] H{ } map>assoc assoc-union
+ } [ H{ } clone global-box boa ] H{ } map>assoc assoc-union
+ global-hashtable boa
bootstrap-global set ;
: emit-jit-data ( -- )
! See http://factorcode.org/license.txt for BSD license.
USING: kernel vectors sequences sequences.private hashtables
arrays kernel.private math strings assocs ;
+SLOT: boxes
+SLOT: value
+FROM: accessors => boxes>> value>> value<< ;
IN: namespaces
<PRIVATE
-: namestack* ( -- namestack )
- CONTEXT-OBJ-NAMESTACK context-object { vector } declare ; inline
-: >n ( namespace -- ) namestack* push ;
-: ndrop ( -- ) namestack* pop* ;
-
-SINGLETON: +globals+
-
-: get-global-hashtable ( -- table )
- OBJ-GLOBAL special-object { hashtable } declare ; inline
+TUPLE: global-hashtable
+ { boxes hashtable read-only } ;
+TUPLE: global-box value ;
-: box-at ( key -- box )
- get-global-hashtable
- 2dup at [ 2nip ] [ [ f 1array ] 2dip [ set-at ] 2curry keep ] if* ; foldable
+: (box-at) ( key globals -- box )
+ boxes>> 2dup at
+ [ 2nip ] [ [ f global-box boa ] 2dip [ set-at ] 2curry keep ] if* ; foldable
-: box> ( box -- value )
- 0 swap nth-unsafe ; inline
+: box-at ( key globals -- box )
+ (box-at) { global-box } declare ; inline
-: >box ( value box -- )
- 0 swap set-nth-unsafe ; inline
+M: global-hashtable at*
+ box-at value>> dup ; inline
-M: +globals+ at*
- drop box-at box> dup ; inline
+M: global-hashtable set-at
+ box-at value<< ; inline
-M: +globals+ set-at
- drop box-at >box ; inline
+M: global-hashtable delete-at
+ box-at f swap value<< ; inline
-M: +globals+ delete-at
- drop box-at f swap >box ; inline
+: namestack* ( -- namestack )
+ CONTEXT-OBJ-NAMESTACK context-object { vector } declare ; inline
+: >n ( namespace -- ) namestack* push ;
+: ndrop ( -- ) namestack* pop* ;
PRIVATE>
+: global ( -- g ) OBJ-GLOBAL special-object { global-hashtable } declare ; foldable
+
: namespace ( -- namespace ) namestack* last ; inline
: namestack ( -- namestack ) namestack* clone ;
: set-namestack ( namestack -- )
>vector CONTEXT-OBJ-NAMESTACK set-context-object ;
-: global ( -- g ) +globals+ ; inline
: init-namespaces ( -- ) global 1array set-namestack ;
: get ( variable -- value ) namestack* assoc-stack ; inline
: set ( value variable -- ) namespace set-at ;