1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-23 12:00:21 +02:00

class-of has an opcode

* libguile/vm-i-scheme.c (class-of): New opcode.
* module/language/tree-il/compile-glil.scm:
* module/oop/goops.scm: Compile class-of into an opcode.
This commit is contained in:
Andy Wingo 2009-11-06 12:40:20 +01:00
parent b4a595a5d6
commit aec4a84ac8
3 changed files with 13 additions and 5 deletions

View file

@ -285,6 +285,12 @@ VM_DEFINE_FUNCTION (126, mod, "mod", 2)
/*
* GOOPS support
*/
VM_DEFINE_FUNCTION (169, class_of, "class-of", 1)
{
ARGS1 (obj);
RETURN (SCM_INSTANCEP (obj) ? SCM_CLASS_OF (obj) : scm_class_of (obj));
}
VM_DEFINE_FUNCTION (127, slot_ref, "slot-ref", 2)
{
size_t slot;

View file

@ -103,6 +103,7 @@
((list? . 1) . list?)
(list . list)
(vector . vector)
((class-of . 1) . class-of)
((@slot-ref . 2) . slot-ref)
((@slot-set! . 3) . slot-set)
((vector-ref . 2) . vector-ref)

View file

@ -82,6 +82,12 @@
(eval-when (eval load compile)
(%init-goops-builtins))
(eval-when (eval load compile)
(use-modules ((language tree-il primitives) :select (add-interesting-primitive!)))
(add-interesting-primitive! 'class-of)
(add-interesting-primitive! '@slot-ref)
(add-interesting-primitive! '@slot-set!))
;; Then load the rest of GOOPS
(use-modules (oop goops util)
(oop goops dispatch)
@ -1125,11 +1131,6 @@
;; the idea is to compile the index into the procedure, for fastest
;; lookup. Also, @slot-ref and @slot-set! have their own bytecodes.
(eval-when (compile)
(use-modules ((language tree-il primitives) :select (add-interesting-primitive!)))
(add-interesting-primitive! '@slot-ref)
(add-interesting-primitive! '@slot-set!))
(eval-when (eval load compile)
(define num-standard-pre-cache 20))