]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: rename F to false_object, and rename T to true_object
authorSlava Pestov <slava@shill.local>
Mon, 19 Oct 2009 01:26:21 +0000 (20:26 -0500)
committerSlava Pestov <slava@shill.local>
Mon, 19 Oct 2009 01:26:21 +0000 (20:26 -0500)
27 files changed:
vm/alien.cpp
vm/arrays.hpp
vm/booleans.cpp
vm/booleans.hpp
vm/callstack.cpp
vm/code_block.cpp
vm/code_heap.cpp
vm/collector.hpp
vm/contexts.cpp
vm/data_heap.cpp
vm/debug.cpp
vm/dispatch.cpp
vm/errors.cpp
vm/factor.cpp
vm/image.cpp
vm/image.hpp
vm/io.cpp
vm/jit.cpp
vm/layouts.hpp
vm/math.cpp
vm/os-macosx.mm
vm/os-unix.cpp
vm/quotations.cpp
vm/strings.cpp
vm/tuples.cpp
vm/vm.hpp
vm/words.cpp

index 84e40a46132a62c8580b72458d32dd724e1fc917..22872634424b9148b0d7a191d003225a73d05424 100755 (executable)
@@ -12,8 +12,8 @@ char *factor_vm::pinned_alien_offset(cell obj)
        case ALIEN_TYPE:
                {
                        alien *ptr = untag<alien>(obj);
-                       if(ptr->expired != F)
-                               general_error(ERROR_EXPIRED,obj,F,NULL);
+                       if(to_boolean(ptr->expired))
+                               general_error(ERROR_EXPIRED,obj,false_object,NULL);
                        return pinned_alien_offset(ptr->base) + ptr->displacement;
                }
        case F_TYPE:
@@ -40,7 +40,7 @@ cell factor_vm::allot_alien(cell delegate_, cell displacement)
                new_alien->base = delegate.value();
 
        new_alien->displacement = displacement;
-       new_alien->expired = F;
+       new_alien->expired = false_object;
 
        return new_alien.value();
 }
@@ -51,8 +51,8 @@ void factor_vm::primitive_displaced_alien()
        cell alien = dpop();
        cell displacement = to_cell(dpop());
 
-       if(alien == F && displacement == 0)
-               dpush(F);
+       if(!to_boolean(alien) && displacement == 0)
+               dpush(false_object);
        else
        {
                switch(tagged<object>(alien).type())
@@ -130,17 +130,17 @@ void factor_vm::primitive_dlsym()
 
        symbol_char *sym = name->data<symbol_char>();
 
-       if(library.value() == F)
-               box_alien(ffi_dlsym(NULL,sym));
-       else
+       if(to_boolean(library.value()))
        {
                dll *d = untag_check<dll>(library.value());
 
                if(d->dll == NULL)
-                       dpush(F);
+                       dpush(false_object);
                else
                        box_alien(ffi_dlsym(d,sym));
        }
+       else
+               box_alien(ffi_dlsym(NULL,sym));
 }
 
 /* close a native library handle */
@@ -154,10 +154,10 @@ void factor_vm::primitive_dlclose()
 void factor_vm::primitive_dll_validp()
 {
        cell library = dpop();
-       if(library == F)
-               dpush(T);
+       if(to_boolean(library))
+               dpush(tag_boolean(untag_check<dll>(library)->dll != NULL));
        else
-               dpush(untag_check<dll>(library)->dll == NULL ? F : T);
+               dpush(true_object);
 }
 
 /* gets the address of an object representing a C pointer */
@@ -170,8 +170,8 @@ char *factor_vm::alien_offset(cell obj)
        case ALIEN_TYPE:
                {
                        alien *ptr = untag<alien>(obj);
-                       if(ptr->expired != F)
-                               general_error(ERROR_EXPIRED,obj,F,NULL);
+                       if(to_boolean(ptr->expired))
+                               general_error(ERROR_EXPIRED,obj,false_object,NULL);
                        return alien_offset(ptr->base) + ptr->displacement;
                }
        case F_TYPE:
@@ -202,9 +202,9 @@ VM_C_API char *unbox_alien(factor_vm *myvm)
 void factor_vm::box_alien(void *ptr)
 {
        if(ptr == NULL)
-               dpush(F);
+               dpush(false_object);
        else
-               dpush(allot_alien(F,(cell)ptr));
+               dpush(allot_alien(false_object,(cell)ptr));
 }
 
 VM_C_API void box_alien(void *ptr, factor_vm *myvm)
index accf8b3b04dcfc1b7cedadb1a7e5e01663087d57..d4cbcc11c3d3c10f65f8e5cb1d5535d1124411f0 100755 (executable)
@@ -26,7 +26,8 @@ struct growable_array {
        cell count;
        gc_root<array> elements;
 
-       explicit growable_array(factor_vm *myvm, cell capacity = 10) : count(0), elements(myvm->allot_array(capacity,F),myvm) {}
+       explicit growable_array(factor_vm *myvm, cell capacity = 10) :
+               count(0), elements(myvm->allot_array(capacity,false_object),myvm) {}
 
        void add(cell elt);
        void append(array *elts);
index f1f0230c1363e3513e01115361a55365ff46cfe1..538f4b7dce30bca717802d6c9909ed1e9d3c7861 100644 (file)
@@ -5,7 +5,7 @@ namespace factor
 
 void factor_vm::box_boolean(bool value)
 {
-       dpush(value ? T : F);
+       dpush(tag_boolean(value));
 }
 
 VM_C_API void box_boolean(bool value, factor_vm *myvm)
@@ -13,11 +13,6 @@ VM_C_API void box_boolean(bool value, factor_vm *myvm)
        return myvm->box_boolean(value);
 }
 
-bool factor_vm::to_boolean(cell value)
-{
-       return value != F;
-}
-
 VM_C_API bool to_boolean(cell value, factor_vm *myvm)
 {
        return myvm->to_boolean(value);
index 498c3f74be565e4bdfe75678e6b2b909dc6917c5..375c8e3756c5521aa824965282e99b4652715bf8 100644 (file)
@@ -6,7 +6,12 @@ VM_C_API bool to_boolean(cell value, factor_vm *vm);
 
 inline cell factor_vm::tag_boolean(cell untagged)
 {
-       return (untagged ? T : F);
+       return (untagged ? true_object : false_object);
+}
+
+inline bool factor_vm::to_boolean(cell value)
+{
+       return value != false_object;
 }
 
 }
index 0b7663e513542b5c5ce3fe7404f2b0a69e67d435..838274cff8a2c8aa352561a87ac8b1a461dd5895 100755 (executable)
@@ -100,22 +100,22 @@ cell factor_vm::frame_scan(stack_frame *frame)
        case QUOTATION_TYPE:
                {
                        cell quot = frame_executing(frame);
-                       if(quot == F)
-                               return F;
-                       else
+                       if(to_boolean(quot))
                        {
                                char *return_addr = (char *)FRAME_RETURN_ADDRESS(frame,this);
                                char *quot_xt = (char *)(frame_code(frame) + 1);
 
                                return tag_fixnum(quot_code_offset_to_scan(
                                        quot,(cell)(return_addr - quot_xt)));
-                       }
+                       }    
+                       else
+                               return false_object;
                }
        case WORD_TYPE:
-               return F;
+               return false_object;
        default:
                critical_error("Bad frame type",frame_type(frame));
-               return F;
+               return false_object;
        }
 }
 
index 0afd98dd0faca98e50dd4cd003d4f6fffec6c2f4..80862bc426cf580e2bb8306ddbf7852188456f54 100755 (executable)
@@ -66,7 +66,7 @@ void *factor_vm::object_xt(cell obj)
 
 void *factor_vm::xt_pic(word *w, cell tagged_quot)
 {
-       if(tagged_quot == F || max_pic_size == 0)
+       if(!to_boolean(tagged_quot) || max_pic_size == 0)
                return w->xt;
        else
        {
@@ -92,7 +92,7 @@ void *factor_vm::word_xt_pic_tail(word *w)
 image load */
 void factor_vm::undefined_symbol()
 {
-       general_error(ERROR_UNDEFINED_SYMBOL,F,F,NULL);
+       general_error(ERROR_UNDEFINED_SYMBOL,false_object,false_object,NULL);
 }
 
 void undefined_symbol()
@@ -106,7 +106,7 @@ void *factor_vm::get_rel_symbol(array *literals, cell index)
        cell symbol = array_nth(literals,index);
        cell library = array_nth(literals,index + 1);
 
-       dll *d = (library == F ? NULL : untag<dll>(library));
+       dll *d = (to_boolean(library) ? untag<dll>(library) : NULL);
 
        if(d != NULL && !d->dll)
                return (void *)factor::undefined_symbol;
@@ -147,8 +147,8 @@ void *factor_vm::get_rel_symbol(array *literals, cell index)
 
 cell factor_vm::compute_relocation(relocation_entry rel, cell index, code_block *compiled)
 {
-       array *literals = (compiled->literals == F
-               ? NULL : untag<array>(compiled->literals));
+       array *literals = (to_boolean(compiled->literals)
+               ? untag<array>(compiled->literals) : NULL);
        cell offset = relocation_offset_of(rel) + (cell)compiled->xt();
 
 #define ARG array_nth(literals,index)
@@ -196,7 +196,7 @@ cell factor_vm::compute_relocation(relocation_entry rel, cell index, code_block
 
 template<typename Iterator> void factor_vm::iterate_relocations(code_block *compiled, Iterator &iter)
 {
-       if(compiled->relocation != F)
+       if(to_boolean(compiled->relocation))
        {
                byte_array *relocation = untag<byte_array>(compiled->relocation);
 
@@ -308,9 +308,9 @@ void factor_vm::update_literal_references(code_block *compiled)
 void factor_vm::relocate_code_block_step(relocation_entry rel, cell index, code_block *compiled)
 {
 #ifdef FACTOR_DEBUG
-       if(compiled->literals != F)
+       if(to_boolean(compiled->literals))
                tagged<array>(compiled->literals).untag_check(this);
-       if(compiled->relocation != F)
+       if(to_boolean(compiled->relocation))
                tagged<byte_array>(compiled->relocation).untag_check(this);
 #endif
 
@@ -484,12 +484,12 @@ code_block *factor_vm::add_code_block(cell type, cell code_, cell labels_, cell
 
        /* slight space optimization */
        if(relocation.type() == BYTE_ARRAY_TYPE && array_capacity(relocation.untagged()) == 0)
-               compiled->relocation = F;
+               compiled->relocation = false_object;
        else
                compiled->relocation = relocation.value();
 
        if(literals.type() == ARRAY_TYPE && array_capacity(literals.untagged()) == 0)
-               compiled->literals = F;
+               compiled->literals = false_object;
        else
                compiled->literals = literals.value();
 
@@ -497,7 +497,7 @@ code_block *factor_vm::add_code_block(cell type, cell code_, cell labels_, cell
        memcpy(compiled + 1,code.untagged() + 1,code_length);
 
        /* fixup labels */
-       if(labels.value() != F)
+       if(to_boolean(labels.value()))
                fixup_labels(labels.as<array>().untagged(),compiled);
 
        /* next time we do a minor GC, we have to scan the code heap for
index b7307dd7e636dcf47b7fbffbc0e4562277b65699..8caee005fb0d96cf8d8b8e3a82ab619a41de1401 100755 (executable)
@@ -51,8 +51,8 @@ void factor_vm::jit_compile_word(cell word_, cell def_, bool relocate)
 
        word->code = def->code;
 
-       if(word->pic_def != F) jit_compile(word->pic_def,relocate);
-       if(word->pic_tail_def != F) jit_compile(word->pic_tail_def,relocate);
+       if(to_boolean(word->pic_def)) jit_compile(word->pic_def,relocate);
+       if(to_boolean(word->pic_tail_def)) jit_compile(word->pic_tail_def,relocate);
 }
 
 struct word_updater {
@@ -164,7 +164,7 @@ void factor_vm::forward_object_xts()
 
        cell obj;
 
-       while((obj = next_object()) != F)
+       while(to_boolean(obj = next_object()))
        {
                switch(tagged<object>(obj).type())
                {
@@ -251,7 +251,7 @@ struct stack_trace_stripper {
 
        void operator()(code_block *compiled)
        {
-               compiled->owner = F;
+               compiled->owner = false_object;
        }
 };
 
index 8156fd16930d23fa69c3abfc9d1c90fd2e2eb158..69488e04aba8fc4094a0511f5fce5c203a9ce632 100644 (file)
@@ -119,7 +119,7 @@ template<typename TargetGeneration, typename Policy> struct collector {
        the user environment and extra roots registered by local_roots.hpp */
        void trace_roots()
        {
-               trace_handle(&myvm->T);
+               trace_handle(&myvm->true_object);
                trace_handle(&myvm->bignum_zero);
                trace_handle(&myvm->bignum_pos_one);
                trace_handle(&myvm->bignum_neg_one);
index bed044250e50283b690ef99ddd9d660546660643..c914271c8911f5e51c7ebcb42d3f115f58e271b0 100644 (file)
@@ -143,13 +143,13 @@ bool factor_vm::stack_to_array(cell bottom, cell top)
 void factor_vm::primitive_datastack()
 {
        if(!stack_to_array(ds_bot,ds))
-               general_error(ERROR_DS_UNDERFLOW,F,F,NULL);
+               general_error(ERROR_DS_UNDERFLOW,false_object,false_object,NULL);
 }
 
 void factor_vm::primitive_retainstack()
 {
        if(!stack_to_array(rs_bot,rs))
-               general_error(ERROR_RS_UNDERFLOW,F,F,NULL);
+               general_error(ERROR_RS_UNDERFLOW,false_object,false_object,NULL);
 }
 
 /* returns pointer to top of stack */
@@ -180,7 +180,7 @@ void factor_vm::primitive_check_datastack()
        fixnum saved_height = array_capacity(saved_datastack);
        fixnum current_height = (ds - ds_bot + sizeof(cell)) / sizeof(cell);
        if(current_height - height != saved_height)
-               dpush(F);
+               dpush(false_object);
        else
        {
                fixnum i;
@@ -188,11 +188,11 @@ void factor_vm::primitive_check_datastack()
                {
                        if(((cell *)ds_bot)[i] != array_nth(saved_datastack,i))
                        {
-                               dpush(F);
+                               dpush(false_object);
                                return;
                        }
                }
-               dpush(T);
+               dpush(true_object);
        }
 }
 
index 6b099533141b173c8271a20f899b83e7ec22ef0a..335938acab6a47c1de25c63911381ac4fa8490ec 100755 (executable)
@@ -240,10 +240,10 @@ void factor_vm::primitive_begin_scan()
 cell factor_vm::next_object()
 {
        if(!gc_off)
-               general_error(ERROR_HEAP_SCAN,F,F,NULL);
+               general_error(ERROR_HEAP_SCAN,false_object,false_object,NULL);
 
        if(heap_scan_ptr >= data->tenured->here)
-               return F;
+               return false_object;
 
        object *obj = (object *)heap_scan_ptr;
        heap_scan_ptr += untagged_object_size(obj);
@@ -266,7 +266,7 @@ template<typename Iterator> void factor_vm::each_object(Iterator &iterator)
 {
        begin_scan();
        cell obj;
-       while((obj = next_object()) != F)
+       while(to_boolean(obj = next_object()))
                iterator(tagged<object>(obj));
        end_scan();
 }
index da8c6032545ccadb6cf2c2b840aaf9b2bab6fe15..8fad13d663ae44f5628201686817f2732b9e948e 100755 (executable)
@@ -236,7 +236,7 @@ void factor_vm::dump_objects(cell type)
        begin_scan();
 
        cell obj;
-       while((obj = next_object()) != F)
+       while(to_boolean(obj = next_object()))
        {
                if(type == TYPE_COUNT || tagged<object>(obj).type_p(type))
                {
@@ -275,7 +275,7 @@ void factor_vm::find_data_references(cell look_for)
 
        cell obj;
 
-       while((obj = next_object()) != F)
+       while(to_boolean(obj = next_object()))
        {
                data_references_finder finder(look_for,obj,this);
                do_slots(UNTAG(obj),finder);
index 03323f811dd010e477049143b4fe64371d72a67f..23b0b80765b7769c689141621c014661e12aeb6b 100755 (executable)
@@ -15,14 +15,14 @@ cell factor_vm::search_lookup_alist(cell table, cell klass)
                        index -= 2;
        }
 
-       return F;
+       return false_object;
 }
 
 cell factor_vm::search_lookup_hash(cell table, cell klass, cell hashcode)
 {
        array *buckets = untag<array>(table);
        cell bucket = array_nth(buckets,hashcode & (array_capacity(buckets) - 1));
-       if(tagged<object>(bucket).type_p(WORD_TYPE) || bucket == F)
+       if(tagged<object>(bucket).type_p(WORD_TYPE) || !to_boolean(bucket))
                return bucket;
        else
                return search_lookup_alist(bucket,klass);
@@ -56,12 +56,12 @@ cell factor_vm::lookup_tuple_method(cell obj, cell methods)
 
                if(tagged<object>(echelon_methods).type_p(WORD_TYPE))
                        return echelon_methods;
-               else if(echelon_methods != F)
+               else if(to_boolean(echelon_methods))
                {
                        cell klass = nth_superclass(layout,echelon);
                        cell hashcode = untag_fixnum(nth_hashcode(layout,echelon));
                        cell result = search_lookup_hash(echelon_methods,klass,hashcode);
-                       if(result != F)
+                       if(to_boolean(result))
                                return result;
                }
 
@@ -69,7 +69,7 @@ cell factor_vm::lookup_tuple_method(cell obj, cell methods)
        }
 
        critical_error("Cannot find tuple method",methods);
-       return F;
+       return false_object;
 }
 
 cell factor_vm::lookup_hi_tag_method(cell obj, cell methods)
index a3c0242d7eddbf2ff7117dfc98ea34665df546a1..a1fc71ffbc38ea88fbc3326b7d15fea336dad167 100755 (executable)
@@ -29,7 +29,7 @@ void factor_vm::throw_error(cell error, stack_frame *callstack_top)
 {
        /* If the error handler is set, we rewind any C stack frames and
        pass the error to user-space. */
-       if(!current_gc && userenv[BREAK_ENV] != F)
+       if(!current_gc && to_boolean(userenv[BREAK_ENV]))
        {
                /* If error was thrown during heap scan, we re-enable the GC */
                gc_off = false;
@@ -80,7 +80,7 @@ void factor_vm::type_error(cell type, cell tagged)
 
 void factor_vm::not_implemented_error()
 {
-       general_error(ERROR_NOT_IMPLEMENTED,F,F,NULL);
+       general_error(ERROR_NOT_IMPLEMENTED,false_object,false_object,NULL);
 }
 
 /* Test if 'fault' is in the guard page at the top or bottom (depending on
@@ -97,32 +97,32 @@ bool factor_vm::in_page(cell fault, cell area, cell area_size, int offset)
 void factor_vm::memory_protection_error(cell addr, stack_frame *native_stack)
 {
        if(in_page(addr, ds_bot, 0, -1))
-               general_error(ERROR_DS_UNDERFLOW,F,F,native_stack);
+               general_error(ERROR_DS_UNDERFLOW,false_object,false_object,native_stack);
        else if(in_page(addr, ds_bot, ds_size, 0))
-               general_error(ERROR_DS_OVERFLOW,F,F,native_stack);
+               general_error(ERROR_DS_OVERFLOW,false_object,false_object,native_stack);
        else if(in_page(addr, rs_bot, 0, -1))
-               general_error(ERROR_RS_UNDERFLOW,F,F,native_stack);
+               general_error(ERROR_RS_UNDERFLOW,false_object,false_object,native_stack);
        else if(in_page(addr, rs_bot, rs_size, 0))
-               general_error(ERROR_RS_OVERFLOW,F,F,native_stack);
+               general_error(ERROR_RS_OVERFLOW,false_object,false_object,native_stack);
        else if(in_page(addr, nursery.end, 0, 0))
                critical_error("allot_object() missed GC check",0);
        else
-               general_error(ERROR_MEMORY,allot_cell(addr),F,native_stack);
+               general_error(ERROR_MEMORY,allot_cell(addr),false_object,native_stack);
 }
 
 void factor_vm::signal_error(int signal, stack_frame *native_stack)
 {
-       general_error(ERROR_SIGNAL,tag_fixnum(signal),F,native_stack);
+       general_error(ERROR_SIGNAL,tag_fixnum(signal),false_object,native_stack);
 }
 
 void factor_vm::divide_by_zero_error()
 {
-       general_error(ERROR_DIVIDE_BY_ZERO,F,F,NULL);
+       general_error(ERROR_DIVIDE_BY_ZERO,false_object,false_object,NULL);
 }
 
 void factor_vm::fp_trap_error(unsigned int fpu_status, stack_frame *signal_callstack_top)
 {
-       general_error(ERROR_FP_TRAP,tag_fixnum(fpu_status),F,signal_callstack_top);
+       general_error(ERROR_FP_TRAP,tag_fixnum(fpu_status),false_object,signal_callstack_top);
 }
 
 void factor_vm::primitive_call_clear()
index 8b1202ddb0fc26f637e8f2cb655238f5b59e1160..5548ebd610bfa050590895f376a08ca33a49a86d 100755 (executable)
@@ -100,7 +100,7 @@ void factor_vm::do_stage1_init()
        fflush(stdout);
 
        compile_all_words();
-       userenv[STAGE2_ENV] = T;
+       userenv[STAGE2_ENV] = true_object;
 
        print_string("done\n");
        fflush(stdout);
@@ -148,17 +148,17 @@ void factor_vm::init_factor(vm_parameters *p)
 
        init_profiler();
 
-       userenv[CPU_ENV] = allot_alien(F,(cell)FACTOR_CPU_STRING);
-       userenv[OS_ENV] = allot_alien(F,(cell)FACTOR_OS_STRING);
+       userenv[CPU_ENV] = allot_alien(false_object,(cell)FACTOR_CPU_STRING);
+       userenv[OS_ENV] = allot_alien(false_object,(cell)FACTOR_OS_STRING);
        userenv[CELL_SIZE_ENV] = tag_fixnum(sizeof(cell));
-       userenv[EXECUTABLE_ENV] = allot_alien(F,(cell)p->executable_path);
-       userenv[ARGS_ENV] = F;
-       userenv[EMBEDDED_ENV] = F;
+       userenv[EXECUTABLE_ENV] = allot_alien(false_object,(cell)p->executable_path);
+       userenv[ARGS_ENV] = false_object;
+       userenv[EMBEDDED_ENV] = false_object;
 
        /* We can GC now */
        gc_off = false;
 
-       if(userenv[STAGE2_ENV] == F)
+       if(!to_boolean(userenv[STAGE2_ENV]))
                do_stage1_init();
 }
 
@@ -169,7 +169,7 @@ void factor_vm::pass_args_to_factor(int argc, vm_char **argv)
        int i;
 
        for(i = 1; i < argc; i++){
-               args.add(allot_alien(F,(cell)argv[i]));
+               args.add(allot_alien(false_object,(cell)argv[i]));
        }
 
        args.trim();
index 05e0d66724132fd27a88ca2fbe4ae545b3ed197c..cb598a18c307e225436630c5bbcb575cf4989ba0 100755 (executable)
@@ -8,7 +8,7 @@ void factor_vm::init_objects(image_header *h)
 {
        memcpy(userenv,h->userenv,sizeof(userenv));
 
-       T = h->t;
+       true_object = h->true_object;
        bignum_zero = h->bignum_zero;
        bignum_pos_one = h->bignum_pos_one;
        bignum_neg_one = h->bignum_neg_one;
@@ -88,13 +88,13 @@ bool factor_vm::save_image(const vm_char *filename)
        h.code_relocation_base = code->seg->start;
        h.code_size = code->heap_size();
 
-       h.t = T;
+       h.true_object = true_object;
        h.bignum_zero = bignum_zero;
        h.bignum_pos_one = bignum_pos_one;
        h.bignum_neg_one = bignum_neg_one;
 
        for(cell i = 0; i < USER_ENV; i++)
-               h.userenv[i] = (save_env_p(i) ? userenv[i] : F);
+               h.userenv[i] = (save_env_p(i) ? userenv[i] : false_object);
 
        bool ok = true;
 
@@ -132,7 +132,7 @@ void factor_vm::primitive_save_image_and_exit()
        /* strip out userenv data which is set on startup anyway */
        for(cell i = 0; i < USER_ENV; i++)
        {
-               if(!save_env_p(i)) userenv[i] = F;
+               if(!save_env_p(i)) userenv[i] = false_object;
        }
 
        gc(collect_full_op,
@@ -184,7 +184,7 @@ void factor_vm::fixup_quotation(quotation *quot, cell code_relocation_base)
 
 void factor_vm::fixup_alien(alien *d)
 {
-       if(d->base == F) d->expired = T;
+       if(!to_boolean(d->base)) d->expired = true_object;
 }
 
 struct stack_frame_fixupper {
@@ -273,7 +273,7 @@ void factor_vm::relocate_data(cell data_relocation_base, cell code_relocation_ba
        for(cell i = 0; i < USER_ENV; i++)
                data_fixup(&userenv[i],data_relocation_base);
 
-       data_fixup(&T,data_relocation_base);
+       data_fixup(&true_object,data_relocation_base);
        data_fixup(&bignum_zero,data_relocation_base);
        data_fixup(&bignum_pos_one,data_relocation_base);
        data_fixup(&bignum_neg_one,data_relocation_base);
@@ -350,7 +350,7 @@ void factor_vm::load_image(vm_parameters *p)
        relocate_code(h.data_relocation_base);
 
        /* Store image path name */
-       userenv[IMAGE_ENV] = allot_alien(F,(cell)p->image_path);
+       userenv[IMAGE_ENV] = allot_alien(false_object,(cell)p->image_path);
 }
 
 }
index f0711858522a40aa5db404e424d168b86e9c579a..8a7080110ce2357f78b5cce14b8bf6542635dddc 100755 (executable)
@@ -17,7 +17,7 @@ struct image_header {
        /* size of code heap */
        cell code_size;
        /* tagged pointer to t singleton */
-       cell t;
+       cell true_object;
        /* tagged pointer to bignum 0 */
        cell bignum_zero;
        /* tagged pointer to bignum 1 */
index 8e6eff730e2657ca3cde9a4d2123df679085c3a1..d5cfc1745c23a63ae3f97eca4a9e8cf11bdf3480 100755 (executable)
--- a/vm/io.cpp
+++ b/vm/io.cpp
@@ -16,9 +16,9 @@ normal operation. */
 
 void factor_vm::init_c_io()
 {
-       userenv[STDIN_ENV] = allot_alien(F,(cell)stdin);
-       userenv[STDOUT_ENV] = allot_alien(F,(cell)stdout);
-       userenv[STDERR_ENV] = allot_alien(F,(cell)stderr);
+       userenv[STDIN_ENV] = allot_alien(false_object,(cell)stdin);
+       userenv[STDOUT_ENV] = allot_alien(false_object,(cell)stdout);
+       userenv[STDERR_ENV] = allot_alien(false_object,(cell)stderr);
 }
 
 void factor_vm::io_error()
@@ -28,7 +28,7 @@ void factor_vm::io_error()
                return;
 #endif
 
-       general_error(ERROR_IO,tag_fixnum(errno),F,NULL);
+       general_error(ERROR_IO,tag_fixnum(errno),false_object,NULL);
 }
 
 void factor_vm::primitive_fopen()
@@ -63,7 +63,7 @@ void factor_vm::primitive_fgetc()
                {
                        if(feof(file))
                        {
-                               dpush(F);
+                               dpush(false_object);
                                break;
                        }
                        else
@@ -97,7 +97,7 @@ void factor_vm::primitive_fread()
                {
                        if(feof(file))
                        {
-                               dpush(F);
+                               dpush(false_object);
                                break;
                        }
                        else
index 77a311cb24d58d9beb3d05010f27dc7f9e8e017f..1a35cabbaf1d46977e3eec43fa108a837781aa09 100644 (file)
@@ -103,7 +103,7 @@ code_block *jit::to_code_block()
        return parent_vm->add_code_block(
                type,
                code.elements.value(),
-               F, /* no labels */
+               false_object, /* no labels */
                owner.value(),
                relocation.elements.value(),
                literals.elements.value());
index 2fba97d74736164b9fd9be6b7fe48a80c3dd4050..aef8b1b66847635809659297146418ccfeb508e3 100644 (file)
@@ -46,9 +46,6 @@ inline static cell align8(cell a)
 #define OBJECT_TYPE 6
 #define TUPLE_TYPE 7
 
-/* Canonical F object */
-#define F F_TYPE
-
 #define HEADER_TYPE 8 /* anything less than this is a tag */
 
 #define GC_COLLECTED 5 /* can be anything other than FIXNUM_TYPE */
@@ -78,9 +75,12 @@ enum
        FP_TRAP_INEXACT           = 1 << 4,
 };
 
+/* What Factor calls 'f' */
+static const cell false_object = F_TYPE;
+
 inline static bool immediate_p(cell obj)
 {
-       return (obj == F || TAG(obj) == FIXNUM_TYPE);
+       return (obj == false_object || TAG(obj) == FIXNUM_TYPE);
 }
 
 inline static fixnum untag_fixnum(cell tagged)
index e4caa0f5ca417d55ef383ff316dd4a32e5ebb014..679cdae1662afd67a90aa0c7c15ce2d53fb5699a 100755 (executable)
@@ -285,7 +285,7 @@ void factor_vm::primitive_str_to_float()
        if(end == c_str + capacity - 1)
                drepl(allot_float(f));
        else
-               drepl(F);
+               drepl(false_object);
 }
 
 void factor_vm::primitive_float_to_str()
index 3aa001774bcbc7e813a89d4f0011d2af801bb2ec..96f169bbcf002be3f4e4c56f7f2beb79369e2b4a 100644 (file)
@@ -13,7 +13,7 @@ NS_DURING
                c_to_factor(quot,this);
                NS_VOIDRETURN;
 NS_HANDLER
-               dpush(allot_alien(F,(cell)localException));
+               dpush(allot_alien(false_object,(cell)localException));
                quot = userenv[COCOA_EXCEPTION_ENV];
                if(!tagged<object>(quot).type_p(QUOTATION_TYPE))
                {
index 70d7e395dee5d42ecd4d9e1c9fd8d5d355572d81..2f9d5a3c89ff70d15fab31d29e1755f4fa983c4d 100644 (file)
@@ -72,7 +72,7 @@ void *factor_vm::ffi_dlsym(dll *dll, symbol_char *symbol)
 void factor_vm::ffi_dlclose(dll *dll)
 {
        if(dlclose(dll->dll))
-               general_error(ERROR_FFI,F,F,NULL);
+               general_error(ERROR_FFI,false_object,false_object,NULL);
        dll->dll = NULL;
 }
 
index 60fdce1003210bb6776fc3ee0a7e85f0251c6bea..4c15d2d57e1f43bf39066d84318e7f14e6da17a5 100755 (executable)
@@ -88,7 +88,7 @@ bool quotation_jit::stack_frame_p()
                switch(tagged<object>(obj).type())
                {
                case WORD_TYPE:
-                       if(parent_vm->untag<word>(obj)->subprimitive == F)
+                       if(!parent_vm->to_boolean(parent_vm->untag<word>(obj)->subprimitive))
                                return true;
                        break;
                case QUOTATION_TYPE:
@@ -149,7 +149,7 @@ void quotation_jit::iterate_quotation()
                {
                case WORD_TYPE:
                        /* Intrinsics */
-                       if(obj.as<word>()->subprimitive != F)
+                       if(parent_vm->to_boolean(obj.as<word>()->subprimitive))
                                emit_subprimitive(obj.value());
                        /* The (execute) primitive is special-cased */
                        else if(obj.value() == parent_vm->userenv[JIT_EXECUTE_WORD])
@@ -313,8 +313,8 @@ void factor_vm::primitive_array_to_quotation()
 {
        quotation *quot = allot<quotation>(sizeof(quotation));
        quot->array = dpeek();
-       quot->cached_effect = F;
-       quot->cache_counter = F;
+       quot->cached_effect = false_object;
+       quot->cache_counter = false_object;
        quot->xt = (void *)lazy_jit_compile;
        quot->code = NULL;
        drepl(tag<quotation>(quot));
index ecfc84ebef9a905888e50dce3157e3f334333698..d7434fe660e90434cfca145aff35f578b02e8887 100644 (file)
@@ -35,7 +35,9 @@ void factor_vm::set_string_nth_slow(string *str_, cell index, cell ch)
 
        str->data()[index] = ((ch & 0x7f) | 0x80);
 
-       if(str->aux == F)
+       if(to_boolean(str->aux))
+               aux = untag<byte_array>(str->aux);
+       else
        {
                /* We don't need to pre-initialize the
                byte array with any data, since we
@@ -48,8 +50,6 @@ void factor_vm::set_string_nth_slow(string *str_, cell index, cell ch)
                str->aux = tag<byte_array>(aux);
                write_barrier(&str->aux);
        }
-       else
-               aux = untag<byte_array>(str->aux);
 
        aux->data<u16>()[index] = ((ch >> 7) ^ 1);
 }
@@ -69,8 +69,8 @@ string *factor_vm::allot_string_internal(cell capacity)
        string *str = allot<string>(string_size(capacity));
 
        str->length = tag_fixnum(capacity);
-       str->hashcode = F;
-       str->aux = F;
+       str->hashcode = false_object;
+       str->aux = false_object;
 
        return str;
 }
@@ -109,7 +109,7 @@ void factor_vm::primitive_string()
 bool factor_vm::reallot_string_in_place_p(string *str, cell capacity)
 {
        return nursery.contains_p(str)
-               && (str->aux == F || nursery.contains_p(untag<byte_array>(str->aux)))
+               && (!to_boolean(str->aux) || nursery.contains_p(untag<byte_array>(str->aux)))
                && capacity <= string_capacity(str);
 }
 
@@ -121,7 +121,7 @@ string* factor_vm::reallot_string(string *str_, cell capacity)
        {
                str->length = tag_fixnum(capacity);
 
-               if(str->aux != F)
+               if(to_boolean(str->aux))
                {
                        byte_array *aux = untag<byte_array>(str->aux);
                        aux->capacity = tag_fixnum(capacity * 2);
@@ -139,7 +139,7 @@ string* factor_vm::reallot_string(string *str_, cell capacity)
 
                memcpy(new_str->data(),str->data(),to_copy);
 
-               if(str->aux != F)
+               if(to_boolean(str->aux))
                {
                        byte_array *new_aux = allot_byte_array(capacity * sizeof(u16));
 
index 5fdde6596eec4e0240a669c93983da03b258717d..2d195ea13b4fe9b79ff515ca28b749f5a00e8b56 100755 (executable)
@@ -18,7 +18,7 @@ void factor_vm::primitive_tuple()
        tuple *t = allot_tuple(layout.value());
        fixnum i;
        for(i = tuple_size(layout.untagged()) - 1; i >= 0; i--)
-               t->data()[i] = F;
+               t->data()[i] = false_object;
 
        dpush(tag<tuple>(t));
 }
index c3d71dc6f2bc5a9921593c98d0d16de8214a747a..d232d6153d0074c84108662d301c2db6ba1eef70 100755 (executable)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -26,8 +26,8 @@ struct factor_vm
        /* Pooling unused contexts to make callbacks cheaper */
        context *unused_contexts;
 
-       /* Canonical T object. It's just a word */
-       cell T;
+       /* Canonical truth value. In Factor, 't' */
+       cell true_object;
 
        /* Is call counting enabled? */
        bool profiling_p;
index 72460a64b9bfa86e37467c14ca0c3d235fff4cc3..6193a5c93c4f2b420def23c2bd03fb84bdfe15d2 100644 (file)
@@ -14,11 +14,11 @@ word *factor_vm::allot_word(cell name_, cell vocab_, cell hashcode_)
        new_word->vocabulary = vocab.value();
        new_word->name = name.value();
        new_word->def = userenv[UNDEFINED_ENV];
-       new_word->props = F;
+       new_word->props = false_object;
        new_word->counter = tag_fixnum(0);
-       new_word->pic_def = F;
-       new_word->pic_tail_def = F;
-       new_word->subprimitive = F;
+       new_word->pic_def = false_object;
+       new_word->pic_tail_def = false_object;
+       new_word->subprimitive = false_object;
        new_word->profiling = NULL;
        new_word->code = NULL;