safe_value_t object_tracker_to_safe_value(object_tracker_t *handle) { value_t target = handle->value; safe_value_t s_result; s_result.as_value.encoded = ((address_arith_t) handle) + get_value_domain(target); CHECK_FALSE("cast into condition", safe_value_is_immediate(s_result)); return s_result; }
value_t value_validate(value_t value) { switch (get_value_domain(value)) { case vdHeapObject: return heap_object_validate(value); case vdDerivedObject: return derived_object_validate(value); default: return success(); } }
value_t value_identity_compare_cycle_protect(value_t a, value_t b, cycle_detector_t *detector) { // First check that they even belong to the same domain. Values can be equal // across domains. value_domain_t a_domain = get_value_domain(a); value_domain_t b_domain = get_value_domain(b); if (a_domain != b_domain) return no(); // Then dispatch to the domain equals functions. switch (a_domain) { case vdInteger: case vdCustomTagged: return new_boolean(is_same_value(a, b)); case vdHeapObject: return heap_object_identity_compare(a, b, detector); default: return no(); } }
value_t new_heap_object_with_type(runtime_t *runtime, value_t header) { switch (get_value_domain(header)) { case vdHeapObject: return new_heap_object_with_object_type(runtime, header); case vdCustomTagged: return new_heap_object_with_custom_tagged_type(runtime, header); default: return new_unsupported_behavior_condition(get_value_type_info(header), ubNewObjectWithType); } }
value_t value_ordering_compare(value_t a, value_t b) { value_domain_t a_domain = get_value_domain(a); value_domain_t b_domain = get_value_domain(b); if (a_domain != b_domain) { int a_ordinal = get_value_domain_ordinal(a_domain); int b_ordinal = get_value_domain_ordinal(b_domain); return compare_signed_integers(a_ordinal, b_ordinal); } else { switch (a_domain) { case vdInteger: return integer_ordering_compare(a, b); case vdHeapObject: return object_ordering_compare(a, b); case vdCustomTagged: return custom_tagged_ordering_compare(a, b); default: return unordered(); } } }
value_t get_primary_type(value_t self, runtime_t *runtime) { switch (get_value_domain(self)) { case vdInteger: return ROOT(runtime, integer_type); case vdHeapObject: return get_heap_object_primary_type(self, runtime); case vdCustomTagged: return get_custom_tagged_primary_type(self, runtime); default: return new_unsupported_behavior_condition(get_value_type_info(self), ubGetPrimaryType); } }
value_t set_heap_object_contents(runtime_t *runtime, value_t object, value_t header, value_t payload) { switch (get_value_domain(header)) { case vdHeapObject: return set_heap_object_contents_with_object_type(runtime, object, header, payload); break; case vdCustomTagged: return set_heap_object_contents_with_custom_tagged_type(runtime, object, header, payload); break; default: return new_unsupported_behavior_condition(get_value_type_info(header), ubNewObjectWithType); } }
value_t value_transient_identity_hash_cycle_protect(value_t value, hash_stream_t *stream, cycle_detector_t *detector) { switch (get_value_domain(value)) { case vdInteger: return integer_transient_identity_hash(value, stream); case vdHeapObject: return heap_object_transient_identity_hash(value, stream, detector); case vdCustomTagged: return custom_tagged_transient_identity_hash(value, stream); default: return new_unsupported_behavior_condition(get_value_type_info(value), ubTransientIdentityHash); } }
void value_print_on_cycle_detect(value_t value, print_on_context_t *context) { switch (get_value_domain(value)) { case vdInteger: integer_print_on(value, context); break; case vdHeapObject: heap_object_print_on(value, context); break; case vdDerivedObject: derived_object_print_on(value, context); break; case vdCondition: condition_print_on(value, context->buf); break; case vdCustomTagged: custom_tagged_print_on(value, context); break; default: UNREACHABLE("value print on"); break; } }