mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 21:35:49 +00:00
Branches: main
Mark Java RTTI classes as implementing java.io.Serializable to
enable serialization of existentially typed values.
java/runtime/DuExistInfo.java:
java/runtime/DuExistLocn.java:
java/runtime/DuFunctorDesc.java:
java/runtime/DuPtagLayout.java:
java/runtime/EnumFunctorDesc.java:
java/runtime/ForeignEnumFunctorDesc.java:
java/runtime/MethodPtr.java:
java/runtime/NotagFunctorDesc.java:
java/runtime/PseudoTypeInfo.java:
java/runtime/ReservedAddrFunctorDesc.java:
java/runtime/Sectag_Locn.java:
java/runtime/TypeClassConstraint.java:
java/runtime/TypeClassDeclStruct.java:
java/runtime/TypeClassId.java:
java/runtime/TypeClassMethod.java:
java/runtime/TypeCtorInfo_Struct.java:
java/runtime/TypeCtorRep.java:
java/runtime/TypeFunctors.java:
java/runtime/TypeInfo_Struct.java:
java/runtime/TypeLayout.java:
As above.
TypeCtorInfo_Struct.unify() cannot rely on the uniqueness of
TypeCtorInfo_Struct instances, as deserialisation will create new
copies.
49 lines
1.8 KiB
Java
49 lines
1.8 KiB
Java
//
|
|
// Copyright (C) 2001-2004, 2009 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 jmercury.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 implements java.io.Serializable {
|
|
public int variable_number;
|
|
public PseudoTypeInfo(int n) { variable_number = n; }
|
|
protected PseudoTypeInfo() { variable_number = -1; }
|
|
|
|
// Adding or removing members requires corresponding changes in
|
|
// mlds_to_java.m.
|
|
public static final PseudoTypeInfo K1 = new PseudoTypeInfo(1);
|
|
public static final PseudoTypeInfo K2 = new PseudoTypeInfo(2);
|
|
public static final PseudoTypeInfo K3 = new PseudoTypeInfo(3);
|
|
public static final PseudoTypeInfo K4 = new PseudoTypeInfo(4);
|
|
public static final PseudoTypeInfo K5 = new PseudoTypeInfo(5);
|
|
|
|
// 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;
|
|
}
|
|
}
|
|
|
|
// vim: set ts=8 sts=8 sw=8 noet:
|