Define primop, AST, and HIR instruction for taking the class of a standard object
robert-strandh opened this issue · comments
We would like to implement CLASS-OF as something like:
(defun class-of (object)
(cond ((cleavir-primop:standard-object-p object)
(cleavir-primop:class-of object))
((cleavir-primop:fixnump object)
(load-time-value (find-class 'fixnum)))
((cleavir-primop:consp object)
(load-time-value (find-class 'cons)))
((cleavir-primop:single-float-p object)
(load-time-value (find-class 'single-float)))
((cleavir-primop:characterp object)
(load-time-value (find-class 'character)))))
For that, we need a primop, an AST class, and a HIR instruction for
returning the class of a standard object.
I defined the primop, the AST class, and the instruction class.
I also defined methods on CST-TO-AST, and COMPILE-AST.
I ended up calling the operator STANDARD-OBJECT-CLASS-OF to emphasize
that it can handle only standard objects.