static value_t heap_object_identity_compare(value_t a, value_t b, cycle_detector_t *detector) { CHECK_DOMAIN(vdHeapObject, a); CHECK_DOMAIN(vdHeapObject, b); // Fast case when a and b are the same object. if (is_same_value(a, b)) return yes(); heap_object_family_t a_family = get_heap_object_family(a); heap_object_family_t b_family = get_heap_object_family(b); if (a_family != b_family) return no(); family_behavior_t *behavior = get_heap_object_family_behavior(a); return (behavior->identity_compare)(a, b, detector); }
static value_t object_ordering_compare(value_t a, value_t b) { CHECK_DOMAIN(vdHeapObject, a); CHECK_DOMAIN(vdHeapObject, b); heap_object_family_t a_family = get_heap_object_family(a); heap_object_family_t b_family = get_heap_object_family(b); if (a_family != b_family) // This may cause us to return a valid result even when a and b are not // comparable. return compare_signed_integers(a_family, b_family); family_behavior_t *behavior = get_heap_object_family_behavior(a); value_t (*ordering_compare)(value_t a, value_t b) = behavior->ordering_compare; if (ordering_compare == NULL) { return unordered(); } else { return ordering_compare(a, b); } }
static value_t new_heap_object_with_object_type(runtime_t *runtime, value_t type) { heap_object_family_t family = get_heap_object_family(type); switch (family) { case ofType: return new_instance_of_type(runtime, type); case ofUtf8: return new_instance_of_string(runtime, type); default: { return new_instance_of_seed(runtime, type); } } }
static value_t set_heap_object_contents_with_object_type(runtime_t *runtime, value_t object, value_t header, value_t payload) { heap_object_family_t family = get_heap_object_family(header); switch (family) { case ofUtf8: return set_heap_object_contents_with_utf8_type(runtime, object, header, payload); default: { set_seed_payload(object, payload); return success(); } } }
// Performs the appropriate action for a fragment element to the given fragment. static value_t apply_unbound_fragment_element(value_t ambience, value_t element, value_t fragment) { CHECK_FAMILY(ofAmbience, ambience); heap_object_family_t family = get_heap_object_family(element); switch (family) { case ofNamespaceDeclarationAst: return apply_namespace_declaration(ambience, element, fragment); case ofMethodDeclarationAst: return apply_method_declaration(ambience, element, fragment); case ofIsDeclarationAst: return apply_is_declaration(get_ambience_runtime(ambience), element, fragment); default: ERROR("Invalid toplevel element %s", get_heap_object_family_name(family)); return success(); } }