mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 13:23:53 +00:00
Estimated hours taken: 30 Branches: main Implement RTTI for the Java-backend (incomplete) java/runtime/PseudoTypeInfo.java: java/runtime/TypeCtorInfo_Struct.java: java/runtime/TypeInfo_Struct.java: Implement the `unify' operation for these classes. This implementation actually just compares them. library/rtti_implementation.m: Document a bug in notag_functor_arg_type/1 Define the foreign type of `type_layout' as `TypeLayout' in Java. Correct an off-by-one error in type_ctor_and_args/3. Implement deconstruct/8 for TypeCtorRep = enum. Implement the following predicates in Java: get_var_arity_typeinfo_arity/1 get_pti_from_arg_types/2 typeinfo_is_variable/2 get_type_ctor_info/1 get_primary_tag/1 get_remote_secondary_tag/1 ptag_index/2 sectag_locn/1 du_sectag_alternatives/2 type_info_index/2 type_ctor_arity/1 type_ctor_rep/1 type_ctor_module_name/1 type_ctor_name/1 type_ctor_functors/1 type_layout/1 unsafe_cast/1 du_functor_desc/3 du_functor_name/1 du_functor_arity/1 du_functor_arg_type_contains_var/1 du_functor_sectag_locn/1 du_functor_primary/1 du_functor_secondary/1 du_functor_ordinal/1 du_functor_arg_types/1 du_functor_arg_names/1 du_functor_exist_info/1 enum_functor_desc/3 enum_functor_name/1 enum_functor_ordinal/1 notag_functor_desc/3 notag_functor_name/1 notag_functor_arg_type/1 notag_functor_arg_name/1 null/1 null_string/0 unsafe_get_enum_value/1 library/type_desc.m: Implement the following procedures for Java: type_of/1 has_type/1 type_ctor_and_args/3 type_ctor_name_and_arity/4 Implement the Java classes `type_desc_0' and `type_ctor_desc_0'.
39 lines
1.3 KiB
Java
39 lines
1.3 KiB
Java
//
|
|
// Copyright (C) 2001-2004 The University of Melbourne.
|
|
// This file may only be copied under the terms of the GNU Library General
|
|
// Public License - see the file COPYING.LIB in the Mercury distribution.
|
|
//
|
|
|
|
package mercury.runtime;
|
|
|
|
// A PseudoTypeInfo represents a possibly non-ground type.
|
|
// There are three possible cases:
|
|
//
|
|
// - Unbound type variables are represented by directly constructing
|
|
// a PseudoTypeInfo with the variable number.
|
|
//
|
|
// - Ground types with arity zero may be represented as TypeCtorInfo_Struct,
|
|
// which extends PseudoTypeInfo, and uses the protected constructor
|
|
// which sets variable_number to -1. This is a slightly optimized
|
|
// version of the case below.
|
|
//
|
|
// - Any other types are represented as TypeInfo_Struct,
|
|
// which extends PseudoTypeInfo, and uses the protected constructor
|
|
// which sets variable_number to -1.
|
|
//
|
|
public class PseudoTypeInfo {
|
|
public int variable_number;
|
|
public PseudoTypeInfo(int n) { variable_number = n; }
|
|
protected PseudoTypeInfo() { variable_number = -1; }
|
|
|
|
// XXX This should be renamed `equals'
|
|
public boolean unify(PseudoTypeInfo ti) {
|
|
if (this.getClass() == TypeInfo_Struct.class &&
|
|
ti.getClass() == TypeInfo_Struct.class) {
|
|
return ((TypeInfo_Struct) this).unify(
|
|
(TypeInfo_Struct) ti);
|
|
}
|
|
return variable_number == ti.variable_number;
|
|
}
|
|
}
|