Implement RTTI for the Java-backend (incomplete)

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'.
This commit is contained in:
James Goddard
2004-02-26 08:17:54 +00:00
parent 7af03bf50d
commit 1aa44ba2da
5 changed files with 448 additions and 18 deletions

View File

@@ -25,4 +25,14 @@ 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;
}
}

View File

@@ -48,4 +48,14 @@ public class TypeCtorInfo_Struct extends PseudoTypeInfo {
value_ordered_functor_descs;
type_ctor_flags = flags;
}
// XXX this should be renamed `equals'
public boolean unify(TypeCtorInfo_Struct tci) {
return this == tci;
/*
return type_ctor_module_name.equals(tci.type_ctor_module_name)
&& type_ctor_name.equals(tci.type_ctor_name)
&& arity == tci.arity;
*/
}
}

View File

@@ -125,4 +125,32 @@ public class TypeInfo_Struct extends PseudoTypeInfo {
}
}
}
// XXX this should be renamed `equals'
public boolean unify(TypeInfo_Struct ti) {
if (this == ti) {
return true;
}
if (type_ctor.unify(ti.type_ctor) == false) {
return false;
}
if (args == null || ti.args == null) {
if (args == null && ti.args == null) {
return true;
}
return false;
}
for (int i = 0; i < args.length || i < ti.args.length; i++) {
if (i == args.length || i == ti.args.length) {
return false;
}
if (args[i].unify(ti.args[i]) == false) {
return false;
}
}
return true;
}
}