]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/tagged.hpp
VM: undoing 0274e889b94323fdde6919a77c494ffcfbcb2166 (#1513)
[factor.git] / vm / tagged.hpp
index c9a77da67640a17199ff42b6deb739dc80445a0b..28fb12b4e249a2ec3cdc4035b0f8068da3e6ad64 100644 (file)
@@ -29,6 +29,12 @@ template <typename Type> struct tagged {
     return (Type*)(UNTAG(value_));
   }
 
+  Type* untag_check(factor_vm* parent) const {
+    if (!type_p())
+      parent->type_error(Type::type_number, value_);
+    return untagged();
+  }
+
   explicit tagged(cell tagged) : value_(tagged) {}
   explicit tagged(Type* untagged) : value_(factor::tag(untagged)) {}
 
@@ -52,6 +58,10 @@ template <typename Type> struct tagged {
   }
 };
 
+template <typename Type> Type* factor_vm::untag_check(cell value) {
+  return tagged<Type>(value).untag_check(this);
+}
+
 template <typename Type> Type* untag(cell value) {
   return tagged<Type>(value).untagged();
 }