VM: makes some factor_vm methods to free functions

locals-and-roots
Björn Lindqvist 2016-05-29 03:03:07 +02:00
parent 941c9fabd4
commit b027285b48
2 changed files with 5 additions and 13 deletions

View File

@ -2,20 +2,16 @@
namespace factor { namespace factor {
cell factor_vm::search_lookup_alist(cell table, cell klass) { static cell search_lookup_alist(cell table, cell klass) {
array* elements = untag<array>(table); array* elements = untag<array>(table);
fixnum index = array_capacity(elements) - 2; for (fixnum index = array_capacity(elements) - 2; index >= 0; index -= 2) {
while (index >= 0) {
if (array_nth(elements, index) == klass) if (array_nth(elements, index) == klass)
return array_nth(elements, index + 1); return array_nth(elements, index + 1);
else
index -= 2;
} }
return false_object; return false_object;
} }
cell factor_vm::search_lookup_hash(cell table, cell klass, cell hashcode) { static cell search_lookup_hash(cell table, cell klass, cell hashcode) {
array* buckets = untag<array>(table); array* buckets = untag<array>(table);
cell bucket = array_nth(buckets, hashcode & (array_capacity(buckets) - 1)); cell bucket = array_nth(buckets, hashcode & (array_capacity(buckets) - 1));
if (TAG(bucket) == ARRAY_TYPE) if (TAG(bucket) == ARRAY_TYPE)
@ -23,12 +19,12 @@ cell factor_vm::search_lookup_hash(cell table, cell klass, cell hashcode) {
return bucket; return bucket;
} }
cell factor_vm::nth_superclass(tuple_layout* layout, fixnum echelon) { static cell nth_superclass(tuple_layout* layout, fixnum echelon) {
cell* ptr = (cell*)(layout + 1); cell* ptr = (cell*)(layout + 1);
return ptr[echelon * 2]; return ptr[echelon * 2];
} }
cell factor_vm::nth_hashcode(tuple_layout* layout, fixnum echelon) { static cell nth_hashcode(tuple_layout* layout, fixnum echelon) {
cell* ptr = (cell*)(layout + 1); cell* ptr = (cell*)(layout + 1);
return ptr[echelon * 2 + 1]; return ptr[echelon * 2 + 1];
} }

View File

@ -660,10 +660,6 @@ struct factor_vm {
void primitive_quotation_compiled_p(); void primitive_quotation_compiled_p();
// dispatch // dispatch
cell search_lookup_alist(cell table, cell klass);
cell search_lookup_hash(cell table, cell klass, cell hashcode);
cell nth_superclass(tuple_layout* layout, fixnum echelon);
cell nth_hashcode(tuple_layout* layout, fixnum echelon);
cell lookup_tuple_method(cell obj, cell methods); cell lookup_tuple_method(cell obj, cell methods);
cell lookup_method(cell obj, cell methods); cell lookup_method(cell obj, cell methods);
void primitive_lookup_method(); void primitive_lookup_method();