]> gitweb.factorcode.org Git - factor.git/commitdiff
VM: makes some factor_vm methods to free functions
authorBjörn Lindqvist <bjourne@gmail.com>
Sun, 29 May 2016 01:03:07 +0000 (03:03 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Sun, 29 May 2016 01:03:07 +0000 (03:03 +0200)
vm/dispatch.cpp
vm/vm.hpp

index 615edde4eb377e5fd5784c483296d5e0bbc10eb0..f1a4dd8acdf09f3241574fd97aada77c64684ef0 100644 (file)
@@ -2,20 +2,16 @@
 
 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);
-  fixnum index = array_capacity(elements) - 2;
-  while (index >= 0) {
+  for (fixnum index = array_capacity(elements) - 2; index >= 0; index -= 2) {
     if (array_nth(elements, index) == klass)
       return array_nth(elements, index + 1);
-    else
-      index -= 2;
   }
-
   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);
   cell bucket = array_nth(buckets, hashcode & (array_capacity(buckets) - 1));
   if (TAG(bucket) == ARRAY_TYPE)
@@ -23,12 +19,12 @@ cell factor_vm::search_lookup_hash(cell table, cell klass, cell hashcode) {
   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);
   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);
   return ptr[echelon * 2 + 1];
 }
index f737fcd763316f8215a4424cdb1dbc5b4c7f973d..1f186ff6b3da94ddfb51cf6afdb17d35efa97741 100644 (file)
--- a/vm/vm.hpp
+++ b/vm/vm.hpp
@@ -660,10 +660,6 @@ struct factor_vm {
   void primitive_quotation_compiled_p();
 
   // 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_method(cell obj, cell methods);
   void primitive_lookup_method();