From: <dgr...@us...> - 2010-01-22 04:23:44
|
Revision: 12676 http://x10.svn.sourceforge.net/x10/?rev=12676&view=rev Author: dgrove-oss Date: 2010-01-22 04:23:36 +0000 (Fri, 22 Jan 2010) Log Message: ----------- Vijay's patch for XTENLANG-902 with some minor additions to files in x10.runtime/src-cpp from me to fix handwritten code in C++ runtime system to (a) enable Rail/ValRail<Any> to be created (missing serialization code in Any) (b) change String.format to take Rail/ValRail<Any> instead of Rail/ValRail<Object> Much of the String format implementations are stubbed out. I will fix tomorrow as part of the work for XTENLANG-818. Modified Paths: -------------- trunk/x10.compiler/src/x10/ExtensionInfo.java trunk/x10.compiler/src/x10/ast/X10Boxed_c.java trunk/x10.compiler/src/x10/ast/X10Cast_c.java trunk/x10.compiler/src/x10/types/X10TypeSystem.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime/src-cpp/x10/lang/Any.h trunk/x10.runtime/src-cpp/x10/lang/String.cc trunk/x10.runtime/src-cpp/x10/lang/String.h trunk/x10.runtime/src-java/x10/core/GrowableRail.java trunk/x10.runtime/src-java/x10/core/Rail.java trunk/x10.runtime/src-java/x10/core/ValRail.java trunk/x10.runtime/src-java/x10/rtt/Equality.java trunk/x10.runtime/src-java/x10/rtt/RuntimeType.java trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 trunk/x10.runtime/src-x10/x10/io/Printer.x10 trunk/x10.runtime/src-x10/x10/io/ReaderIterator.x10 trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 trunk/x10.runtime/src-x10/x10/lang/Clock.x10 trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 trunk/x10.runtime/src-x10/x10/lang/String.x10 trunk/x10.runtime/src-x10/x10/lang/_.x10 trunk/x10.tests/examples/Constructs/Cast/InlineConstraint.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/AssignmentIntLitteralToConstrainedInt.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/AssignmentIntLitteralToConstrainedInt_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/AssignmentPrimitiveConstrainedIdentity.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastNullToNullablePrimitive.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastNullToNullablePrimitiveConstrained.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastNullToNullableReference.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastNullablePrimitiveToPrimitive.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/UnboxNullablePrimitive.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/UnboxNullablePrimitiveConstrained.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/UnboxNullablePrimitiveConstrained2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/UnboxPrimitive.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/UnboxPrimitiveConstrained.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/UnboxPrimitiveConstrained1_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/UnboxPrimitiveConstrained2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/DynamicCast4_MethodReturn.x10.new trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeClassOne.x10.new Added Paths: ----------- trunk/x10.runtime/src-x10/x10/util/Box.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastIn3ToAny3AndBack.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastInt3ToAnyAndBack.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastInt5ToAnyAndInt3.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastIntToAnyAndBack.x10 trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/DynamicCast4_MethodReturn.x10 trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeClassOne.x10 Removed Paths: ------------- trunk/x10.runtime/src-java/x10/core/Box.java trunk/x10.runtime/src-java/x10/core/BoxInt.java trunk/x10.runtime/src-java/x10/core/BoxedBoolean.java trunk/x10.runtime/src-java/x10/core/BoxedByte.java trunk/x10.runtime/src-java/x10/core/BoxedChar.java trunk/x10.runtime/src-java/x10/core/BoxedDouble.java trunk/x10.runtime/src-java/x10/core/BoxedFloat.java trunk/x10.runtime/src-java/x10/core/BoxedInt.java trunk/x10.runtime/src-java/x10/core/BoxedLong.java trunk/x10.runtime/src-java/x10/core/BoxedShort.java trunk/x10.runtime/src-java/x10/core/BoxedString.java trunk/x10.runtime/src-java/x10/core/Value.java trunk/x10.runtime/src-x10/x10/lang/Box.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastBoxedToNullablePrimitive.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastBoxedToNullablePrimitiveConstrained.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastBoxedToNullablePrimitiveConstrained2.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastBoxedToPrimitive.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastBoxedToPrimitive2.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastBoxedToPrimitiveConstrained1.x10 trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/CastBoxedToPrimitiveConstrained2.x10 trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeSubClassOne.x10.new trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10InterfaceOne.x10.new Modified: trunk/x10.compiler/src/x10/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -261,7 +261,7 @@ goals.add(TypeChecked(job)); goals.add(ReassembleAST(job)); - goals.add(X10Boxed(job)); + // goals.add(X10Boxed(job)); goals.add(X10Casted(job)); goals.add(MoveFieldInitializers(job)); goals.add(ConformanceChecked(job)); Modified: trunk/x10.compiler/src/x10/ast/X10Boxed_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Boxed_c.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.compiler/src/x10/ast/X10Boxed_c.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -79,12 +79,12 @@ assert ts.isInterfaceType(toType); - if (ts.typeEquals(toType, ts.Object(), context)) { + /* if (ts.typeEquals(toType, ts.Object(), context)) { Position pos = this.position(); Type t = ts.boxOf(Types.ref(expr.type())); return X10Cast_c.check(nf.New(pos, nf.CanonicalTypeNode(pos, Types.ref(t)), Collections.singletonList(expr)), tc); } - +*/ boolean local = false; Type fromType = e.type(); Type fromBase = X10TypeMixin.baseType(fromType); @@ -116,7 +116,7 @@ Name className = Name.makeFresh("Boxed$"); Name xname = Name.make("v"); - Type superType = ts.boxOf(Types.ref(fromType)); + Type superType = fromType; // ts.boxOf(Types.ref(fromType)); List<ClassMember> members = new ArrayList<ClassMember>(); Modified: trunk/x10.compiler/src/x10/ast/X10Cast_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Cast_c.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.compiler/src/x10/ast/X10Cast_c.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -312,29 +312,29 @@ // } // } - Type boxOfTo = ts.boxOf(Types.ref(toType)); - Type boxOfFrom = ts.boxOf(Types.ref(fromType)); + // Type boxOfTo = ts.boxOf(Types.ref(toType)); + // Type boxOfFrom = ts.boxOf(Types.ref(fromType)); // v: Ref // v as Value // -> // (v as Box[Ref]).value as Value - if (ts.isReferenceOrInterfaceType(fromType, context) && (ts.isParameterType(toType))) { + /* if (ts.isReferenceOrInterfaceType(fromType, context) && (ts.isParameterType(toType))) { Expr boxed = expr; if (! ts.typeEquals(baseFrom, boxOfTo, context)) { boxed = check(nf.X10Cast(position(), nf.CanonicalTypeNode(position(), boxOfTo), expr, convert), tc); return check(nf.X10Cast(position(), nf.CanonicalTypeNode(position(), toType), boxed, convert), tc); } - } + }*/ - if (convert != ConversionType.UNKNOWN_IMPLICIT_CONVERSION && ts.typeEquals(baseFrom, boxOfTo, context)) { + /* if (convert != ConversionType.UNKNOWN_IMPLICIT_CONVERSION && ts.typeEquals(baseFrom, boxOfTo, context)) { // System.out.println("UNBOXING " + expr + " from " + fromType + " to " + toType); Expr unboxed = check(nf.Field(position(), expr, nf.Id(position(), Name.make("value"))), tc); return check(nf.X10Cast(position(), nf.CanonicalTypeNode(position(), toType), unboxed, convert), tc); - } + }*/ // v to I, where I is not a value interface (i.e., a function type) - if (ts.isParameterType(fromType) && ts.typeBaseEquals(toType, ts.Object(), context)) { + /* if (ts.isParameterType(fromType) && ts.typeBaseEquals(toType, ts.Object(), context)) { if (ts.isSubtypeWithValueInterfaces(fromType, toType, context)) { // TypeBuilder tb = new TypeBuilder(tc.job(), ts, nf); // tb = tb.pushPackage(tc.context().package_()); @@ -352,7 +352,7 @@ return check(boxed, tc); } } - +*/ // v to I, where I is not a value interface (i.e., a function type) if (( ts.isParameterType(fromType)) && ts.isInterfaceType(toType)) { if (ts.isSubtypeWithValueInterfaces(fromType, toType, context)) { Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -323,13 +323,13 @@ Type ULong(); - /** x10.lang.Box */ + /** x10.lang.Box * Type Box(); Type boxOf(Ref<? extends Type> base); boolean isBox(Type type); - +*/ boolean isFunctionType(Type type); Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -709,6 +709,8 @@ @Override protected ClassType load(String name) { + if (name.equals("x10.lang.Box") || name.equals("Box")) + new Error("Loading Box??").printStackTrace(); QName qualName = QName.make(name); try { return (ClassType) typeForName(qualName); @@ -762,7 +764,7 @@ } */ - private X10ParsedClassType boxType_; + /* private X10ParsedClassType boxType_; public Type Box() { if (boxType_ == null) @@ -773,7 +775,7 @@ public Type boxOf(Ref<? extends Type> base) { return boxOf(Position.COMPILER_GENERATED, base); } - +*/ public List<Type> superTypes(ObjectType t) { Type sup = t.superClass(); if (sup == null) @@ -830,9 +832,9 @@ return (xt instanceof FunctionType) || ((X10ClassDef) xt.def()).isFunction(); } - public boolean isBox(Type t) { + /* public boolean isBox(Type t) { return hasSameClassDef(t, this.Box()); - } + }*/ public boolean isInterfaceType(Type t) { t = X10TypeMixin.baseType(t); @@ -1067,8 +1069,9 @@ * nullableType() -- the name is misleading. */ public Type boxOf(Position pos, Ref<? extends Type> type) { - X10ParsedClassType box = (X10ParsedClassType) Box(); - return X10TypeMixin.instantiate(box, type); + return type.get(); + // X10ParsedClassType box = (X10ParsedClassType) Box(); + // return X10TypeMixin.instantiate(box, type); } X10ParsedClassType futureType_; Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -691,7 +691,8 @@ xct.restoreAnonObjectScope(inAnonObjectScope); } else - if (((X10TypeSystem) type.typeSystem()).isAny(type) && (t.isBoolean() || t.isNumeric())) { + if (((X10TypeSystem) type.typeSystem()).isAny(X10TypeMixin.baseType(type)) + && (t.isBoolean() || t.isNumeric())) { if (t.isBoolean()) { er.dumpCodeString("((Boolean) #0).booleanValue()", expr); } else if (t.isInt()) { Modified: trunk/x10.runtime/src-cpp/x10/lang/Any.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/Any.h 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-cpp/x10/lang/Any.h 2010-01-22 04:23:36 UTC (rev 12676) @@ -37,6 +37,15 @@ x10aux::ref<x10::lang::String> (I::*toString)(); x10aux::ref<x10::lang::String> (I::*typeName)(); }; + + static void _serialize(x10aux::ref<Any> this_, + x10aux::serialization_buffer &buf) { + x10::lang::Reference::_serialize(this_, buf); + } + + template<class T> static x10aux::ref<T> _deserialize(x10aux::deserialization_buffer &buf) { + return x10::lang::Reference::_deserialize<T>(buf); + } }; } } Modified: trunk/x10.runtime/src-cpp/x10/lang/String.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.cc 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-cpp/x10/lang/String.cc 2010-01-22 04:23:36 UTC (rev 12676) @@ -9,7 +9,6 @@ #include <x10/lang/String.h> #include <x10/lang/Rail.h> -#include <x10/lang/Box.h> #include <cstdarg> #include <sstream> @@ -166,7 +165,7 @@ } // TODO: DG: itables: refactor to share the code. -ref<String> String::format(ref<String> format, ref<ValRail<ref<Object> > > parms) { +ref<String> String::format(ref<String> format, ref<ValRail<ref<Any> > > parms) { std::ostringstream ss; nullCheck(format); char* fmt = const_cast<char*>(format->c_str()); @@ -189,6 +188,7 @@ ss << (buf = x10aux::alloc_printf(fmt, "null")); // FIXME: Ignore nulls for now } else if (x10aux::instanceof<ref<String> >(p)) { ss << (buf = x10aux::alloc_printf(fmt, class_cast<ref<String> >(p)->c_str())); + /* FIXME: XTENLANG-818: } else if (x10aux::instanceof<ref<Box<x10_boolean> > >(p)) { ref<Box<x10_boolean> > tmp = class_cast<ref<Box<x10_boolean> > >(p); ss << (buf = x10aux::alloc_printf(fmt, tmp->FMGL(value))); @@ -213,6 +213,7 @@ } else if (x10aux::instanceof<ref<Box<x10_double> > >(p)) { ref<Box<x10_double> > tmp = class_cast<ref<Box<x10_double> > >(p); ss << (buf = x10aux::alloc_printf(fmt, tmp->FMGL(value))); + */ } else { ss << (buf = x10aux::alloc_printf(fmt, p->toString()->c_str())); } @@ -224,7 +225,7 @@ return String::Lit(ss.str().c_str()); } -ref<String> String::format(ref<String> format, ref<Rail<ref<Object> > > parms) { +ref<String> String::format(ref<String> format, ref<Rail<ref<Any> > > parms) { std::ostringstream ss; nullCheck(format); char* fmt = const_cast<char*>(format->c_str()); @@ -247,6 +248,7 @@ ss << (buf = x10aux::alloc_printf(fmt, "null")); // FIXME: Ignore nulls for now } else if (x10aux::instanceof<ref<String> >(p)) { ss << (buf = x10aux::alloc_printf(fmt, class_cast<ref<String> >(p)->c_str())); + /* FIXME: XTENLANG-818: } else if (x10aux::instanceof<ref<Box<x10_boolean> > >(p)) { ref<Box<x10_boolean> > tmp = class_cast<ref<Box<x10_boolean> > >(p); ss << (buf = x10aux::alloc_printf(fmt, tmp->FMGL(value))); @@ -271,6 +273,7 @@ } else if (x10aux::instanceof<ref<Box<x10_double> > >(p)) { ref<Box<x10_double> > tmp = class_cast<ref<Box<x10_double> > >(p); ss << (buf = x10aux::alloc_printf(fmt, tmp->FMGL(value))); + */ } if (buf != NULL) dealloc(buf); Modified: trunk/x10.runtime/src-cpp/x10/lang/String.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.h 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-cpp/x10/lang/String.h 2010-01-22 04:23:36 UTC (rev 12676) @@ -121,10 +121,10 @@ virtual void _destructor(); static x10aux::ref<String> format(x10aux::ref<String> format, - x10aux::ref<ValRail<x10aux::ref<Object> > > parms); + x10aux::ref<ValRail<x10aux::ref<Any> > > parms); static x10aux::ref<String> format(x10aux::ref<String> format, - x10aux::ref<Rail<x10aux::ref<Object> > > parms); + x10aux::ref<Rail<x10aux::ref<Any> > > parms); virtual x10_boolean equals(x10aux::ref<x10::lang::Any> p0); Deleted: trunk/x10.runtime/src-java/x10/core/Box.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Box.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/Box.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,128 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.core; - -import x10.rtt.Equality; -import x10.rtt.RuntimeType; -import x10.rtt.Type; - -public class Box<T> extends Ref { - protected final Type<T> type; - protected final T value; - - public static class RTT<T> extends RuntimeType<Box<T>> { - Type<T> type; - - public RTT(Type<?> type) { - super(Box.class); - this.type = (Type<T>) type; - } - - @Override - public boolean instanceof$(Object o) { - return o instanceof Box && ((Box) o).type.isSubtype(type); - } - - @Override - public boolean isSubtype(Type<?> o) { - if (o instanceof Box.RTT) { - Box.RTT other = (Box.RTT) o; - return type.isSubtype(other.type); - } - return super.isSubtype(o); - } - } - - protected Box(Type<?> type, T v) { - assert v != null; - this.value = v; - this.type = (Type<T>) type; - } -// protected Box(Type<T> type, T v) { -// assert v != null; -// this.value = v; -// this.type = type; -// } - - public static Box<Boolean> make(Type<Boolean> type, boolean v) { return new BoxedBoolean(v); } - public static Box<Byte> make(Type<Byte> type, byte v) { return new BoxedByte(v); } - public static Box<Short> make(Type<Short> type, short v) { return new BoxedShort(v); } - public static Box<Character> make(Type<Character> type, char v) { return new BoxedChar(v); } - public static Box<Integer> make(Type<Integer> type, int v) { return new BoxedInt(v); } - public static Box<Long> make(Type<Long> type, long v) { return new BoxedLong(v); } - public static Box<Float> make(Type<Float> type, float v) { return new BoxedFloat(v); } - public static Box<Double> make(Type<Double> type, double v) { return new BoxedDouble(v); } - - public static <S> Ref make(Type<S> type, S v) { - if (v == null) - return null; - if (v instanceof Box) { - Box<?> box = (Box<?>) v; - if (type.instanceof$(box.value())) { - return make(type, (S) box.value()); - } - else { - throw new ClassCastException(); - } - } - if (v instanceof Ref) - return (Ref) v; - if (v instanceof Value) - return ((Value) v).box$(); - if (v instanceof String) - return new BoxedString((String) v); - if (v instanceof Boolean) - return new BoxedBoolean((Boolean) v); - if (v instanceof Byte) - return new BoxedByte((Byte) v); - if (v instanceof Character) - return new BoxedChar((Character) v); - if (v instanceof Short) - return new BoxedShort((Short) v); - if (v instanceof Integer) - return new BoxedInt((Integer) v); - if (v instanceof Long) - return new BoxedLong((Long) v); - if (v instanceof Float) - return new BoxedFloat((Float) v); - if (v instanceof Double) - return new BoxedDouble((Double) v); - - // TOOD: Throwable - - return new Box<S>(type, v); - } - - public T value() { return value; } - - public static <T> T unbox(Box<T> box) { - if (box != null) { - return box.value(); - } - throw new ClassCastException(); - } - - public boolean equals(Object o) { - if (o == null) - return false; - if (o instanceof Box) - return Equality.equalsequals(value, ((Box<?>) o).value); - if (Equality.equalsequals(value, o)) - return true; - return false; - } - - public int hashCode() { - return value.hashCode(); - } - - public String toString() { - return value.toString(); - } -} Deleted: trunk/x10.runtime/src-java/x10/core/BoxInt.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxInt.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxInt.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,28 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.core; - -import x10.rtt.Equality; -import x10.rtt.RuntimeType; -import x10.rtt.Type; -import x10.rtt.Types; - -public class BoxInt extends Box<Integer> { - public BoxInt(int v) { - super(Types.INT, v); - } - - public int hashCode() { - return value.hashCode(); - } - - public String toString() { - return value.toString(); - } -} Deleted: trunk/x10.runtime/src-java/x10/core/BoxedBoolean.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedBoolean.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedBoolean.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,12 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedBoolean<T> extends Box<Boolean> { - public BoxedBoolean(boolean v) { - super(Types.BOOLEAN, v); - } -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedByte.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedByte.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedByte.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,32 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedByte<T> extends Box<Byte> { - public BoxedByte(byte v) { - super(Types.BYTE, v); - } - - public String toString(Integer radix) { - return java.lang.Integer.toString(this.value, radix); - } - - public String toHexString() { - return java.lang.Integer.toHexString(this.value); - } - - public String toOctalString() { - return java.lang.Integer.toOctalString(this.value); - } - - public String toBinaryString() { - return java.lang.Integer.toBinaryString(this.value); - } - - public String toString() { - return java.lang.Byte.toString(this.value); - } -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedChar.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedChar.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedChar.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,67 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedChar<T> extends Box<Character> { - public BoxedChar(char v) { - super(Types.CHAR, v); - } - - public Boolean isLowerCase() { - return java.lang.Character.isLowerCase(this.value); - } - public Boolean isUpperCase() { - return java.lang.Character.isUpperCase(this.value); - } - public Boolean isTitleCase() { - return java.lang.Character.isTitleCase(this.value); - } - public Boolean isDigit() { - return java.lang.Character.isDigit(this.value); - } - public Boolean isLetter() { - return java.lang.Character.isLetter(this.value); - } - public Boolean isLetterOrDigit() { - return java.lang.Character.isLetterOrDigit(this.value); - } - public Boolean isUnicodeIdentifierStart() { - return java.lang.Character.isUnicodeIdentifierStart(this.value); - } - public Boolean isUnicodeIdentifierPart() { - return java.lang.Character.isUnicodeIdentifierPart(this.value); - } - public Boolean isIdentifierIgnorable() { - return java.lang.Character.isIdentifierIgnorable(this.value); - } - public Boolean isSpace() { - return java.lang.Character.isSpace(this.value); - } - public Boolean isSpaceChar() { - return java.lang.Character.isSpaceChar(this.value); - } - public Boolean isWhitespace() { - return java.lang.Character.isWhitespace(this.value); - } - public Boolean isISOControl() { - return java.lang.Character.isISOControl(this.value); - } - public Character toLowerCase() { - return java.lang.Character.toLowerCase(this.value); - } - public Character toUpperCase() { - return java.lang.Character.toUpperCase(this.value); - } - public Character toTitleCase() { - return java.lang.Character.toTitleCase(this.value); - } - public Integer ord() { - return (Integer) ((int) this.value); - } - public Character reverseBytes() { - return java.lang.Character.reverseBytes(this.value); - } -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedDouble.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedDouble.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedDouble.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,33 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedDouble<T> extends Box<Double> { - public BoxedDouble(double v) { - super(Types.DOUBLE, v); - } - - public String toHexString() { - return java.lang.Double.toHexString(this.value); - } - public String toString() { - return java.lang.Double.toString(this.value); - } - public Boolean isNaN() { - return java.lang.Double.isNaN(this.value); - } - public Boolean isInfinite() { - return java.lang.Double.isInfinite(this.value); - } - - public Long toIntBits() { - return java.lang.Double.doubleToLongBits(this.value); - } - public Long toRawIntBits() { - return java.lang.Double.doubleToRawLongBits(this.value); - } - -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedFloat.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedFloat.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedFloat.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,32 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedFloat<T> extends Box<Float> { - public BoxedFloat(float v) { - super(Types.FLOAT, v); - } - - public String toHexString() { - return java.lang.Float.toHexString(this.value); - } - public String toString() { - return java.lang.Float.toString(this.value); - } - public Boolean isNaN() { - return java.lang.Float.isNaN(this.value); - } - public Boolean isInfinite() { - return java.lang.Float.isInfinite(this.value); - } - - public Integer toIntBits() { - return java.lang.Float.floatToIntBits(this.value); - } - public Integer toRawIntBits() { - return java.lang.Float.floatToRawIntBits(this.value); - } -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedInt.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedInt.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedInt.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,72 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedInt<T> extends Box<Integer> { - public BoxedInt(int v) { - super(Types.INT, v); - } - - public String toString(Integer radix) { - return Integer.toString(this.value, radix); - } - - public String toHexString() { - return Integer.toHexString(this.value); - } - - public String toOctalString() { - return Integer.toOctalString(this.value); - } - - public String toBinaryString() { - return Integer.toBinaryString(this.value); - } - - public String toString() { - return Integer.toString(this.value); - } - - public Integer highestOneBit() { - return Integer.highestOneBit(this.value); - } - - public Integer lowestOneBit() { - return Integer.lowestOneBit(this.value); - } - - public Integer numberOfLeadingZeros() { - return Integer.numberOfLeadingZeros(this.value); - } - - public Integer numberOfTrailingZeros() { - return Integer.numberOfTrailingZeros(this.value); - } - - public Integer bitCount() { - return Integer.bitCount(this.value); - } - - public Integer rotateLeft(Integer bits) { - return Integer.rotateLeft(this.value, bits); - } - - public Integer rotateRight(Integer bits) { - return Integer.rotateRight(this.value, bits); - } - - public Integer reverse() { - return Integer.reverse(this.value); - } - - public Integer signum() { - return Integer.signum(this.value); - } - - public Integer reverseBytes() { - return Integer.reverseBytes(this.value); - } -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedLong.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedLong.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedLong.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,73 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedLong<T> extends Box<Long> { - public BoxedLong(long v) { - super(Types.LONG, v); - } - - public String toString(Integer radix) { - return Long.toString(this.value, radix); - } - - public String toHexString() { - return Long.toHexString(this.value); - } - - public String toOctalString() { - return Long.toOctalString(this.value); - } - - public String toBinaryString() { - return Long.toBinaryString(this.value); - } - - public String toString() { - return Long.toString(this.value); - } - - public Long highestOneBit() { - return Long.highestOneBit(this.value); - } - - public Long lowestOneBit() { - return Long.lowestOneBit(this.value); - } - - public Integer numberOfLeadingZeros() { - return Long.numberOfLeadingZeros(this.value); - } - - public Integer numberOfTrailingZeros() { - return Long.numberOfTrailingZeros(this.value); - } - - public Integer bitCount() { - return Long.bitCount(this.value); - } - - public Long rotateLeft(Integer bits) { - return Long.rotateLeft(this.value, bits); - } - - public Long rotateRight(Integer bits) { - return Long.rotateRight(this.value, bits); - } - - public Long reverse() { - return Long.reverse(this.value); - } - - public Integer signum() { - return Long.signum(this.value); - } - - public Long reverseBytes() { - return Long.reverseBytes(this.value); - } - -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedShort.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedShort.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedShort.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,36 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.Types; - -public class BoxedShort<T> extends Box<Short> { - public BoxedShort(short v) { - super(Types.SHORT, v); - } - - public String toString(Integer radix) { - return java.lang.Integer.toString(this.value, radix); - } - - public String toHexString() { - return java.lang.Integer.toHexString(this.value); - } - - public String toOctalString() { - return java.lang.Integer.toOctalString(this.value); - } - - public String toBinaryString() { - return java.lang.Integer.toBinaryString(this.value); - } - - public String toString() { - return java.lang.Short.toString(this.value); - } - - public Short reverseBytes() { - return java.lang.Short.reverseBytes(this.value); - } -} \ No newline at end of file Deleted: trunk/x10.runtime/src-java/x10/core/BoxedString.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/BoxedString.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/BoxedString.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,28 +0,0 @@ -/** - * - */ -package x10.core; - -import x10.rtt.RuntimeType; - -public class BoxedString<T> extends Box<String> { - public BoxedString(String v) { - super(new RuntimeType<String>(String.class), v); - } - - public Integer length() { - return this.value.length(); - } - - public Character apply(Integer i) { - return this.value.charAt(i); - } - - public Character charAt(Integer i) { - return this.value.charAt(i); - } - - public String substring(Integer fromIndex, Integer toIndex) { - return this.value.substring(fromIndex, toIndex); - } -} \ No newline at end of file Modified: trunk/x10.runtime/src-java/x10/core/GrowableRail.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/GrowableRail.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/GrowableRail.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -127,49 +127,9 @@ return elementType; } - @Override - public Ref box$() { - return new BoxedGrowableRail(elementType, this); - } - public static class BoxedGrowableRail<T> extends Box<GrowableRail<T>> implements Indexable<Integer,T>, Fun_0_1<Integer,T>, Iterable<T>, Settable<Integer,T> { - public BoxedGrowableRail(Type<T> T, GrowableRail<T> v) { - super(new GrowableRail.RTT(T), v); - } + - public T apply(Integer o) { - return this.value.apply(o); - } - - public Type<?> rtt_x10$lang$Fun_0_1_U() { - throw new RuntimeException(); - } - - public Type<?> rtt_x10$lang$Fun_0_1_Z1() { - throw new RuntimeException(); - } - - public Iterator<T> iterator() { - return this.value.iterator(); - } - - public T set(T v, Integer i) { - return this.value.set(v, i); - } - - public Integer length() { - return this.value.length(); - } - - public void add(T v) { - this.value.add(v); - } - - public void removeLast() { - this.value.removeLast(); - } - } - // // Runtime type information Modified: trunk/x10.runtime/src-java/x10/core/Rail.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Rail.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/Rail.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -144,33 +144,8 @@ // boxed rail // - @Override - public Ref box$() { - return new BoxedRail(type, this); - } - - public static class BoxedRail<T> extends Box<Rail<T>> implements Indexable<Integer,T>, Fun_0_1<Integer,T>, Settable<Integer,T> { - public BoxedRail(Type<T> T, Rail<T> v) { - super(new Rail.RTT(T), v); - } + - public T apply(Integer o) { - return this.value.apply(o); - } - - public Type<?> rtt_x10$lang$Fun_0_1_U() { - throw new RuntimeException(); - } - - public Type<?> rtt_x10$lang$Fun_0_1_Z1() { - throw new RuntimeException(); - } - - public T set(T v, Integer i) { - return this.value.set(v, i); - } - } - // // Runtime type information // Modified: trunk/x10.runtime/src-java/x10/core/ValRail.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/ValRail.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/ValRail.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -149,36 +149,9 @@ return value.toString(); } + // - // boxed rail - // - - // @Override - public Ref box$() { - return new BoxedValRail(type, this); - } - - public static class BoxedValRail<T> extends Box<ValRail<T>> implements Indexable<Integer,T>, Fun_0_1<Integer,T> { - public BoxedValRail(Type<T> T, ValRail<T> v) { - super(new ValRail.RTT(T), v); - } - - public T apply(Integer o) { - return this.value.apply(o); - } - - public Type<?> rtt_x10$lang$Fun_0_1_U() { - throw new RuntimeException(); - } - - public Type<?> rtt_x10$lang$Fun_0_1_Z1() { - throw new RuntimeException(); - } - } - - - // // Runtime type information // Deleted: trunk/x10.runtime/src-java/x10/core/Value.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Value.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/core/Value.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,153 +0,0 @@ -/* - * - * (C) Copyright IBM Corporation 2006-2008. - * - * This file is part of X10 Language. - * - */ - -package x10.core; - -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; - -import x10.rtt.Equality; -import x10.rtt.RuntimeType; -import x10.rtt.Type; - -// Base class of all X10 value objects -- should be generated, but we need this class to get Box to compile. -public class Value { - - public static class RTT extends RuntimeType<Value> { - public static final RTT it = new RTT(); - - public RTT() { - super(Value.class); - } - - @Override - public boolean instanceof$(Object o) { - return o instanceof Value; - } - } - - public static class BoxedValue extends Box<Value> { - BoxedValue(Value v) { - super(Value.RTT.it, v); - } - } - - public Ref box$() { - return new BoxedValue(this); - } - - public boolean equals(Object o) { - if (o instanceof Value) - return this.equals((Value) o); - return false; - } - - public boolean equals(Ref o) { - return false; - } - - public boolean equals(Value o) { - return structEquals(o); - } - - public int hashCode() { - return structHash(); - } - - public final int structHash() { - Class<?> c = this.getClass(); - Object o = this; - int hash = 17; - try { - while (c != null) { - Field[] fs = c.getDeclaredFields(); - for (int i = fs.length - 1; i >= 0; i--) { - Field f = fs[i]; - if (Modifier.isStatic(f.getModifiers())) - continue; - if (Type.class.isAssignableFrom(f.getType())) - continue; - f.setAccessible(true); - if (f.getType().isPrimitive()) { - hash = hash * 37 + f.get(o).hashCode(); - } - else if (f.getType().isArray()) { - java.lang.Object a = f.get(o); - int len = Array.getLength(a); - for (int j = 0; j < len; j++) { - hash = hash * 37 + Array.get(a, j).hashCode(); - } - } - else { - // I assume here that value types are immutable - // and can thus not contain mutually recursive - // structures. If that is wrong, we would have to do - // more work here to avoid dying with a StackOverflow. - hash = hash * 37 + f.get(o).hashCode(); - } - } - c = c.getSuperclass(); - } - } - catch (IllegalAccessException iae) { - throw new Error(iae); // fatal, should never happen - } - return hash; - } - - public final boolean structEquals(Object o) { - if (o == null) - return false; - if (o == this) - return true; - Class<?> c = this.getClass(); - Object o1 = this; - Object o2 = o; - if (c != o2.getClass()) - return false; - try { - while (c != null) { - Field[] fs = c.getDeclaredFields(); - for (int i = fs.length - 1; i >= 0; i--) { - Field f = fs[i]; - if (Modifier.isStatic(f.getModifiers())) - continue; - f.setAccessible(true); - Object a1 = f.get(o1); - Object a2 = f.get(o2); - if (f.getType().isPrimitive()) { - if (!Equality.equalsequals(a1, a2)) - return false; - } - else if (f.getType().isArray()) { - int len = Array.getLength(a1); - if (len != Array.getLength(a2)) - return false; - for (int j = 0; j < len; j++) - if (!Equality.equalsequals(Array.get(a1, j), Array.get(a2, j))) - return false; - } - else { - // I assume here that value types are immutable - // and can thus not contain mutually recursive - // structures. If that is wrong, we would have to do - // more work here to avoid dying with a StackOverflow. - if (!Equality.equalsequals(a1, a2)) - return false; - } - } - c = c.getSuperclass(); - } - } - catch (IllegalAccessException iae) { - throw new Error(iae); // fatal, should never happen - } - return true; - } -} Modified: trunk/x10.runtime/src-java/x10/rtt/Equality.java =================================================================== --- trunk/x10.runtime/src-java/x10/rtt/Equality.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/rtt/Equality.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -8,9 +8,9 @@ package x10.rtt; -import x10.core.Box; + import x10.core.Ref; -import x10.core.Value; + import x10.core.Struct; public class Equality { @@ -82,7 +82,7 @@ } } public static boolean equalsequals(Struct a, Struct b) { return a.structEquals(b); } - public static boolean equalsequals(Value a, Value b) { return a.structEquals(b); } + // public static boolean equalsequals(Value a, Value b) { return a.structEquals(b); } public static boolean equalsequals(Ref a, Ref b) { return a == b; } public static boolean equalsequals(Object a, boolean b) { return equalsequals(a, (Object) b); } @@ -107,7 +107,7 @@ if (a instanceof Number && b instanceof Number) return equalsNumbers(a, b); if (a instanceof Comparable) return ((Comparable) a).compareTo(b) == 0; - if (a instanceof Value) return ((Value) a).structEquals(b); + // if (a instanceof Value) return ((Value) a).structEquals(b); if (a instanceof Struct) return ((Struct) a).structEquals(b); return false; Modified: trunk/x10.runtime/src-java/x10/rtt/RuntimeType.java =================================================================== --- trunk/x10.runtime/src-java/x10/rtt/RuntimeType.java 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-java/x10/rtt/RuntimeType.java 2010-01-22 04:23:36 UTC (rev 12676) @@ -14,7 +14,6 @@ import java.util.List; import x10.core.Ref; -import x10.core.Value; import x10.core.fun.Fun_0_1; import x10.core.fun.Fun_0_2; import x10.constraint.XConstraint; @@ -78,9 +77,10 @@ public T zeroValue() { // null for ref types, otherwise complain - if (!x10.runtime.impl.java.Configuration.NULL_DEFAULT_VALUE && Value.class.isAssignableFrom(c)) { + /* if (!x10.runtime.impl.java.Configuration.NULL_DEFAULT_VALUE + && Value.class.isAssignableFrom(c)) { throw new UnsupportedOperationException(); - } + }*/ return null; } Modified: trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -55,13 +55,13 @@ return this; val pmb = new PolyMatBuilder(rank); - var last: Box[PolyRow] = null; + var last: PolyRow = null; for (next:PolyRow in this) { if (last!=null && !next.isParallel(last as PolyRow)) pmb.add(last as PolyRow); - last = new Box[PolyRow](next); + last = next; } - pmb.add(last.value); + pmb.add(last); return pmb.toSortedPolyMat(false); } Modified: trunk/x10.runtime/src-x10/x10/io/Printer.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/io/Printer.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/io/Printer.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -51,16 +51,21 @@ public global def printf(fmt: String): Void { printf(fmt, []); } - public global def printf(fmt: String, o1: Object): Void { printf(fmt, [o1]); } - public global def printf(fmt: String, o1: Object, o2: Object): Void { printf(fmt, [o1,o2]); } - public global def printf(fmt: String, o1: Object, o2: Object, o3: Object): Void { printf(fmt, [o1,o2,o3]); } - public global def printf(fmt: String, o1: Object, o2: Object, o3: Object, o4: Object): Void { printf(fmt, [o1,o2,o3,o4]); } - public global def printf(fmt: String, o1: Object, o2: Object, o3: Object, o4: Object, o5: Object): Void { printf(fmt, [o1,o2,o3,o4,o5]); } - public global def printf(fmt: String, o1: Object, o2: Object, o3: Object, o4: Object, o5: Object, o6: Object): Void { printf(fmt, [o1,o2,o3,o4,o5,o6]); } + public global def printf(fmt: String, o1: Any): Void { printf(fmt, [o1]); } + public global def printf(fmt: String, o1: Any, o2: Any): Void { printf(fmt, [o1,o2]); } + public global def printf(fmt: String, o1: Any, o2: Any, o3: Any): Void { printf(fmt, [o1,o2,o3]); } + public global def printf(fmt: String, o1: Any, o2: Any, o3: Any, o4: Any): Void { + printf(fmt, [o1,o2,o3,o4]); + } + public global def printf(fmt: String, o1: Any, o2: Any, o3: Any, o4: Any, o5: Any): Void { + printf(fmt, [o1,o2,o3,o4,o5]); + } + public global def printf(fmt: String, o1: Any, o2: Any, o3: Any, o4: Any, o5: Any, o6: Any): Void { + printf(fmt, [o1,o2,o3,o4,o5,o6]); + } + public global def printf(fmt: String, args: Rail[Any]): Void { print(String.format(fmt, args)); } + public global def printf(fmt: String, args: ValRail[Any]): Void { print(String.format(fmt, args)); } - public global def printf(fmt: String, args: Rail[Object]): Void { print(String.format(fmt, args)); } - public global def printf(fmt: String, args: ValRail[Object]): Void { print(String.format(fmt, args)); } - public global def flush(): Void { try { Modified: trunk/x10.runtime/src-x10/x10/io/ReaderIterator.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/io/ReaderIterator.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/io/ReaderIterator.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -9,7 +9,7 @@ package x10.io; import x10.util.NoSuchElementException; - +import x10.util.Box; /** * Usage: * @@ -32,7 +32,7 @@ public def this(m: Marshal[T], r: Reader) { this.m = m; this.r = r; - this.next = null; + // this.next = null; } /** Allow the iterator to be used in a for loop. */ @@ -41,7 +41,7 @@ public def next(): T = { if (! hasNext()) throw new NoSuchElementException(); - val x: T = next as T; + val x: T = next.value; next = null; return x; } @@ -50,7 +50,7 @@ if (next == null) { try { val x: T = r.read[T](m); - next = x as Box[T]; + next = new Box[T](x); } catch (IOException) { return false; Modified: trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/lang/Boolean.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -48,7 +48,7 @@ @Native("c++", "x10aux::boolean_utils::parseBoolean(#1)") public native static def parseBoolean(String): Boolean; - @Native("java", "((((#2) instanceof boolean) && #1 == ((boolean)#2)) || (((#2) instanceof x10.core.BoxedBoolean) && #1 == ((x10.core.BoxedBoolean) #2).value.value))") + @Native("java", "((((#2) instanceof boolean) && #1 == ((boolean)#2)) || (((#2) instanceof Boolean) && #1 == ((Boolean) #2).booleanValue()))") @Native("c++", "x10aux::equals(#0,#1)") public global safe native def equals(x:Any):Boolean; Deleted: trunk/x10.runtime/src-x10/x10/lang/Box.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Box.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/lang/Box.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -1,29 +0,0 @@ -package x10.lang; - -import x10.compiler.Native; -import x10.compiler.NativeRep; - -public final class Box[+T](value: T) { - public def this(x: T) { property(x); } - - public global safe def hashCode(): int = value.hashCode(); - - public global safe def toString(): String = value.toString(); - - public global safe def equals(x:Any): Boolean { - if (x == null) { - return false; - } - if (x instanceof T) { - val y = x as T; - return value.equals(y); - } - if (x instanceof Box[T]) { - val y = (x as Box[T]).value; - return value.equals(y); - } - return false; - } - - public static operator[T](x:T):Box[T] = new Box[T](x); -} Modified: trunk/x10.runtime/src-x10/x10/lang/Clock.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Clock.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/lang/Clock.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -30,11 +30,11 @@ property(name); } - private global def get() = Runtime.clockPhases().get(this) as Int; + private global def get() = Runtime.clockPhases().get(this).value; private global def put(ph:Int) = Runtime.clockPhases().put(this, ph); - private global def remove() = Runtime.clockPhases().remove(this) as Int; + private global def remove() = Runtime.clockPhases().remove(this).value; private atomic def resumeLocal() { if (--alive == 0) { Modified: trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -16,7 +16,7 @@ import x10.util.Random; import x10.util.Stack; import x10.util.concurrent.atomic.AtomicInteger; - +import x10.util.Box; /** * @author tardieu */ @@ -941,7 +941,7 @@ async (box) box.latch.release(); } catch (e:Throwable) { async (box) { - box.e = e; + box.e = new Box[Throwable](e); box.latch.release(); } } @@ -949,7 +949,7 @@ if (!NO_STEALS && safe()) worker().join(box.latch); box.latch.await(); if (null != box.e) { - val x = box.e as Throwable; + val x = box.e.value; if (x instanceof Error) throw x as Error; if (x instanceof RuntimeException) @@ -985,7 +985,7 @@ if (!NO_STEALS && safe()) worker().join(box.latch); box.latch.await(); if (null != box.e) { - val x = box.e as Throwable; + val x = box.e.value; if (x instanceof Error) throw x as Error; if (x instanceof RuntimeException) Modified: trunk/x10.runtime/src-x10/x10/lang/String.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/String.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/lang/String.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -78,11 +78,11 @@ @Native("c++", "x10aux::safe_to_string(#4)") public native static def valueOf[T](T):String; - @Native("java", "java.lang.String.format(#1, new Object() { final Object[] unbox(Object[] a) { Object[] b = new Object[a.length]; for (int i = 0; i < a.length; i++) { if (a[i] instanceof x10.lang.Box) b[i] = ((x10.lang.Box) a[i]).value(); else b[i] = a[i]; } return b; } }.unbox(#2.getBoxedArray()))") + @Native("java", "java.lang.String.format(#1, #2.getBoxedArray())") @Native("c++", "x10::lang::String::format(#1,#2)") - public native static def format(fmt: String, Rail[Object]): String; + public native static def format(fmt: String, Rail[Any]): String; - @Native("java", "java.lang.String.format(#1, new Object() { final Object[] unbox(Object[] a) { Object[] b = new Object[a.length]; for (int i = 0; i < a.length; i++) { if (a[i] instanceof x10.lang.Box) b[i] = ((x10.lang.Box) a[i]).value(); else b[i] = a[i]; } return b; } }.unbox(#2.getBoxedArray()))") + @Native("java", "java.lang.String.format(#1, #2.getBoxedArray())") @Native("c++", "x10::lang::String::format(#1,#2)") - public native static def format(fmt: String, ValRail[Object]): String; + public native static def format(fmt: String, ValRail[Any]): String; } Modified: trunk/x10.runtime/src-x10/x10/lang/_.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/_.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.runtime/src-x10/x10/lang/_.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -31,6 +31,7 @@ public static type Float(b:Float) = Float{self==b}; public static type Double(b:Double) = Double{self==b}; public static type String(s:String) = String{self==s}; + public static type Any(x:Any) = Any{self==x}; public static type signed = Int; Added: trunk/x10.runtime/src-x10/x10/util/Box.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/Box.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/util/Box.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -0,0 +1,27 @@ +package x10.util; + +public final class Box[+T](value: T) implements ()=> T { + public def this(x: T) { property(x); } + + public def apply()=value; + public global safe def hashCode(): int = value.hashCode(); + + public global safe def toString(): String = value.toString(); + + public global safe def equals(x:Any): Boolean { + if (x == null) { + return false; + } + if (x instanceof T) { + val y = x as T; + return value.equals(y); + } + if (x instanceof Box[T]) { + val y = (x as Box[T]).value; + return value.equals(y); + } + return false; + } + + public static operator[T](x:T):Box[T] = new Box[T](x); +} Property changes on: trunk/x10.runtime/src-x10/x10/util/Box.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.tests/examples/Constructs/Cast/InlineConstraint.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Cast/InlineConstraint.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.tests/examples/Constructs/Cast/InlineConstraint.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -13,24 +13,24 @@ public def run() { val v:Object = 0..5; var result:boolean=true; - val c = v instanceof Region{self.rank==1}; + val c = v instanceof Region(1); if (!c) { Console.OUT.println("v instanceof Region{self.rank==1} failed."); result=false; } - val d = v instanceof Region{self.rank==2}; + val d = v instanceof Region(2); if (d) { Console.OUT.println("WTF, it's a two-dimensional region?!"); result=false; } try { - val e = v as Region{self.rank==1}; + val e = v as Region(1); } catch (ClassCastException) { Console.OUT.println("WTF, cast to a single-dimensional region failed?!"); result=false; } try { - val f = v as Region{self.rank==2}; + val f = v as Region(2); Console.OUT.println("WTF, cast to a two-dimensional region succeeded?!"); result = false; } catch (ClassCastException) { Modified: trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/AssignmentIntLitteralToConstrainedInt.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/AssignmentIntLitteralToConstrainedInt.x10 2010-01-22 03:44:31 UTC (rev 12675) +++ trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/AssignmentIntLitteralToConstrainedInt.x10 2010-01-22 04:23:36 UTC (rev 12676) @@ -16,8 +16,8 @@ public def run(): boolean = { try { - var i: int{self == 0} = 0; - i = 0; + val j = 1 as Int(0); + }catch (e: Throwable) { return false; } @@ -25,7 +25,7 @@ return true; } - public static def main(var args: Rail[String]): void = { + public static def main(Rail[String]){ new AssignmentIntLitteralToConstrainedInt().execute(); } Modified: trunk/x10.tests/examples/Constructs/Cast/PrimitiveDependentTypeCast/AssignmentIntLitteralToConstrainedInt_MustFailCompile.x10 ===============================================================... [truncated message content] |