mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 09:23:44 +00:00
Add constant structure support to Java backend
This change enables constant structure support for the Java backend for the
structures introduced by the polymorphism pass.
compiler/const_struct.m:
compiler/ml_unify_gen.m:
Enable constant structure support
java/runtime/TypeInfo_Struct.java:
Add a constructor to the TypeInfo structure for Java. This constructor
has the interface expected by the polymorphism code.
Never expect to be passed the arity to the varargs constructor.
compiler/polymorphism.m:
compiler/ml_unify_gen.m:
Change how we avoid creating TypeInfos with an explicit arity argument
for Java
We never specify the arity for a TypeInfo_Struct in a Java grade. There
are two reasons: this is a little difficult to handle due to overloading
rules and it is not necessary.
This is handled by removing these arguments in the MLDS backend.
However, the current solution does not work when we create TypeInfos as
constant structures. Therefore this change removes the special case
from the MLDS backend and instead never creates the arity arguments
during the polymorphism pass. rtti_to_mlds.m didn't need updating as it
already had the correct behaviour.
compiler/rtti_to_mlds.m:
Update a comment.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (C) 2001-2004, 2011 The University of Melbourne.
|
||||
// Copyright (C) 2001-2004, 2011, 2014 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.
|
||||
//
|
||||
@@ -83,23 +83,34 @@ public class TypeInfo_Struct extends PseudoTypeInfo
|
||||
for (int i = 0; i < as.length; i++) {
|
||||
ptis[i] = (PseudoTypeInfo) as[i];
|
||||
}
|
||||
init(tc, ptis);
|
||||
init(tc, ptis);
|
||||
}
|
||||
|
||||
// XXX untested guess
|
||||
// We don't have a version of this constructor that also takes the arity
|
||||
// as an argument (as we do with the init method above), e.g.
|
||||
//
|
||||
// public TypeInfo_Struct(TypeInfo_Struct ti, int artiy, Object... as)
|
||||
//
|
||||
// because such overloadings are not allowed under Java 1.7. (Previous
|
||||
// versions of Java incorrectly allowed them.)
|
||||
// If you change this you will also need to update the code in
|
||||
// compiler/rtti_to_mlds.m.
|
||||
// versions of Java incorrectly allowed them.) This is okay because
|
||||
// init above simply checks the number of items in the array to
|
||||
// determine the arity.
|
||||
//
|
||||
public TypeInfo_Struct(TypeInfo_Struct ti, Object... as)
|
||||
// If you change this you will also need to update the code in
|
||||
// compiler/rtti_to_mlds.m and compiler/polymorphism.m
|
||||
//
|
||||
public TypeInfo_Struct(Object a1, Object... as)
|
||||
{
|
||||
init(ti.type_ctor, as);
|
||||
if (a1 instanceof TypeInfo_Struct) {
|
||||
TypeInfo_Struct ti = (TypeInfo_Struct)a1;
|
||||
init(ti.type_ctor, as);
|
||||
} else if (a1 instanceof TypeCtorInfo_Struct) {
|
||||
init((TypeCtorInfo_Struct)a1, as);
|
||||
} else {
|
||||
throw new ClassCastException(
|
||||
"cannot cast argument to a TypeInfo or " +
|
||||
"TypeCtorInfo");
|
||||
}
|
||||
}
|
||||
|
||||
// XXX a temp hack just to get things to run
|
||||
|
||||
Reference in New Issue
Block a user