From: <dgr...@us...> - 2010-02-01 19:25:24
|
Revision: 12782 http://x10.svn.sourceforge.net/x10/?rev=12782&view=rev Author: dgrove-oss Date: 2010-02-01 19:25:11 +0000 (Mon, 01 Feb 2010) Log Message: ----------- WIP in building a shared library version of x10rt that can be loaded by a JVM to supply native methods backing the Java bindings for X10RT. In this step, x10rt itself is built using libtool and the default postcompiler for the C++ backend becomes libtool as well so that the produced executables will run without requiring x10.dist/lib to be added to the LD_LIBRARY_PATH. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java trunk/x10.runtime/src-cpp/x10rt/Makefile trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk trunk/x10.runtime/src-cpp/x10rt/standalone/standalone.mk Modified: trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2010-01-31 03:15:57 UTC (rev 12781) +++ trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2010-02-01 19:25:11 UTC (rev 12782) @@ -92,7 +92,7 @@ protected boolean gcEnabled() { return false; } protected String defaultPostCompiler() { - return x10rtOpts.cxx; + return "libtool --mode=link --tag=CXX "+x10rtOpts.cxx; } /** Add the arguments that go before the output files */ Modified: trunk/x10.runtime/src-cpp/x10rt/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/Makefile 2010-01-31 03:15:57 UTC (rev 12781) +++ trunk/x10.runtime/src-cpp/x10rt/Makefile 2010-02-01 19:25:11 UTC (rev 12782) @@ -15,9 +15,9 @@ EXECUTABLES = -X10_HOME = ../../.. +X10_HOME = ${CURDIR}/../../.. -COMMON_OBJS = common/x10rt_front.o common/x10rt_logical.o common/x10rt_cuda.o +COMMON_OBJS = common/x10rt_front.lo common/x10rt_logical.lo common/x10rt_cuda.lo ifdef ENABLE_X10RT_CUDA CXXFLAGS += -DENABLE_CUDA -isystem/usr/local/cuda/include @@ -38,8 +38,11 @@ include standalone/standalone.mk +%.lo: %.cc + libtool --mode=compile $(CXX) $(CXXFLAGS) -c $< -o $@ + install: $(LIBS) $(PROPERTIES) - $(CP) $(LIBS) $(X10_HOME)/x10.dist/lib + libtool --mode=install $(CP) $(LIBS) $(X10_HOME)/x10.dist/lib $(CP) $(PROPERTIES) $(X10_HOME)/x10.dist/etc $(CP) include/*.h $(X10_HOME)/x10.dist/include (test -n "$(EXECUTABLES)" && $(CP) $(EXECUTABLES) $(X10_HOME)/x10.dist/bin) || true @@ -61,20 +64,21 @@ @echo TESTS = $(TESTS) clean: - $(RM) -r */*.o lib/*.a bin/* etc/*.properties test/*.mpi test/*.standalone test/*.pgas_* */*~ *~ core* vgcore* include/pgasrt*.h include/xlupc*.h + $(RM) -r */*.o bin/* etc/*.properties test/*.mpi */*~ *~ core* vgcore* include/pgasrt*.h include/xlupc*.h + libtool --mode=clean $(RM) */*.lo lib/*.la test/*.standalone test/*.pgas_* test/*.mpi_* # vim: ts=8:sw=8:noet # DO NOT DELETE -common/x10rt_cuda.o: include/x10rt_types.h common/x10rt_internal.h -common/x10rt_cuda.o: include/x10rt_cuda.h -common/x10rt_front.o: include/x10rt_front.h include/x10rt_types.h -common/x10rt_front.o: include/x10rt_logical.h -common/x10rt_logical.o: include/x10rt_logical.h include/x10rt_types.h -common/x10rt_logical.o: include/x10rt_net.h include/x10rt_cuda.h -common/x10rt_logical.o: common/x10rt_internal.h -mpi/x10rt_mpi.o: include/x10rt_net.h include/x10rt_types.h -standalone/x10rt_standalone.o: include/x10rt_net.h include/x10rt_types.h -test/x10rt_basic.o: include/x10rt_front.h include/x10rt_types.h -test/x10rt_gups.o: include/x10rt_front.h include/x10rt_types.h -test/x10rt_topology.o: include/x10rt_front.h include/x10rt_types.h +common/x10rt_cuda.lo: include/x10rt_types.h common/x10rt_internal.h +common/x10rt_cuda.lo: include/x10rt_cuda.h +common/x10rt_front.lo: include/x10rt_front.h include/x10rt_types.h +common/x10rt_front.lo: include/x10rt_logical.h +common/x10rt_logical.lo: include/x10rt_logical.h include/x10rt_types.h +common/x10rt_logical.lo: include/x10rt_net.h include/x10rt_cuda.h +common/x10rt_logical.lo: common/x10rt_internal.h +mpi/x10rt_mpi.lo: include/x10rt_net.h include/x10rt_types.h +standalone/x10rt_standalone.lo: include/x10rt_net.h include/x10rt_types.h +test/x10rt_basic.lo: include/x10rt_front.h include/x10rt_types.h +test/x10rt_gups.lo: include/x10rt_front.h include/x10rt_types.h +test/x10rt_topology.lo: include/x10rt_front.h include/x10rt_types.h Modified: trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk 2010-01-31 03:15:57 UTC (rev 12781) +++ trunk/x10.runtime/src-cpp/x10rt/mpi/mpi.mk 2010-02-01 19:25:11 UTC (rev 12782) @@ -2,18 +2,18 @@ AR ?= ar -LIBS += lib/libx10rt_mpi.a +LIBS += lib/libx10rt_mpi.la PROPERTIES += etc/x10rt_mpi.properties -%.mpi: %.cc lib/libx10rt_mpi.a - $(MPICXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) -lx10rt_mpi +%.mpi: %.cc lib/libx10rt_mpi.la + libtool --mode=link --tag=CXX $(MPICXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) -lx10rt_mpi -mpi/x10rt_mpi.o: mpi/x10rt_mpi.cc - $(MPICXX) $(CXXFLAGS) -c $< -o $@ +mpi/x10rt_mpi.lo: mpi/x10rt_mpi.cc + libtool --mode=compile --tag=CXX $(MPICXX) $(CXXFLAGS) -c $< -o $@ -lib/libx10rt_mpi.a: mpi/x10rt_mpi.o $(COMMON_OBJS) - $(AR) $(ARFLAGS) $@ $^ +lib/libx10rt_mpi.la: mpi/x10rt_mpi.lo $(COMMON_OBJS) + libtool --mode=link --tag=CXX $(MPICXX) -o $@ $^ -rpath ${X10_HOME}/x10.dist/lib etc/x10rt_mpi.properties: @echo "CXX=$(MPICXX)" > $@ Modified: trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk 2010-01-31 03:15:57 UTC (rev 12781) +++ trunk/x10.runtime/src-cpp/x10rt/pgas/pgas.mk 2010-02-01 19:25:11 UTC (rev 12782) @@ -113,12 +113,12 @@ ifeq ($(PLATFORM_SUPPORTS_SOCKETS), yes) TESTS += $(patsubst test/%,test/%.pgas_sockets,$(BASE_TESTS)) -LIBS += lib/libx10rt_pgas_sockets.a +LIBS += lib/libx10rt_pgas_sockets.la PROPERTIES += etc/x10rt_pgas_sockets.properties EXECUTABLES += bin/launcher bin/manager bin/daemon -%.pgas_sockets: %.cc lib/libx10rt_pgas_sockets.a - $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) $(SOCKETS_LDFLAGS) $(SOCKETS_LDLIBS) +%.pgas_sockets: %.cc lib/libx10rt_pgas_sockets.la + libtool --mode=link $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) $(SOCKETS_LDFLAGS) $(SOCKETS_LDLIBS) ifdef CUSTOM_PGAS lib/libxlpgas_sockets.a: $(COMMON_OBJS) $(CUSTOM_PGAS)/lib/libxlpgas_sockets.a include/pgasrt.h @@ -133,9 +133,8 @@ $(GZIP) -cd $(SOCKETS_TGZ) | $(TAR) -xf - endif -lib/libx10rt_pgas_sockets.a: $(COMMON_OBJS) lib/libxlpgas_sockets.a - $(CP) lib/libxlpgas_sockets.a lib/libx10rt_pgas_sockets.a - $(AR) $(ARFLAGS) $@ $(COMMON_OBJS) +lib/libx10rt_pgas_sockets.la: $(COMMON_OBJS) lib/libxlpgas_sockets.a + libtool --mode=link $(CXX) -o $@ $(COMMON_OBJS) lib/libxlpgas_sockets.a -rpath ${X10_HOME}/x10.dist/lib etc/x10rt_pgas_sockets.properties: @echo "CXX=$(CXX)" > $@ @@ -157,11 +156,11 @@ HACK=$(shell echo "Your platform supports LAPI but we could not find the poe executable so not building LAPI tests">2) endif -LIBS += lib/libx10rt_pgas_lapi.a +LIBS += lib/libx10rt_pgas_lapi.la PROPERTIES += etc/x10rt_pgas_lapi.properties -%.pgas_lapi: %.cc lib/libx10rt_pgas_lapi.a - $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) $(LAPI_LDFLAGS) $(LAPI_LDLIBS) +%.pgas_lapi: %.cc lib/libx10rt_pgas_lapi.la + libtool --mode=link $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) $(LAPI_LDFLAGS) $(LAPI_LDLIBS) ifdef CUSTOM_PGAS lib/libxlpgas_lapi.a: $(COMMON_OBJS) $(CUSTOM_PGAS)/lib/libxlpgas_lapi.a include/pgasrt.h @@ -176,9 +175,8 @@ $(GZIP) -cd $(LAPI_TGZ) | $(TAR) -xf - endif -lib/libx10rt_pgas_lapi.a: $(COMMON_OBJS) lib/libxlpgas_lapi.a - $(CP) lib/libxlpgas_lapi.a lib/libx10rt_pgas_lapi.a - $(AR) $(ARFLAGS) $@ $(COMMON_OBJS) +lib/libx10rt_pgas_lapi.la: $(COMMON_OBJS) lib/libxlpgas_lapi.a + libtool --mode=link $(CXX) -o $@ $(COMMON_OBJS) lib/libxlpgas_lapi.a -rpath ${X10_HOME}/x10.dist/lib etc/x10rt_pgas_lapi.properties: echo "CXX=$(CXX)" > $@ @@ -196,10 +194,10 @@ ifeq ($(PLATFORM_SUPPORTS_BGP),yes) TESTS += $(patsubst test/%,test/%.pgas_bgp,$(BASE_TESTS)) -LIBS += lib/libx10rt_pgas_bgp.a +LIBS += lib/libx10rt_pgas_bgp.la PROPERTIES += etc/x10rt_pgas_bgp.properties -%.pgas_bgp: %.cc lib/libx10rt_pgas_bgp.a +%.pgas_bgp: %.cc lib/libx10rt_pgas_bgp.la $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) $(BGP_LDFLAGS) $(BGP_LDLIBS) ifdef CUSTOM_PGAS @@ -215,9 +213,8 @@ $(GZIP) -cd $(BGP_TGZ) | $(TAR) -xf - endif -lib/libx10rt_pgas_bgp.a: $(COMMON_OBJS) lib/libxlpgas_bgp.a - $(CP) lib/libxlpgas_bgp.a lib/libx10rt_pgas_bgp.a - $(AR) $(ARFLAGS) $@ $(COMMON_OBJS) +lib/libx10rt_pgas_bgp.la: $(COMMON_OBJS) lib/libxlpgas_bgp.a + libtool --mode=link $(CXX) -o $@ $(COMMON_OBJS) lib/libxlpgas_bgp.a -rpath ${X10_HOME}/x10.dist/lib etc/x10rt_pgas_bgp.properties: @echo "CXX=$(CXX)" > $@ Modified: trunk/x10.runtime/src-cpp/x10rt/standalone/standalone.mk =================================================================== --- trunk/x10.runtime/src-cpp/x10rt/standalone/standalone.mk 2010-01-31 03:15:57 UTC (rev 12781) +++ trunk/x10.runtime/src-cpp/x10rt/standalone/standalone.mk 2010-02-01 19:25:11 UTC (rev 12782) @@ -1,14 +1,14 @@ TESTS += $(patsubst test/%,test/%.standalone,$(BASE_TESTS)) -LIBS += lib/libx10rt_standalone.a +LIBS += lib/libx10rt_standalone.la PROPERTIES += etc/x10rt_standalone.properties -%.standalone: %.cc lib/libx10rt_standalone.a - $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) -lx10rt_standalone +%.standalone: %.cc lib/libx10rt_standalone.la + libtool --mode=link $(CXX) $(CXXFLAGS) $< -o $@ $(LDFLAGS) -lx10rt_standalone -lib/libx10rt_standalone.a: standalone/x10rt_standalone.o $(COMMON_OBJS) - $(AR) $(ARFLAGS) $@ $^ +lib/libx10rt_standalone.la: standalone/x10rt_standalone.lo $(COMMON_OBJS) + libtool --mode=link $(CXX) -o $@ $^ -rpath ${X10_HOME}/x10.dist/lib etc/x10rt_standalone.properties: @echo "CXX=$(CXX)" > $@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-02-18 02:47:49
|
Revision: 12931 http://x10.svn.sourceforge.net/x10/?rev=12931&view=rev Author: dgrove-oss Date: 2010-02-18 02:47:36 +0000 (Thu, 18 Feb 2010) Log Message: ----------- update file header comment in Makefiles Modified Paths: -------------- trunk/x10.runtime/Make.rules trunk/x10.runtime/x10rt/Makefile trunk/x10.runtime/x10rt/mpi/mpi.mk trunk/x10.runtime/x10rt/pgas/pgas.mk trunk/x10.runtime/x10rt/standalone/standalone.mk trunk/x10.tests/examples/Constructs/Extern/Makefile Modified: trunk/x10.runtime/Make.rules =================================================================== --- trunk/x10.runtime/Make.rules 2010-02-18 02:38:08 UTC (rev 12930) +++ trunk/x10.runtime/Make.rules 2010-02-18 02:47:36 UTC (rev 12931) @@ -1,3 +1,14 @@ +# +# This file is part of the X10 project (http://x10-lang.org). +# +# This file is licensed to You under the Eclipse Public License (EPL); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.opensource.org/licenses/eclipse-1.0.php +# +# (C) Copyright IBM Corporation 2006-2010. +# + ######################### # User-servicable Parts # ######################### Modified: trunk/x10.runtime/x10rt/Makefile =================================================================== --- trunk/x10.runtime/x10rt/Makefile 2010-02-18 02:38:08 UTC (rev 12930) +++ trunk/x10.runtime/x10rt/Makefile 2010-02-18 02:47:36 UTC (rev 12931) @@ -1,3 +1,14 @@ +# +# This file is part of the X10 project (http://x10-lang.org). +# +# This file is licensed to You under the Eclipse Public License (EPL); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.opensource.org/licenses/eclipse-1.0.php +# +# (C) Copyright IBM Corporation 2006-2010. +# + include ../Make.rules CP ?= cp -f Modified: trunk/x10.runtime/x10rt/mpi/mpi.mk =================================================================== --- trunk/x10.runtime/x10rt/mpi/mpi.mk 2010-02-18 02:38:08 UTC (rev 12930) +++ trunk/x10.runtime/x10rt/mpi/mpi.mk 2010-02-18 02:47:36 UTC (rev 12931) @@ -1,3 +1,14 @@ +# +# This file is part of the X10 project (http://x10-lang.org). +# +# This file is licensed to You under the Eclipse Public License (EPL); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.opensource.org/licenses/eclipse-1.0.php +# +# (C) Copyright IBM Corporation 2006-2010. +# + TESTS += $(patsubst test/%,test/%.mpi,$(BASE_TESTS)) MPI_DYNLIB = lib/$(LIBPREFIX)x10rt_mpi$(LIBSUFFIX) Modified: trunk/x10.runtime/x10rt/pgas/pgas.mk =================================================================== --- trunk/x10.runtime/x10rt/pgas/pgas.mk 2010-02-18 02:38:08 UTC (rev 12930) +++ trunk/x10.runtime/x10rt/pgas/pgas.mk 2010-02-18 02:47:36 UTC (rev 12931) @@ -1,3 +1,14 @@ +# +# This file is part of the X10 project (http://x10-lang.org). +# +# This file is licensed to You under the Eclipse Public License (EPL); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.opensource.org/licenses/eclipse-1.0.php +# +# (C) Copyright IBM Corporation 2006-2010. +# + X10_VERSION=svn head VERSION=20100205 SOCKETS_TGZ = pgas-$(VERSION)-$(WPLATFORM)-sockets.tgz Modified: trunk/x10.runtime/x10rt/standalone/standalone.mk =================================================================== --- trunk/x10.runtime/x10rt/standalone/standalone.mk 2010-02-18 02:38:08 UTC (rev 12930) +++ trunk/x10.runtime/x10rt/standalone/standalone.mk 2010-02-18 02:47:36 UTC (rev 12931) @@ -1,3 +1,14 @@ +# +# This file is part of the X10 project (http://x10-lang.org). +# +# This file is licensed to You under the Eclipse Public License (EPL); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.opensource.org/licenses/eclipse-1.0.php +# +# (C) Copyright IBM Corporation 2006-2010. +# + TESTS += $(patsubst test/%,test/%.standalone,$(BASE_TESTS)) STANDALONE_DYNLIB = lib/$(LIBPREFIX)x10rt_standalone$(LIBSUFFIX) Modified: trunk/x10.tests/examples/Constructs/Extern/Makefile =================================================================== --- trunk/x10.tests/examples/Constructs/Extern/Makefile 2010-02-18 02:38:08 UTC (rev 12930) +++ trunk/x10.tests/examples/Constructs/Extern/Makefile 2010-02-18 02:47:36 UTC (rev 12931) @@ -1,3 +1,14 @@ +# +# This file is part of the X10 project (http://x10-lang.org). +# +# This file is licensed to You under the Eclipse Public License (EPL); +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# http://www.opensource.org/licenses/eclipse-1.0.php +# +# (C) Copyright IBM Corporation 2006-2010. +# + # GNU Makefile for building X10 extern shared libraries. # This was tested on Windows/Cygwin, Linux, and AIX (with both gcc and xlC). # See implementation file headers for instructions on building the shared This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2010-02-23 09:06:24
|
Revision: 13012 http://x10.svn.sourceforge.net/x10/?rev=13012&view=rev Author: makinoy Date: 2010-02-23 09:06:16 +0000 (Tue, 23 Feb 2010) Log Message: ----------- Fix XTENLANG-1014. Add null check in conversion function. Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime/src-java/x10/rtt/Types.java Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-02-23 05:49:47 UTC (rev 13011) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-02-23 09:06:16 UTC (rev 13012) @@ -708,8 +708,7 @@ w.write(")"); w.write(")"); w.end(); - } else if (t instanceof ParameterType - && (X10TypeMixin.baseType(type) instanceof ParameterType || type.isNumeric() || type.isChar())) { + } else if (t instanceof ParameterType) { new Template(er, "cast_deptype_primitive_param", ex, expr, rt, "true").expand(); } else { new Template(er, template, ex, expr, rt, "true").expand(); Modified: trunk/x10.runtime/src-java/x10/rtt/Types.java =================================================================== --- trunk/x10.runtime/src-java/x10/rtt/Types.java 2010-02-23 05:49:47 UTC (rev 13011) +++ trunk/x10.runtime/src-java/x10/rtt/Types.java 2010-02-23 09:06:16 UTC (rev 13012) @@ -57,19 +57,25 @@ } public static Object conversion(Type rtt, Object primOrTypeParam) { - if (rtt == x10.rtt.Types.BYTE) { + if (rtt == BOOLEAN) { + if (primOrTypeParam == null) {throw new ClassCastException();} + } + if (rtt == BYTE) { + if (primOrTypeParam == null) {throw new ClassCastException();} if (primOrTypeParam instanceof java.lang.Number) return ((java.lang.Number) primOrTypeParam).byteValue(); if (primOrTypeParam instanceof java.lang.Byte) return primOrTypeParam; if (primOrTypeParam instanceof java.lang.Character) return (byte)((java.lang.Character) primOrTypeParam).charValue(); return primOrTypeParam; } - if (rtt == x10.rtt.Types.SHORT) { + if (rtt == SHORT) { + if (primOrTypeParam == null) {throw new ClassCastException();} if (primOrTypeParam instanceof java.lang.Number) return ((java.lang.Number) primOrTypeParam).shortValue(); if (primOrTypeParam instanceof java.lang.Short) return primOrTypeParam; if (primOrTypeParam instanceof java.lang.Character) return (short)((java.lang.Character) primOrTypeParam).charValue(); return primOrTypeParam; } - if (rtt == x10.rtt.Types.CHAR) { + if (rtt == CHAR) { + if (primOrTypeParam == null) {throw new ClassCastException();} if (primOrTypeParam instanceof java.lang.Byte) return (char)(byte)((java.lang.Byte) primOrTypeParam); if (primOrTypeParam instanceof java.lang.Short) return (char)(short)((java.lang.Short) primOrTypeParam); if (primOrTypeParam instanceof java.lang.Character) return primOrTypeParam; @@ -79,25 +85,29 @@ if (primOrTypeParam instanceof java.lang.Double) return (char)(double)((java.lang.Double) primOrTypeParam); return primOrTypeParam; } - if (rtt == x10.rtt.Types.INT) { + if (rtt == INT) { + if (primOrTypeParam == null) {throw new ClassCastException();} if (primOrTypeParam instanceof java.lang.Number) return ((java.lang.Number) primOrTypeParam).intValue(); if (primOrTypeParam instanceof java.lang.Character) return (int)((java.lang.Character) primOrTypeParam).charValue(); if (primOrTypeParam instanceof java.lang.Integer) return primOrTypeParam; return primOrTypeParam; } - if (rtt == x10.rtt.Types.LONG) { + if (rtt == LONG) { + if (primOrTypeParam == null) {throw new ClassCastException();} if (primOrTypeParam instanceof java.lang.Number) return ((java.lang.Number) primOrTypeParam).longValue(); if (primOrTypeParam instanceof java.lang.Character) return (long)((java.lang.Character) primOrTypeParam).charValue(); if (primOrTypeParam instanceof java.lang.Long) return primOrTypeParam; return primOrTypeParam; } - if (rtt == x10.rtt.Types.FLOAT) { + if (rtt == FLOAT) { + if (primOrTypeParam == null) {throw new ClassCastException();} if (primOrTypeParam instanceof java.lang.Number) return ((java.lang.Number) primOrTypeParam).floatValue(); if (primOrTypeParam instanceof java.lang.Character) return (float)((java.lang.Character) primOrTypeParam).charValue(); if (primOrTypeParam instanceof java.lang.Float) return primOrTypeParam; return primOrTypeParam; } - if (rtt == x10.rtt.Types.DOUBLE) { + if (rtt == DOUBLE) { + if (primOrTypeParam == null) {throw new ClassCastException();} if (primOrTypeParam instanceof java.lang.Number) return ((java.lang.Number) primOrTypeParam).doubleValue(); if (primOrTypeParam instanceof java.lang.Character) return (double)((java.lang.Character) primOrTypeParam).charValue(); if (primOrTypeParam instanceof java.lang.Double) return primOrTypeParam; @@ -105,10 +115,22 @@ } // unimplemented - if (rtt == x10.rtt.Types.UBYTE) {return primOrTypeParam;} - if (rtt == x10.rtt.Types.USHORT) {return primOrTypeParam;} - if (rtt == x10.rtt.Types.UINT) {return primOrTypeParam;} - if (rtt == x10.rtt.Types.ULONG) {return primOrTypeParam;} + if (rtt == UBYTE) { + if (primOrTypeParam == null) {throw new ClassCastException();} + return primOrTypeParam; + } + if (rtt == USHORT) { + if (primOrTypeParam == null) {throw new ClassCastException();} + return primOrTypeParam; + } + if (rtt == UINT) { + if (primOrTypeParam == null) {throw new ClassCastException();} + return primOrTypeParam; + } + if (rtt == ULONG) { + if (primOrTypeParam == null) {throw new ClassCastException();} + return primOrTypeParam; + } return primOrTypeParam; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2010-07-31 16:59:12
|
Revision: 15295 http://x10.svn.sourceforge.net/x10/?rev=15295&view=rev Author: alpern Date: 2010-07-31 16:59:06 +0000 (Sat, 31 Jul 2010) Log Message: ----------- Added support for an @InlineOnly annotation on method declarations. Calls to such methods are inlined but the declaration itself is ignored. Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/Inliner.java Added Paths: ----------- trunk/x10.runtime/src-x10/x10/compiler/InlineOnly.x10 Modified: trunk/x10.compiler/src/x10/visit/Inliner.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Inliner.java 2010-07-31 16:18:28 UTC (rev 15294) +++ trunk/x10.compiler/src/x10/visit/Inliner.java 2010-07-31 16:59:06 UTC (rev 15295) @@ -33,6 +33,7 @@ import polyglot.ast.Formal; import polyglot.ast.Local; import polyglot.ast.LocalDecl; +import polyglot.ast.MethodDecl; import polyglot.ast.Node; import polyglot.ast.NodeFactory; import polyglot.ast.Return; @@ -80,6 +81,7 @@ import x10.types.ParameterType; import x10.types.X10ClassDef; import x10.types.X10ClassType; +import x10.types.X10Def; import x10.types.X10MethodDef; import x10.types.X10MethodInstance; import x10.types.X10TypeMixin; @@ -115,13 +117,15 @@ /** * Names of the annotation classes that govern inlining. */ - private static final QName INLINE_ANNOTATION = QName.make("x10.compiler.Inline"); - private static final QName NO_INLINE_ANNOTATION = QName.make("x10.compiler.NoInline"); + private static final QName INLINE_ANNOTATION = QName.make("x10.compiler.Inline"); + private static final QName INLINE_ONLY_ANNOTATION = QName.make("x10.compiler.InlineOnly"); + private static final QName NO_INLINE_ANNOTATION = QName.make("x10.compiler.NoInline"); /** * The cached type of the @Inline and @NoInline annotations. */ private Type InlineType; + private Type InlineOnlyType; private Type NoInlineType; /** @@ -169,19 +173,26 @@ public NodeVisitor begin() { recursionDepth[0] = INITIAL_RECURSION_DEPTH; try { - NoInlineType = (Type) ts.systemResolver().find(NO_INLINE_ANNOTATION); + InlineType = (Type) ts.systemResolver().find(INLINE_ANNOTATION); } catch (SemanticException e) { - System.out.println("Unable to find " +NO_INLINE_ANNOTATION+ ": "+e); - NoInlineType = null; + System.out.println("Unable to find " +INLINE_ANNOTATION+ ": "+e); + InlineType = null; } try { - InlineType = (Type) ts.systemResolver().find(INLINE_ANNOTATION); + InlineOnlyType = (Type) ts.systemResolver().find(INLINE_ONLY_ANNOTATION); } catch (SemanticException e) { - System.out.println("Unable to find " +INLINE_ANNOTATION+ ": "+e); - InlineType = null; + System.out.println("Unable to find " +INLINE_ONLY_ANNOTATION+ ": "+e); + InlineOnlyType = null; } + try { + NoInlineType = (Type) ts.systemResolver().find(NO_INLINE_ANNOTATION); + } + catch (SemanticException e) { + System.out.println("Unable to find " +NO_INLINE_ANNOTATION+ ": "+e); + NoInlineType = null; + } return super.begin(); } @@ -189,9 +200,21 @@ if (!ALLOW_STMTEXPR) return n; // FIXME: for now if (n instanceof X10Call) return inlineMethodCall((X10Call_c) n); if (n instanceof ClosureCall) return inlineClosureCall((ClosureCall) n); + if (n instanceof X10MethodDecl) + return nonInlineOnlyMethods((X10MethodDecl) n); return n; } + /** + * @param n + * @return + */ + private Node nonInlineOnlyMethods(X10MethodDecl method) { + if (((X10MethodDef) method.methodDef()).annotationsMatching(InlineOnlyType).isEmpty()) + return method; + return null; + } + private Expr inlineMethodCall(X10Call_c c) { if (null == InlineType) return c; try { @@ -522,6 +545,7 @@ f = (Field) f.targetImplicit(false); } return f.typeCheck(this); // TODO: eliminate typeCheck (allow access to private fields) + // return f; // could this work? looks like not! } else if (ie instanceof Local) { LocalDef ld = vars.get(((Local) ie).name().id()); if (ld != null) { Added: trunk/x10.runtime/src-x10/x10/compiler/InlineOnly.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/InlineOnly.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/compiler/InlineOnly.x10 2010-07-31 16:59:06 UTC (rev 15295) @@ -0,0 +1,4 @@ +package x10.compiler; + +public interface InlineOnly extends Inline { +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <awt...@us...> - 2010-09-01 17:28:28
|
Revision: 15950 http://x10.svn.sourceforge.net/x10/?rev=15950&view=rev Author: awtaylor Date: 2010-09-01 17:28:21 +0000 (Wed, 01 Sep 2010) Log Message: ----------- Fixes common usages of @see and @link tags within xdoc Modified Paths: -------------- trunk/x10.doc/src/x10doc/doc/X10ClassDoc.java trunk/x10.doc/src/x10doc/doc/X10Doc.java trunk/x10.doc/src/x10doc/doc/X10MethodDoc.java trunk/x10.doc/src/x10doc/doc/X10ParamTag.java trunk/x10.doc/src/x10doc/doc/X10RootDoc.java trunk/x10.doc/src/x10doc/doc/X10SeeTag.java trunk/x10.doc/src/x10doc/visit/X10DocGenerator.java Added Paths: ----------- trunk/x10.compiler/src/x10/util/HierarchyUtils.java Added: trunk/x10.compiler/src/x10/util/HierarchyUtils.java =================================================================== --- trunk/x10.compiler/src/x10/util/HierarchyUtils.java (rev 0) +++ trunk/x10.compiler/src/x10/util/HierarchyUtils.java 2010-09-01 17:28:21 UTC (rev 15950) @@ -0,0 +1,107 @@ +package x10.util; + +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.Set; + +import polyglot.types.ClassType; +import polyglot.types.Flags; +import polyglot.types.MethodInstance; +import polyglot.types.Type; + +public class HierarchyUtils { + + public static Set<ClassType> getSuperTypes(ClassType startingClass) + { + Set<ClassType> superTypes = new LinkedHashSet<ClassType>(); + ClassType previousType = startingClass; + ClassType superType = (ClassType)startingClass.superClass(); + + while(superType != null) + { + superTypes.add(superType); + addInterfaces(previousType, superTypes); + previousType = superType; + superType = (ClassType)superType.superClass(); + } + + addInterfaces(previousType, superTypes); + + return superTypes; + } + + public static Set<ClassType> getSuperClasses(ClassType startingClass) + { + Set<ClassType> superTypes = new HashSet<ClassType>(); + ClassType superType = (ClassType)startingClass.superClass(); + + while(superType != null) + { + superTypes.add(superType); + superType = (ClassType)superType.superClass(); + } + + return superTypes; + } + + private static void addInterfaces(ClassType startingClass, Set<ClassType> interfaces) + { + for(Type type : startingClass.interfaces()) + { + interfaces.add((ClassType)type); + addInterfaces((ClassType)type, interfaces); + } + } + + public static Set<ClassType> getInterfaces(Set<ClassType> classes) + { + Set<ClassType> interfaces = new HashSet<ClassType>(); + for(ClassType ct : classes) + { + addInterfaces(ct, interfaces); + } + + return interfaces; + } + + public static Set<MethodInstance> getMethods(Set<ClassType> classes) + { + return getMethods(classes, Flags.NONE); + } + + public static Set<MethodInstance> getMethods(Set<ClassType> classes, Flags flags) + { + Set<MethodInstance> methods = new HashSet<MethodInstance>(); + for(ClassType ct : classes) + { + for(MethodInstance mi : ct.methods()) + { + if(mi.flags().contains(flags)) + { + methods.add(mi); + } + } + } + + return methods; + } + + public static Set<MethodInstance> getImplementedMethods(Set<ClassType> classes) + { + Set<MethodInstance> methods = new HashSet<MethodInstance>(); + for(ClassType ct : classes) + { + for(MethodInstance mi : ct.methods()) + { + if(!mi.flags().isAbstract()) + { + methods.add(mi); + } + } + } + + return methods; + } + + +} Modified: trunk/x10.doc/src/x10doc/doc/X10ClassDoc.java =================================================================== --- trunk/x10.doc/src/x10doc/doc/X10ClassDoc.java 2010-09-01 17:26:32 UTC (rev 15949) +++ trunk/x10.doc/src/x10doc/doc/X10ClassDoc.java 2010-09-01 17:28:21 UTC (rev 15950) @@ -5,11 +5,13 @@ import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; +import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; import polyglot.types.ClassType; import polyglot.types.Ref; +import x10.ast.X10SourceFile_c; import x10.types.ParameterType; import x10.types.TypeDef; import x10.types.X10ClassDef; @@ -37,6 +39,7 @@ import com.sun.javadoc.WildcardType; public class X10ClassDoc extends X10Doc implements ClassDoc { + X10SourceFile_c source; X10ClassDef classDef; X10ClassDoc containingClass; X10ClassDoc superclass; @@ -85,14 +88,21 @@ if (doc.name().equals(name)) return doc; } - String shortname = ""; - String signature = ""; + String shortname = name; + String signature = "()"; int index = name.indexOf("("); if (index != -1) { shortname = name.substring(0,name.indexOf("(")); signature = name.substring(index); signature = makeQualifiedParams(signature); } + + index = shortname.indexOf("["); + if(index != -1) + { + shortname = shortname.substring(0, index); + } + for(X10ConstructorDoc doc: constructors.values()){ if (doc.name().equals(shortname) && doc.signature().equals(signature)){ @@ -110,19 +120,38 @@ return null; } - private String makeQualifiedParams(String signature){ - String sig= "("; - Pattern p = Pattern.compile("[^,)]*"); - Matcher m = p.matcher(signature.substring(1)); - while(m.find()){ - String s = m.group(); - if (s.equals("")) continue; //Hack - if (!s.contains(".")) - s = "x10.lang." + s; - if (sig.equals("(")) sig += s; else sig += ", " + s; + private String makeQualifiedParams(String signature) { + String sig = ""; + String delim = "(),>"; + StringTokenizer tok = new StringTokenizer(signature, delim, true); + while (tok.hasMoreTokens()) { + String token = tok.nextToken(); + if (delim.contains(token)) { + sig += token; + if (token.equals(">")) { + sig += " "; + } + } + + else { + token = token.trim(); + if (token.length() > 0) { + X10ClassDoc doc = X10RootDoc.getRootDoc().findClass(this, + token.trim()); + if (doc != null) { + sig += doc.qualifiedName(); + } + + else { + sig += token; + } + } + } } - return sig + ")"; + + return sig; } + public void setSuperclass(X10ClassDoc superclass) { this.superclass = superclass; } @@ -374,6 +403,11 @@ public static String typeParameterKey(ParameterType p) { return p.name().toString(); } + + public void setSource(X10SourceFile_c source) + { + this.source = source; + } public X10FieldDoc updateField(X10FieldDef fdef, String comments) { X10FieldDoc fd = getField(fdef); @@ -627,6 +661,7 @@ // TODO Auto-generated method stub if (X10RootDoc.printSwitch) System.out.println("ClassDoc.importedClasses() called for "+name()); + return new ClassDoc[0]; } Modified: trunk/x10.doc/src/x10doc/doc/X10Doc.java =================================================================== --- trunk/x10.doc/src/x10doc/doc/X10Doc.java 2010-09-01 17:26:32 UTC (rev 15949) +++ trunk/x10.doc/src/x10doc/doc/X10Doc.java 2010-09-01 17:28:21 UTC (rev 15950) @@ -22,6 +22,7 @@ X10Tag[] firstSentenceTags, inlineTags; List<Tag> blockTags = new ArrayList<Tag>(); List<Tag> paramTags = new ArrayList<Tag>(); + List<SeeTag> seeTags = new ArrayList<SeeTag>(); public void processComment(String rawComment) { this.rawComment = rawComment; @@ -121,29 +122,37 @@ } - private void processBlockTag(String tagText){ + private void processBlockTag(String tagText) { String kind = null; String text = null; Pattern p = Pattern.compile("@[^\\s]*"); Matcher m = p.matcher(tagText); - if (m.find()){ + if (m.find()) { kind = m.group().substring(1); text = tagText.substring(m.end()).trim(); } - if (kind.equals(X10Tag.PARAM)){ - - + if (kind.equals(X10Tag.PARAM)) { Pattern p1 = Pattern.compile("[^\\s]*"); Matcher m1 = p1.matcher(text); - if (m1.find()){ + if (m1.find()) { String name = m1.group(); String paramComment = text.substring(m1.end()).trim(); - X10Tag[] inTags = createInlineTags(paramComment, this).toArray(new X10Tag[0]); - X10ParamTag t = new X10ParamTag(false, name, inTags, paramComment, text , this); + X10Tag[] inTags = createInlineTags(paramComment, this).toArray( + new X10Tag[0]); + X10ParamTag t = new X10ParamTag(false, name, inTags, + paramComment, text, this); blockTags.add(t); paramTags.add(t); } - } else { + + } + + else if (kind.equals("see") || kind.equals("link") + || kind.equals("linkplain")) { + seeTags.add(new X10SeeTag("@" + kind, text, text, this)); + } + + else { blockTags.add(new X10Tag(kind, text, this)); } } @@ -272,7 +281,7 @@ */ public Tag[] inlineTags() { if (X10RootDoc.printSwitch) - System.out.println("Doc.inlineTags() called for "+name()); + System.out.println("Doc.inlineTags() called for " + name()); return inlineTags; } @@ -348,7 +357,8 @@ public SeeTag[] seeTags() { if (X10RootDoc.printSwitch) System.out.println("Doc.seeTags() called for "+name()); - return new SeeTag[0]; + + return seeTags.toArray(new SeeTag[seeTags.size()]); } public void setRawCommentText(String arg0) { @@ -364,11 +374,13 @@ public Tag[] tags() { if (X10RootDoc.printSwitch) System.out.println("Doc.tags() called for "+name()); - Tag[] result = new Tag[blockTags.size() + inlineTags.length]; + Tag[] result = new Tag[blockTags.size() + seeTags.size() + inlineTags.length]; if (blockTags.size() > 0) System.arraycopy(blockTags.toArray(new Tag[0]), 0, result, 0, blockTags.size()); + if (seeTags.size() > 0) + System.arraycopy(seeTags.toArray(new Tag[0]), 0, result, blockTags.size(), seeTags.size()); if (inlineTags.length > 0) - System.arraycopy(inlineTags, 0, result, blockTags.size(), inlineTags.length); + System.arraycopy(inlineTags, 0, result, blockTags.size() + seeTags.size(), inlineTags.length); return result; //return inlineTags(); } @@ -436,7 +448,7 @@ //flagsToHex.put(Flags.STRICTFP.toString(), 0x0800); } - public static int flagsToModifierSpecifier(Set flags) { + public static int flagsToModifierSpecifier(Set<Object> flags) { int r = 0; for (Object flag : flags) { // flag could be "property" which is not in flagsToHex (and not recognized by Modified: trunk/x10.doc/src/x10doc/doc/X10MethodDoc.java =================================================================== --- trunk/x10.doc/src/x10doc/doc/X10MethodDoc.java 2010-09-01 17:26:32 UTC (rev 15949) +++ trunk/x10.doc/src/x10doc/doc/X10MethodDoc.java 2010-09-01 17:28:21 UTC (rev 15950) @@ -187,7 +187,20 @@ public String name() { if (X10RootDoc.printSwitch) System.out.println(methodDef.name() + ".name() called."); - return methodDef.name().toString(); + + String name = methodDef.name().toString(); +// if(methodDef.typeParameters().size() > 0) +// { +// String types = ""; +// for(Ref<? extends polyglot.types.Type> type : methodDef.typeParameters()) +// { +// types += type.toString() + ","; +// } +// +// return name + "[" + types.substring(0, types.length() - 1) + "]"; +// } + + return name; } public ClassDoc overriddenClass() { @@ -256,9 +269,7 @@ // System.out.println(name() + ".paramTags() called."); return paramTags.toArray(new ParamTag[0]); } - - public Parameter[] parameters() { // System.out.println(name() + ".parameters() called."); return parameters.toArray(new Parameter[0]); @@ -273,6 +284,10 @@ public static String signature(X10MethodDef md) { String sig = md.signature(); + sig = sig.replaceAll("[^(:,]+:", ""); + sig = sig.replaceAll("\\{[^}]+\\}", ""); + //sig = sig.replaceAll("\\$[^,)]*", ""); + return sig.substring(sig.indexOf('(')); } Modified: trunk/x10.doc/src/x10doc/doc/X10ParamTag.java =================================================================== --- trunk/x10.doc/src/x10doc/doc/X10ParamTag.java 2010-09-01 17:26:32 UTC (rev 15949) +++ trunk/x10.doc/src/x10doc/doc/X10ParamTag.java 2010-09-01 17:28:21 UTC (rev 15950) @@ -1,9 +1,7 @@ package x10doc.doc; -import com.sun.javadoc.Doc; import com.sun.javadoc.ParamTag; import com.sun.javadoc.Tag; -import com.sun.tools.doclets.formats.html.HtmlDocletWriter; public class X10ParamTag extends X10Tag implements ParamTag { private boolean isTypeParameter; @@ -32,9 +30,4 @@ public Tag[] inlineTags(){ return inTags; } - - - - - } Modified: trunk/x10.doc/src/x10doc/doc/X10RootDoc.java =================================================================== --- trunk/x10.doc/src/x10doc/doc/X10RootDoc.java 2010-09-01 17:26:32 UTC (rev 15949) +++ trunk/x10.doc/src/x10doc/doc/X10RootDoc.java 2010-09-01 17:28:21 UTC (rev 15950) @@ -1,14 +1,12 @@ package x10doc.doc; -import java.io.File; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; -import polyglot.frontend.Job; +import polyglot.ast.Import; import polyglot.types.ClassDef; import polyglot.types.ClassType; import polyglot.types.ConstructorDef; @@ -16,13 +14,11 @@ import polyglot.types.MethodDef; import polyglot.types.Package; import polyglot.types.Ref; +import x10.types.ConstrainedType; import x10.types.FunctionType; -import x10.types.ConstrainedType; import x10.types.ParameterType; -import x10.types.ParametrizedType; import x10.types.TypeDef; import x10.types.X10ClassDef; -import x10.types.X10ClassType; import x10.types.X10ConstructorDef; import x10.types.X10Def; import x10.types.X10FieldDef; @@ -30,17 +26,14 @@ import x10.types.X10ParsedClassType; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.util.HierarchyUtils; import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ConstructorDoc; import com.sun.javadoc.Doc; -import com.sun.javadoc.MethodDoc; +import com.sun.javadoc.MemberDoc; import com.sun.javadoc.PackageDoc; -import com.sun.javadoc.ProgramElementDoc; import com.sun.javadoc.RootDoc; -import com.sun.javadoc.SeeTag; import com.sun.javadoc.SourcePosition; -import com.sun.javadoc.Tag; import com.sun.javadoc.Type; public class X10RootDoc extends X10Doc implements RootDoc { @@ -567,4 +560,119 @@ // return cd; // } // } + + public X10ClassDoc findClass(X10Doc holder, String classname) + { + /* + 1. the current class or interface + 2. any enclosing classes and interfaces, searching closest first + 3. any superclasses and superinterfaces, searching closest first + 4. the current package + 5. any imported packages, classes and interfaces, searching in the order of the import statement + */ + + X10ClassDoc classDoc = null; + + // check current class + classDoc = findInCurrentClass(holder, classname); + if(classDoc != null) + { + return classDoc; + } + + // check superclasses and superinterfaces + classDoc = findInEnclosingAndSuperClasses(holder, classname); + if(classDoc != null) + { + return classDoc; + } + + //check current package + classDoc = findInCurrentPackage(holder, classname); + if(classDoc != null) + { + return classDoc; + } + + //check imported + classDoc = findInImports(holder, classname); + if(classDoc != null) + { + return classDoc; + } + + return classDoc; + } + + private X10ClassDoc findInCurrentClass(X10Doc holder, String startingName) { + String newClassName = holderClass(holder).classDef.fullName().toString() + + "." + startingName; + X10ClassDoc classDoc = (X10ClassDoc) this.classNamed(newClassName); + return classDoc; + } + + private X10ClassDoc findInEnclosingAndSuperClasses(X10Doc holder, String startingName) + { + ClassType ct = holderClass(holder).classDef.asType(); + for(ClassType superType : HierarchyUtils.getSuperTypes(ct)) + { + String superName = superType.fullName().toString(); + X10ClassDoc classDoc = null; + if((classDoc = isName(superName, startingName)) != null) + { + return classDoc; + } + } + + return null; + } + + private X10ClassDoc findInCurrentPackage(X10Doc holder, String startingName) + { + String newClassName = holderClass(holder).classDef.package_().toString() + "." + startingName; + X10ClassDoc classDoc = (X10ClassDoc) this.classNamed(newClassName); + return classDoc; + } + + private X10ClassDoc findInImports(X10Doc holder, String startingName) { + X10ClassDoc classDoc = null; + if (holderClass(holder).source != null) { + for (Import i : holderClass(holder).source.imports()) { + + if ((classDoc = isName(i.name().toString(), startingName)) != null) { + return classDoc; + } + } + } + + String lang = "x10.lang." + startingName; + classDoc = (X10ClassDoc) this.classNamed(lang); + return classDoc; + } + + private X10ClassDoc isName(String fullName, String inputName) + { + if(fullName.endsWith(inputName)) + { + X10ClassDoc classDoc = (X10ClassDoc) this.classNamed(fullName); + if(classDoc != null) + { + return classDoc; + } + } + + return null; + } + + public X10ClassDoc holderClass(X10Doc holder) { + if (holder instanceof X10ClassDoc) { + return ((X10ClassDoc) holder); + } + else if (holder instanceof MemberDoc) { + return ((X10ClassDoc) ((MemberDoc) holder).containingClass()); + } + else { + return null; + } + } } Modified: trunk/x10.doc/src/x10doc/doc/X10SeeTag.java =================================================================== --- trunk/x10.doc/src/x10doc/doc/X10SeeTag.java 2010-09-01 17:26:32 UTC (rev 15949) +++ trunk/x10.doc/src/x10doc/doc/X10SeeTag.java 2010-09-01 17:28:21 UTC (rev 15950) @@ -1,11 +1,9 @@ package x10doc.doc; -import java.text.BreakIterator; import java.util.regex.Matcher; import java.util.regex.Pattern; import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.Doc; import com.sun.javadoc.MemberDoc; import com.sun.javadoc.PackageDoc; import com.sun.javadoc.SeeTag; @@ -17,11 +15,12 @@ PackageDoc pkgDoc; X10ClassDoc classDoc; MemberDoc memberDoc; + boolean beenCalled; public X10SeeTag(String name, String label, String text, X10Doc holder) { super(name, text, holder); rootDoc = X10RootDoc.getRootDoc(); - processText(label); +// processText(label); // pkgDoc = null; // classDoc = null; // memberDoc = null; @@ -40,40 +39,57 @@ // } } - private void processText(String text){ + void processText() { + beenCalled = true; + String text = label; int index = text.indexOf("#"); String classname = null; String member = null; if (index == -1) { classname = text; } else { - classname = text.substring(0,index); - if (classDoc != null) { - member = text.substring(index+1); - memberDoc = classDoc.getMemberDoc(member); - } + classname = text.substring(0, index); + if(classname.endsWith("]")) + { + classname = classname.substring(0, classname.indexOf("[")); + } + + member = text.substring(index + 1); } if (classname.equals("")) { classname = X10RootDoc.getContainingClass(holder); } + classDoc = (X10ClassDoc) rootDoc.classNamed(classname); + if (classDoc == null) { + classDoc = rootDoc.findClass(holder, classname); + } + + if (classDoc == null) { + classname = X10RootDoc.getContainingClass(holder); + classDoc = (X10ClassDoc) rootDoc.classNamed(classname); + member = text; + } + + else + { + classname = classDoc.qualifiedName(); + } + + if (member != null && classDoc != null) { + memberDoc = classDoc.getMemberDoc(member); + } + index = classname.lastIndexOf("."); if (index != -1) { - String pkgname = classname.substring(0,index); + String pkgname = classname.substring(0, index); pkgDoc = rootDoc.packageNamed(pkgname); } - } - - public X10ClassDoc holderClass() { - if (holder instanceof X10ClassDoc) { - return ((X10ClassDoc) holder); + + if(label.startsWith("#")) + { + label = label.substring(1); } - else if (holder instanceof MemberDoc) { - return ((X10ClassDoc) ((MemberDoc) holder).containingClass()); - } - else { - return null; - } } public void processLinkTag(String text) { @@ -141,12 +157,12 @@ cd = (X10ClassDoc) rootDoc.classNamed(className); } else if (g5 != null) { // null package name, and non-null class name - pkgName = holderClass().containingPackage().name(); + pkgName = rootDoc.holderClass(holder).containingPackage().name(); className = pkgName + "." + g5; // g5 is a class in the holding class's package cd = (X10ClassDoc) rootDoc.classNamed(className); } else { // null package name, null class name - cd = holderClass(); // g6 is a member of the current class + cd = rootDoc.holderClass(holder); // g6 is a member of the current class } if (g7 == null) { // null list of parameters memberDoc = cd.getField(g6); @@ -200,18 +216,27 @@ } public String label() { + if(classDoc == null) + { + processText(); + } return label; } public ClassDoc referencedClass() { - // ClassDoc cd = X10RootDoc.getRootDoc().classNamed(itemName); - // return cd; return classDoc; } public String referencedClassName() { - // return itemName; - return ((classDoc == null) ? null : classDoc.qualifiedName()); + if(classDoc != null) + { + return classDoc.qualifiedName(); + } + if(pkgDoc != null) + { + return pkgDoc.name(); + } + return null; } public MemberDoc referencedMember() { @@ -224,7 +249,11 @@ } public PackageDoc referencedPackage() { - // PackageDoc p = referencedClass().containingPackage(); + if(classDoc != null || memberDoc != null) + { + return null; + } + return pkgDoc; } } Modified: trunk/x10.doc/src/x10doc/visit/X10DocGenerator.java =================================================================== --- trunk/x10.doc/src/x10doc/visit/X10DocGenerator.java 2010-09-01 17:26:32 UTC (rev 15949) +++ trunk/x10.doc/src/x10doc/visit/X10DocGenerator.java 2010-09-01 17:28:21 UTC (rev 15950) @@ -3,36 +3,25 @@ import java.io.IOException; import java.util.Stack; -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.PackageDoc; -import com.sun.javadoc.RootDoc; - import lpg.runtime.IToken; import polyglot.ast.ClassMember; -import polyglot.ast.Formal; import polyglot.ast.Node; import polyglot.ast.SourceFile_c; import polyglot.ast.TopLevelDecl; -import polyglot.ast.TypeNode; import polyglot.frontend.FileSource; import polyglot.frontend.Job; import polyglot.types.FieldDef; -import polyglot.types.MethodDef; -import polyglot.types.Package; -import polyglot.types.Ref; -import polyglot.types.Type; import polyglot.util.SilentErrorQueue; import x10.ast.PropertyDecl; import x10.ast.PropertyDecl_c; import x10.ast.TypeDecl_c; -import x10.ast.TypeParamNode; import x10.ast.X10ClassDecl_c; import x10.ast.X10ConstructorDecl_c; import x10.ast.X10FieldDecl_c; import x10.ast.X10MethodDecl_c; +import x10.ast.X10SourceFile_c; import x10.extension.X10Ext; import x10.parser.X10Parser; -import x10.types.ParameterType; import x10.types.TypeDef; import x10.types.X10ClassDef; import x10.types.X10ConstructorDef; @@ -41,11 +30,6 @@ import x10.visit.X10DelegatingVisitor; import x10doc.ExtensionInfo; import x10doc.doc.X10ClassDoc; -import x10doc.doc.X10ConstructorDoc; -import x10doc.doc.X10Doc; -import x10doc.doc.X10FieldDoc; -import x10doc.doc.X10MethodDoc; -import x10doc.doc.X10PackageDoc; import x10doc.doc.X10RootDoc; public class X10DocGenerator extends X10DelegatingVisitor { @@ -54,6 +38,7 @@ private X10Parser parser; private X10RootDoc rootDoc; private Stack<X10ClassDoc> stack; + private X10SourceFile_c source; // stack of X10ClassDoc objects created as X10ClassDecl_c objects are visited; the // X10ClassDecl_c objects visited included top level class declarations and inner classes; // when a Doc object is created for a class member, it is added as a member of the top @@ -72,6 +57,7 @@ public void visit(SourceFile_c n) { assert (job.source() instanceof FileSource); FileSource source = (FileSource) job.source(); + this.source = (X10SourceFile_c)n; try { this.parser = (X10Parser) job.extensionInfo().parser(source.open(), source, new SilentErrorQueue(0, "Ignored")); } catch (IOException e) { @@ -145,6 +131,7 @@ // the class is included in the "specified set" if it is specified on the command line // or it is an inner class of an included class X10ClassDoc cd = rootDoc.getSpecCLass(classDef, containingClass, comments); + cd.setSource(source); // all classes, including inner classes are added to rootDoc // for (TypeNode i: n.interfaces()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-09-10 21:28:28
|
Revision: 16304 http://x10.svn.sourceforge.net/x10/?rev=16304&view=rev Author: dgrove-oss Date: 2010-09-10 21:28:20 +0000 (Fri, 10 Sep 2010) Log Message: ----------- Major redesign of arraycopy APIs for the 2.1 object model. In addition to various documentation fixes, three main changes in the API. (1) switch to using static methods with consistent argument order that match that of Java's System.arraycopy. All copy methods on Array now take a specification of a source, followed by a specification of a destination, followed by a specification of the number of elements to be copied. This was enabled by the object model changes that made Array and RemoteArray into distinct types. (2) Based on user-feedback, be much more flexible on the kinds of copies that can be specified. In particular, the API no longer insists that the source and destination of a copy operation have equal Regions or even equal ranks. The only requirement is that the specified copying operation is not allowed to access beyond the bounds of the backing storage of the source/destination arrays. There are three variants of specifying the copied range of points. (a) a shorthand for copying all the data from one Array to another that can be used anytime the source and destination arrays have equal size bounding boxes. In this case only the two arrays are required as arguments. (b) Copy k elements from the source array to the destination array, where the first element in the source/destination array to be copied/written is specified by giving a Point from the source/destination array's region. (b) Copy k elements from the source array to the destination array, where the first element in the source/destination array to be copied/written is specified by giving an int which is in the range of 0..src/dst.region.size-1 which is interpreted as the index of a point in the lexograpical ordering of all points in the src/dst array's region. Note that in the case of arrays with the rail property, this exactly matches the arguments that would be used for the equivalent call to System.arraycopy in Java. (3) Added synchronous copy functions that cover APIs (a), (b) and (c) above for single place copying (both arrays in the current place). Modified Paths: -------------- trunk/x10.runtime/src-x10/x10/array/Array.x10 trunk/x10.runtime/src-x10/x10/array/EmptyRegion.x10 trunk/x10.runtime/src-x10/x10/array/FullRegion.x10 trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 trunk/x10.runtime/src-x10/x10/array/Region.x10 trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk.x10 trunk/x10.tests/examples/Constructs/Array/ArrayCopyTo.x10 Modified: trunk/x10.runtime/src-x10/x10/array/Array.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/Array.x10 2010-09-10 17:46:41 UTC (rev 16303) +++ trunk/x10.runtime/src-x10/x10/array/Array.x10 2010-09-10 21:28:20 UTC (rev 16304) @@ -653,32 +653,37 @@ /** - * Asynchronously copy all of the values from this Array to the - * backing storage of the Array referenced by the RemoteArray. + * Asynchronously copy all of the values from the source Array to the + * Array referenced by the destination RemoteArray. * The two arrays must be defined over Regions with equal size * bounding boxes; if the backing storage for the two arrays is - * not of equal size, then an IllegalArgumentExeption will be raised. + * not of equal size, then an IllegalArgumentExeption will be raised.<p> * + * The activity created to do the copying will be registered with the + * dynamically enclosing finish.<p> + * * Warning: This method is only intended to be used on Arrays containing * non-Object data elements. The elements are actually copied via an * optimized DMA operation if available. Therefore object-references will * not be properly transferred. Ideally, future versions of the X10 type * system would enable this restriction to be checked statically.</p> * - * @param dst the destination array. May actually be local or remote + * @param src the source array. + * @param dst the destination array. * @throws IllegalArgumentException if mismatch in size of backing storage - * of the two arrays. + * of the two arrays. */ - public def asyncCopyTo(dst:RemoteArray[T]) { - asyncCopyTo(dst, false); + public static def asyncCopy[T](src:Array[T], dst:RemoteArray[T]) { + asyncCopy(src, dst, false); } + /** - * Asynchronously copy all of the values from this Array to the - * backing storage of the Array referenced by the RemoteArray. + * Asynchronously copy all of the values from the source Array to the + * Array referenced by the destination RemoteArray. * The two arrays must be defined over Regions with equal size * bounding boxes; if the backing storage for the two arrays is - * not of equal size, then an IllegalArgumentExeption will be raised. + * not of equal size, then an IllegalArgumentExeption will be raised.<p> * * Depending on the value of the uncounted parameter, the activity performing * the copy will either be registered with the dynamically enclosing finish or @@ -690,44 +695,212 @@ * not be properly transferred. Ideally, future versions of the X10 type * system would enable this restriction to be checked statically.</p> * + * @param src the source array. * @param dst the destination array. May actually be local or remote * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted * @throws IllegalArgumentException if mismatch in size of backing storage * of the two arrays. */ - public def asyncCopyTo(dst:RemoteArray[T], uncounted:boolean) { - if (rawLength != dst.rawLength) throw new IllegalArgumentException("source and destination do not have equal size"); - raw.asyncCopyTo(0, dst.home, dst.rawData, 0, rawLength, uncounted); + public static def asyncCopy[T](src:Array[T], dst:RemoteArray[T], uncounted:boolean) { + if (src.rawLength != dst.rawLength) throw new IllegalArgumentException("source and destination do not have equal size"); + src.raw.asyncCopyTo(0, dst.home, dst.rawData, 0, src.rawLength, uncounted); } /** - * Asynchronously copy all of the values from the backing storage of the - * Array referenced by the source RemoteArray to this array. + * Asynchronously copy the specified values from the source Array to the + * specified portion of the Array referenced by the destination RemoteArray. + * If accessing any point in either the specified source or the + * specified destination range would in an ArrayIndexOutOfBoundsError + * being raised, then this method will throw an IllegalArgumentException.<p> + * + * The activity created to do the copying will be registered with the + * dynamically enclosing finish.<p> + * + * Warning: This method is only intended to be used on Arrays containing + * non-Object data elements. The elements are actually copied via an + * optimized DMA operation if available. Therefore object-references will + * not be properly transferred. Ideally, future versions of the X10 type + * system would enable this restriction to be checked statically.</p> + * + * @param src the source array. + * @param srcPoint the first element in this array to be copied. + * @param dst the destination array. May actually be local or remote + * @param dstPoint the first element in the destination + * array where copied data elements will be stored. + * @param numElems the number of elements to be copied. + * + * @throws IllegalArgumentException if the specified copy regions would + * result in an ArrayIndexOutOfBoundsException. + */ + public static def asyncCopy[T](src:Array[T], srcPoint:Point, + dst:RemoteArray[T], dstPoint:Point, + numElems:int) { + asyncCopy(src, srcPoint, dst, dstPoint, numElems, false); + } + + + /** + * Asynchronously copy the specified values from the source Array to the + * specified portion of the Array referenced by the destination RemoteArray. + * If accessing any point in either the specified source or the + * specified destination range would in an ArrayIndexOutOfBoundsError + * being raised, then this method will throw an IllegalArgumentException.<p> + * + * Depending on the value of the uncounted parameter, the activity performing + * the copy will either be registered with the dynamically enclosing finish or + * treated as if it was annotated with @Uncounted (not registered with any finish).</p> + * + * Warning: This method is only intended to be used on Arrays containing + * non-Object data elements. The elements are actually copied via an + * optimized DMA operation if available. Therefore object-references will + * not be properly transferred. Ideally, future versions of the X10 type + * system would enable this restriction to be checked statically.</p> + * + * @param src the source array. + * @param srcPoint the first element in this array to be copied. + * @param dst the destination array. May actually be local or remote + * @param dstPoint the first element in the destination + * array where copied data elements will be stored. + * @param numElems the number of elements to be copied. + * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted + * + * @throws IllegalArgumentException if the specified copy regions would + * result in an ArrayIndexOutOfBoundsException. + */ + public static def asyncCopy[T](src:Array[T], srcPoint:Point, + dst:RemoteArray[T], dstPoint:Point, + numElems:int, uncounted:boolean) { + val gra = dst.array; + val dstIndex = at (gra) gra().region.indexOf(dstPoint); + asyncCopy(src, src.region.indexOf(srcPoint), dst, dstIndex, numElems, uncounted); + } + + + /** + * Asynchronously copy the specified values from the source Array to the + * specified portion of the Array referenced by the destination RemoteArray. + * The index arguments that are used to specify the start of the source + * and destination regions are interpreted as of they were the result + * of calling @link{Region@indexOf} on the Point that specifies the + * start of the copy region. Note that for Arrays that have the + * <code>rail</code> property, this exactly corresponds to the index + * that would be used to access the element via apply or set. + * If accessing any point in either the specified source or the + * specified destination range would in an ArrayIndexOutOfBoundsError + * being raised, then this method will throw an IllegalArgumentException.<p> + * + * The activity created to do the copying will be registered with the + * dynamically enclosing finish.<p> + * + * Warning: This method is only intended to be used on Arrays containing + * non-Object data elements. The elements are actually copied via an + * optimized DMA operation if available. Therefore object-references will + * not be properly transferred. Ideally, future versions of the X10 type + * system would enable this restriction to be checked statically.</p> + * + * @param src the source array. + * @param srcIndex the index of the first element in this array + * to be copied. + * @param dst the destination array. May actually be local or remote + * @param dstIndex the index of the first element in the destination + * array where copied data elements will be stored. + * @param numElems the number of elements to be copied. + * + * @see Region#indexOf + * + * @throws IllegalArgumentException if the specified copy regions would + * result in an ArrayIndexOutOfBoundsException. + */ + public static def asyncCopy[T](src:Array[T], srcIndex:int, + dst:RemoteArray[T], dstIndex:int, + numElems:int) { + asyncCopy(src, srcIndex, dst, dstIndex, numElems, false); + } + + + /** + * Asynchronously copy the specified values from the source Array to the + * specified portion of the Array referenced by the destination RemoteArray. + * The index arguments that are used to specify the start of the source + * and destination regions are interpreted as of they were the result + * of calling @link{Region@indexOf} on the Point that specifies the + * start of the copy region. Note that for Arrays that have the + * <code>rail</code> property, this exactly corresponds to the index + * that would be used to access the element via apply or set. + * If accessing any point in either the specified source or the + * specified destination range would in an ArrayIndexOutOfBoundsError + * being raised, then this method will throw an IllegalArgumentException.<p> + * + * Depending on the value of the uncounted parameter, the activity performing + * the copy will either be registered with the dynamically enclosing finish or + * treated as if it was annotated with @Uncounted (not registered with any finish).</p> + * + * Warning: This method is only intended to be used on Arrays containing + * non-Object data elements. The elements are actually copied via an + * optimized DMA operation if available. Therefore object-references will + * not be properly transferred. Ideally, future versions of the X10 type + * system would enable this restriction to be checked statically.</p> + * + * @param src the source array. + * @param srcIndex the index of the first element in this array + * to be copied. + * @param dst the destination array. May actually be local or remote + * @param dstIndex the index of the first element in the destination + * array where copied data elements will be stored. + * @param numElems the number of elements to be copied. + * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted + * + * @see Region#indexOf + * + * @throws IllegalArgumentException if the specified copy regions would + * result in an ArrayIndexOutOfBoundsException. + */ + public static def asyncCopy[T](src:Array[T], srcIndex:int, + dst:RemoteArray[T], dstIndex:int, + numElems:int, uncounted:boolean) { + if (srcIndex < 0 || ((srcIndex+numElems) > src.rawLength)) { + throw new IllegalArgumentException("Specified range is beyond bounds of source array"); + } + if (dstIndex < 0 || ((dstIndex+numElems) > dst.rawLength)) { + throw new IllegalArgumentException("Specified range is beyond bounds of destination array"); + } + src.raw.asyncCopyTo(srcIndex, dst.home, dst.rawData, dstIndex, numElems, uncounted); + } + + + /** + * Asynchronously copy all of the values from the source Array + * referenced by the RemoteArray to the destination Array. * The two arrays must be defined over Regions with equal size * bounding boxes; if the backing storage for the two arrays is - * not of equal size, then an IllegalArgumentExeption will be raised. + * not of equal size, then an IllegalArgumentExeption will be raised.<p> * + * The activity created to do the copying will be registered with the + * dynamically enclosing finish.<p> + * * Warning: This method is only intended to be used on Arrays containing * non-Object data elements. The elements are actually copied via an * optimized DMA operation if available. Therefore object-references will * not be properly transferred. Ideally, future versions of the X10 type * system would enable this restriction to be checked statically.</p> * - * @param src the source array. May be local or remote + * @param src the source array. + * @param dst the destination array. * @throws IllegalArgumentException if mismatch in size of backing storage - * of the two arrays. + * of the two arrays. */ - public def asyncCopyFrom(src:RemoteArray[T]) { - asyncCopyFrom(src, false); + public static def asyncCopy[T](src:RemoteArray[T], dst:Array[T]) { + asyncCopy(src, dst, false); } + /** - * Asynchronously copy all of the values from the backing storage of the - * Array referenced by the source RemoteArray to this array. + * Asynchronously copy all of the values from the source Array + * referenced by the RemoteArray to the destination Array. * The two arrays must be defined over Regions with equal size * bounding boxes; if the backing storage for the two arrays is - * not of equal size, then an IllegalArgumentExeption will be raised. + * not of equal size, then an IllegalArgumentExeption will be raised.<p> * * Depending on the value of the uncounted parameter, the activity performing * the copy will either be registered with the dynamically enclosing finish or @@ -739,15 +912,260 @@ * not be properly transferred. Ideally, future versions of the X10 type * system would enable this restriction to be checked statically.</p> * - * @param src the source array. May be local or remote + * @param src the source array. + * @param dst the destination array. May actually be local or remote * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted - * @throws IllegalArgumentException if !region.equals(dst.region) + * @throws IllegalArgumentException if mismatch in size of backing storage + * of the two arrays. */ - public def asyncCopyFrom(src:RemoteArray[T], uncounted:boolean) { - if (rawLength != src.rawLength) throw new IllegalArgumentException("source and destination do not have equal size"); - raw.asyncCopyFrom(0, src.home, src.rawData, 0, rawLength, uncounted); + public static def asyncCopy[T](src:RemoteArray[T], dst:Array[T], uncounted:boolean) { + if (src.rawLength != dst.rawLength) throw new IllegalArgumentException("source and destination do not have equal size"); + dst.raw.asyncCopyFrom(0, src.home, src.rawData, 0, dst.rawLength, uncounted); } + + /** + * Asynchronously copy the specified values from the Array referenced by + * the source RemoteArray to the specified portion of the destination Array. + * If accessing any point in either the specified source or the + * specified destination range would in an ArrayIndexOutOfBoundsError + * being raised, then this method will throw an IllegalArgumentException.<p> + * + * The activity created to do the copying will be registered with the + * dynamically enclosing finish.<p> + * + * Warning: This method is only intended to be used on Arrays containing + * non-Object data elements. The elements are actually copied via an + * optimized DMA operation if available. Therefore object-references will + * not be properly transferred. Ideally, future versions of the X10 type + * system would enable this restriction to be checked statically.</p> + * + * @param src the source array. + * @param srcPoint the first element in this array to be copied. + * @param dst the destination array. May actually be local or remote + * @param dstPoint the first element in the destination + * array where copied data elements will be stored. + * @param numElems the number of elements to be copied. + * + * @throws IllegalArgumentException if the specified copy regions would + * result in an ArrayIndexOutOfBoundsException. + */ + public static def asyncCopy[T](src:RemoteArray[T], srcPoint:Point, + dst:Array[T], dstPoint:Point, + numElems:int) { + asyncCopy(src, srcPoint, dst, dstPoint, numElems, false); + } + + + /** + * Asynchronously copy the specified values from the Array referenced by + * the source RemoteArray to the specified portion of the destination Array. + * If accessing any point in either the specified source or the + * specified destination range would in an ArrayIndexOutOfBoundsError + * being raised, then this method will throw an IllegalArgumentException.<p> + * + * Depending on the value of the uncounted parameter, the activity performing + * the copy will either be registered with the dynamically enclosing finish or + * treated as if it was annotated with @Uncounted (not registered with any finish).</p> + * + * Warning: This method is only intended to be used on Arrays containing + * non-Object data elements. The elements are actually copied via an + * optimized DMA operation if available. Therefore object-references will + * not be properly transferred. Ideally, future versions of the X10 type + * system would enable this restriction to be checked statically.</p> + * + * @param src the source array. + * @param srcPoint the first element in this array to be copied. + * @param dst the destination array. May actually be local or remote + * @param dstPoint the first element in the destination + * array where copied data elements will be stored. + * @param numElems the number of elements to be copied. + * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted + * + * @throws IllegalArgumentException if the specified copy regions would + * result in an ArrayIndexOutOfBoundsException. + */ + public static def asyncCopy[T](src:RemoteArray[T], srcPoint:Point, + dst:Array[T], dstPoint:Point, + numElems:int, uncounted:boolean) { + val gra = src.array; + val srcIndex = at (gra) gra().region.indexOf(srcPoint); + asyncCopy(src, srcIndex, dst, dst.region.indexOf(dstPoint), numElems, uncounted); + } + + + /** + * Asynchronously copy the specified values from the Array referenced by + * the source RemoteArray to the specified portion of the destination Array. + * The index arguments that are used to specify the start of the source + * and destination regions are interpreted as of they were the result + * of calling @link{Region@indexOf} on the Point that specifies the + * start of the copy region. Note that for Arrays that have the + * <code>rail</code> property, this exactly corresponds to the index + * that would be used to access the element via apply or set. + * If accessing any point in either the specified source or the + * specified destination range would in an ArrayIndexOutOfBoundsError + * being raised, then this method will throw an IllegalArgumentException.<p> + * + * The activity created to do the copying will be registered with the + * dynamically enclosing finish.<p> + * + * Warning: This method is only intended to be used on Arrays containing + * non-Object data elements. The elements are actually copied via an + * optimized DMA operation if available. Therefore object-references will + * not be properly transferred. Ideally, future versions of the X10 type + * system would enable this restriction to be checked statically.</p> + * + * @param src the source array. + * @param srcIndex the index of the first element in this array + * to be copied. + * @param dst the destination array. May actually be local or remote + * @param dstIndex the index of the first element in the destination + * array where copied data elements will be stored. + * @param numElems the number of elements to be copied. + * + * @see Region#indexOf + * + * @throws IllegalArgumentException if the specified copy regions would + * result in an ArrayIndexOutOfBoundsException. + */ + public static def asyncCopy[T](src:RemoteArray[T], srcIndex:int, + dst:Array[T], dstIndex:int, + numElems:int) { + asyncCopy(src, srcIndex, dst, dstIndex, numElems, false); + } + + + /** + * Asynchronously copy the specified values from the Array referenced by + * the source RemoteArray to the specified portion of the destination Array. + * The index arguments that are used to specify the start of the source + * and destination regions are interpreted as of they were the result + * of calling @link{Region@indexOf} on the Point that specifies the + * start of the copy region. Note that for Arrays that have the + * <code>rail</code> property, this exactly corresponds to the index + * that would be used to access the element via apply or set. + * If accessing any point in either the specified source or the + * specified destination range would in an ArrayIndexOutOfBoundsError + * being raised, then this method will throw an IllegalArgumentException.<p> + * + * Depending on the value of the uncounted parameter, the activity performing + * the copy will either be registered with the dynamically enclosing finish or + * treated as if it was annotated with @Uncounted (not registered with any finish).</p> + * + * Warning: This method is only intended to be used on Arrays containing + * non-Object data elements. The elements are actually copied via an + * optimized DMA operation if available. Therefore object-references will + * not be properly transferred. Ideally, future versions of the X10 type + * system would enable this restriction to be checked statically.</p> + * + * @param src the source array. + * @param srcIndex the index of the first element in this array + * to be copied. + * @param dst the destination array. May actually be local or remote + * @param dstIndex the index of the first element in the destination + * array where copied data elements will be stored. + * @param numElems the number of elements to be copied. + * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted + * + * @see Region#indexOf + * + * @throws IllegalArgumentException if the specified copy regions would + * result in an ArrayIndexOutOfBoundsException. + */ + public static def asyncCopy[T](src:RemoteArray[T], srcIndex:int, + dst:Array[T], dstIndex:int, + numElems:int, uncounted:boolean) { + if (srcIndex < 0 || ((srcIndex+numElems) > src.rawLength)) { + throw new IllegalArgumentException("Specified range is beyond bounds of source array"); + } + if (dstIndex < 0 || ((dstIndex+numElems) > dst.rawLength)) { + throw new IllegalArgumentException("Specified range is beyond bounds of destination array"); + } + dst.raw.asyncCopyFrom(dstIndex, src.home, src.rawData, srcIndex, numElems, uncounted); + } + + + /** + * Copy all of the values from the source Array to the destination Array. + * The two arrays must be defined over Regions with equal size + * bounding boxes; if the backing storage for the two arrays is + * not of equal size, then an IllegalArgumentExeption will be raised.<p> + * + * @param src the source array. + * @param dst the destination array. + * @throws IllegalArgumentException if mismatch in size of backing storage + * of the two arrays. + */ + public static def copy[T](src:Array[T], dst:Array[T]) { + if (src.rawLength != dst.rawLength) throw new IllegalArgumentException("source and destination do not have equal size"); + src.raw.asyncCopyTo(0, here, dst.raw, 0, src.rawLength, false); + } + + + /** + * Copy the specified values from the source Array to the + * specified portion of the destination Array. + * If accessing any point in either the specified source or the + * specified destination range would in an ArrayIndexOutOfBoundsError + * being raised, then this method will throw an IllegalArgumentException.<p> + * + * @param src the source array. + * @param srcPoint the first element in this array to be copied. + * @param dst the destination array. May actually be local or remote + * @param dstPoint the first element in the destination + * array where copied data elements will be stored. + * @param numElems the number of elements to be copied. + * + * @throws IllegalArgumentException if the specified copy regions would + * result in an ArrayIndexOutOfBoundsException. + */ + public static def copy[T](src:Array[T], srcPoint:Point, + dst:Array[T], dstPoint:Point, + numElems:int) { + copy(src, src.region.indexOf(srcPoint), dst, dst.region.indexOf(dstPoint), numElems); + } + + + /** + * Copy the specified values from the source Array to the + * specified portion of the destination Array. + * The index arguments that are used to specify the start of the source + * and destination regions are interpreted as of they were the result + * of calling @link{Region@indexOf} on the Point that specifies the + * start of the copy region. Note that for Arrays that have the + * <code>rail</code> property, this exactly corresponds to the index + * that would be used to access the element via apply or set. + * If accessing any point in either the specified source or the + * specified destination range would in an ArrayIndexOutOfBoundsError + * being raised, then this method will throw an IllegalArgumentException.<p> + * + * @param src the source array. + * @param srcIndex the index of the first element in this array + * to be copied. + * @param dst the destination array. May actually be local or remote + * @param dstIndex the index of the first element in the destination + * array where copied data elements will be stored. + * @param numElems the number of elements to be copied. + * + * @see Region#indexOf + * + * @throws IllegalArgumentException if the specified copy regions would + * result in an ArrayIndexOutOfBoundsException. + */ + public static def copy[T](src:Array[T], srcIndex:int, + dst:Array[T], dstIndex:int, + numElems:int) { + if (srcIndex < 0 || ((srcIndex+numElems) > src.rawLength)) { + throw new IllegalArgumentException("Specified range is beyond bounds of source array"); + } + if (dstIndex < 0 || ((dstIndex+numElems) > dst.rawLength)) { + throw new IllegalArgumentException("Specified range is beyond bounds of destination array"); + } + src.raw.asyncCopyTo(srcIndex, here, dst.raw, dstIndex, numElems, false); + } + + private static @NoInline @NoReturn def raiseBoundsError(i0:int) { throw new ArrayIndexOutOfBoundsException("point (" + i0 + ") not contained in array"); } Modified: trunk/x10.runtime/src-x10/x10/array/EmptyRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/EmptyRegion.x10 2010-09-10 17:46:41 UTC (rev 16303) +++ trunk/x10.runtime/src-x10/x10/array/EmptyRegion.x10 2010-09-10 21:28:20 UTC (rev 16304) @@ -24,6 +24,7 @@ public def isConvex() = true; public def isEmpty() = true; public def size() = 0; + public def indexOf(Point) = -1; public def intersection(that: Region(rank)): Region(rank) = this; public def product(that: Region): Region/*(this.rank+that.rank)*/ = new EmptyRegion(this.rank + that.rank); Modified: trunk/x10.runtime/src-x10/x10/array/FullRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/FullRegion.x10 2010-09-10 17:46:41 UTC (rev 16303) +++ trunk/x10.runtime/src-x10/x10/array/FullRegion.x10 2010-09-10 21:28:20 UTC (rev 16304) @@ -26,6 +26,9 @@ public def size():int { throw new IllegalOperationException("Full Region is infinite; size not supported"); } + public def indexOf(Point):int { + throw new IllegalOperationException("Full Region is infinite; indexOf not supported"); + } public def min() = ValRail.make(rank, (Int)=>Int.MIN_VALUE); public def max() = ValRail.make(rank, (Int)=>Int.MAX_VALUE); public def intersection(that: Region(rank)): Region(rank) = that; Modified: trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 2010-09-10 17:46:41 UTC (rev 16303) +++ trunk/x10.runtime/src-x10/x10/array/PolyRegion.x10 2010-09-10 21:28:20 UTC (rev 16304) @@ -48,7 +48,9 @@ incomplete public def size():int; + incomplete public def indexOf(Point):int; + // // scanners // Modified: trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 2010-09-10 17:46:41 UTC (rev 16303) +++ trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 2010-09-10 21:28:20 UTC (rev 16304) @@ -95,7 +95,17 @@ public def isEmpty() = size == 0; + public def indexOf(pt:Point) { + if (pt.rank != rank) return -1; + var offset: int = pt(0) - min(0); + for (var i:int=1; i<rank; i++) { + val delta_i = max(i) - min(i) + 1; + offset = offset*delta_i + pt(i) - min(i); + } + return offset; + } + // // region operations // Modified: trunk/x10.runtime/src-x10/x10/array/Region.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/Region.x10 2010-09-10 17:46:41 UTC (rev 16303) +++ trunk/x10.runtime/src-x10/x10/array/Region.x10 2010-09-10 21:28:20 UTC (rev 16304) @@ -156,23 +156,34 @@ /** * Returns the number of points in this region. */ - public abstract def size(): int; /** * Returns true iff this region is convex. */ - public abstract def isConvex(): boolean; /** * Returns true iff this region is empty. */ - public abstract def isEmpty(): boolean; + /** + * Returns the index of the argument point in the lexograpically ordered + * enumeration of all Points in thie region. Will return -1 to indicate + * that the argument point is not included in this region. If the argument + * point is contained in this region, then a value between 0 and size-1 + * will be returned. The primary usage of indexOf is in the context of + * Arrays, where it enables the conversion from "logical" indicies + * specified in Points into lower level indices specified by Ints that + * can be used in primitive operations such as copyTo and in interfacing + * to native code. Often indexOf will be used in conjuntion with the + * raw() method of Array or DistArray. + */ + public abstract def indexOf(Point):Int; + // // bounding box // @@ -190,28 +201,24 @@ * Returns the lower bounds of the bounding box of the region as a * Rail[int]. */ - abstract public def min(): ValRail[int]; /** * Returns the upper bounds of the bounding box of the region as a * Rail[int]. */ - abstract public def max(): ValRail[int]; /** * Returns the lower bound of the bounding box of the region along * the ith axis. */ - public def min(i:Int) = min()(i); /** * Returns the upper bound of the bounding box of the region along * the ith axis. */ - public def max(i:Int) = max()(i); Modified: trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk.x10 2010-09-10 17:46:41 UTC (rev 16303) +++ trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk.x10 2010-09-10 21:28:20 UTC (rev 16304) @@ -112,9 +112,11 @@ /** * Copies a contiguous portion of this IndexedMemoryChunk * to a destination IndexedMemoryChunk at the specified place. + * If the destination place is the current place, then the copy happens synchronously. * If the destination place is not the same as the current place, then - * the copy happens asynchronously and the created remote activity is registered - * with the dynamically enclosing finish of the activity that invoked asyncCopyTo.</p> + * the copy happens asynchronously and the created remote activity is optionally + * registered with the dynamically enclosing finish of the activity that invoked + * asyncCopyTo depending on the value of the uncounted parameter.</p> * * Note: No checking is performed to verify that this operation is safe; * it is the responsibility of higher-level abstractions built on top of @@ -125,6 +127,7 @@ * @param dst the destination IndexedMemoryChunk. * @param dstIndex the index of the first element to store in the destination. * @param numElems the number of elements to copy. + * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted */ @Native("java", "x10.util.IndexedMemoryChunk__NativeRep.copyTo(#9, #0,#1,#2,#3,#4,#5,#6)") @Native("c++", "(#0)->copyTo(#1,#2,#3,#4,#5,#6)") @@ -137,9 +140,11 @@ /** * Copies a contiguous portion of the src IndexedMemoryChunk found * at the specified place into this IndexedMemoryChunk. + * If the source place is the current place, then the copy happens synchronously. * If the source place is not the same as the current place, then - * the copy happens asynchronously and the created remote activity is registered - * with the dynamically enclosing finish of the activity that invoked asyncCopyFrom.</p> + * the copy happens asynchronously and the created remote activity is optionally + * registered with the dynamically enclosing finish of the activity that invoked + * asyncCopyFrom depending on the value of the uncounted paramater.</p> * * Note: No checking is performed to verify that this operation is safe; * it is the responsibility of higher-level abstractions built on top of @@ -150,6 +155,7 @@ * @param src the destination IndexedMemoryChunk. * @param srcIndex the index of the first element to copy in the source. * @param numElems the number of elements to copy. + * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted */ @Native("java", "x10.util.IndexedMemoryChunk__NativeRep.copyFrom(#9, #0,#1,#2,#3,#4,#5,#6)") @Native("c++", "(#0)->copyFrom(#1,#2,#3,#4,#5,#6)") Modified: trunk/x10.tests/examples/Constructs/Array/ArrayCopyTo.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayCopyTo.x10 2010-09-10 17:46:41 UTC (rev 16303) +++ trunk/x10.tests/examples/Constructs/Array/ArrayCopyTo.x10 2010-09-10 21:28:20 UTC (rev 16304) @@ -28,24 +28,24 @@ var fail:boolean = false; finish { - localA.asyncCopyTo(20, remoteA, 20, 81); - localB.asyncCopyTo(remoteB); + Array.asyncCopy(localA, 0, remoteA, 0, 81); + Array.asyncCopy(localB, remoteB); } finish { - finalA.asyncCopyFrom(20, remoteA, 20, 81); - finalB.asyncCopyFrom(remoteB); + Array.asyncCopy(remoteA, 0, finalA, 0, 81); + Array.asyncCopy(remoteB, finalB); } for (p in localA) { if (localA(p) != finalA(p)) { - Console.OUT.println("Expected to find "+localA(p)+"at "+p+" but found "+finalA(p)); + Console.OUT.println("Expected to find "+localA(p)+" at "+p+" but found "+finalA(p)); fail = true; } } for (p in localB) { if (localB(p) != finalB(p)) { - Console.OUT.println("Expected to find "+localB(p)+"at "+p+" but found "+finalB(p)); + Console.OUT.println("Expected to find "+localB(p)+" at "+p+" but found "+finalB(p)); fail = true; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-09-17 23:57:31
|
Revision: 16547 http://x10.svn.sourceforge.net/x10/?rev=16547&view=rev Author: ipeshansky Date: 2010-09-17 23:57:24 +0000 (Fri, 17 Sep 2010) Log Message: ----------- War on warnings. Modified Paths: -------------- trunk/x10.compiler/src/polyglot/types/Flags.java trunk/x10.constraints/META-INF/MANIFEST.MF trunk/x10.constraints/src/x10/constraint/XConstraint.java trunk/x10.constraints/src/x10/constraint/XDisEquals.java trunk/x10.constraints/src/x10/constraint/XEQV.java trunk/x10.constraints/src/x10/constraint/XField.java trunk/x10.constraints/src/x10/constraint/XNameWrapper.java trunk/x10.constraints/src/x10/constraint/XTerm.java trunk/x10.constraints/src/x10/constraint/XTerms.java trunk/x10.constraints/src/x10/constraint/XVar.java trunk/x10.dist/build.properties trunk/x10.doc/src/x10doc/doc/X10ClassDoc.java trunk/x10.doc/src/x10doc/doc/X10Doc.java trunk/x10.doc/src/x10doc/doc/X10ParameterizedType.java trunk/x10.tests/build.properties Modified: trunk/x10.compiler/src/polyglot/types/Flags.java =================================================================== --- trunk/x10.compiler/src/polyglot/types/Flags.java 2010-09-17 23:52:45 UTC (rev 16546) +++ trunk/x10.compiler/src/polyglot/types/Flags.java 2010-09-17 23:57:24 UTC (rev 16547) @@ -72,7 +72,7 @@ } public static void addToOrder(String name, Flags after) { - List order = FlagComparator.order; + List<String> order = FlagComparator.order; boolean added = false; if (after == null) { @@ -82,7 +82,7 @@ order.add(0, name); } else { - for (ListIterator i = order.listIterator(); i.hasNext(); ) { + for (ListIterator<String> i = order.listIterator(); i.hasNext(); ) { String s = (String) i.next(); after = after.clear(new Flags(s)); if (after.flags.isEmpty()) { @@ -103,7 +103,7 @@ * Effects: returns a new accessflags object with no accessflags set. */ protected Flags() { - this.flags = new TreeSet(); + this.flags = new TreeSet<String>(); } protected Flags(String name) { @@ -111,7 +111,7 @@ flags.add(name); } - public Set flags() { + public Set<String> flags() { return this.flags; } Modified: trunk/x10.constraints/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.constraints/META-INF/MANIFEST.MF 2010-09-17 23:52:45 UTC (rev 16546) +++ trunk/x10.constraints/META-INF/MANIFEST.MF 2010-09-17 23:57:24 UTC (rev 16547) @@ -4,3 +4,4 @@ Bundle-SymbolicName: x10.constraints Bundle-Version: 2.0.6.qualifier Export-Package: x10.constraint +Bundle-RequiredExecutionEnvironment: J2SE-1.5 Modified: trunk/x10.constraints/src/x10/constraint/XConstraint.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XConstraint.java 2010-09-17 23:52:45 UTC (rev 16546) +++ trunk/x10.constraints/src/x10/constraint/XConstraint.java 2010-09-17 23:57:24 UTC (rev 16547) @@ -16,15 +16,12 @@ import java.util.List; import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.Map; import java.util.Set; - - /** * * A constraint solver for the following constraint system. Note terms in this constraint system are untyped. @@ -73,7 +70,7 @@ * @author vj * */ -public class XConstraint implements Cloneable { +public class XConstraint implements Cloneable { private static final boolean DEBUG = false; protected HashMap<XTerm, XPromise> roots; Modified: trunk/x10.constraints/src/x10/constraint/XDisEquals.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XDisEquals.java 2010-09-17 23:52:45 UTC (rev 16546) +++ trunk/x10.constraints/src/x10/constraint/XDisEquals.java 2010-09-17 23:57:24 UTC (rev 16547) @@ -18,8 +18,6 @@ */ -import java.util.List; - public class XDisEquals extends XFormula { Modified: trunk/x10.constraints/src/x10/constraint/XEQV.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XEQV.java 2010-09-17 23:52:45 UTC (rev 16546) +++ trunk/x10.constraints/src/x10/constraint/XEQV.java 2010-09-17 23:57:24 UTC (rev 16547) @@ -45,7 +45,7 @@ public List<XEQV> eqvs() { if (hasEQV()) return Collections.<XEQV>singletonList(this); - return Collections.EMPTY_LIST; + return Collections.<XEQV>emptyList(); } } Modified: trunk/x10.constraints/src/x10/constraint/XField.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XField.java 2010-09-17 23:52:45 UTC (rev 16546) +++ trunk/x10.constraints/src/x10/constraint/XField.java 2010-09-17 23:57:24 UTC (rev 16547) @@ -12,7 +12,7 @@ package x10.constraint; import java.util.List; -import java.util.Set; + /** * A representation of a Field. * @author vj Modified: trunk/x10.constraints/src/x10/constraint/XNameWrapper.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XNameWrapper.java 2010-09-17 23:52:45 UTC (rev 16546) +++ trunk/x10.constraints/src/x10/constraint/XNameWrapper.java 2010-09-17 23:57:24 UTC (rev 16547) @@ -51,6 +51,6 @@ } public boolean equals(Object o) { - return o instanceof XNameWrapper && v.equals(((XNameWrapper<?>) o).v); + return o instanceof XNameWrapper<?> && v.equals(((XNameWrapper<?>) o).v); } } Modified: trunk/x10.constraints/src/x10/constraint/XTerm.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XTerm.java 2010-09-17 23:52:45 UTC (rev 16546) +++ trunk/x10.constraints/src/x10/constraint/XTerm.java 2010-09-17 23:57:24 UTC (rev 16547) @@ -13,7 +13,6 @@ import java.io.Serializable; import java.util.List; -import java.util.Set; /** * Constraints constrain XTerms. Thus XTerms are the basic building blocks of constraints. @@ -23,7 +22,7 @@ * @author vj * */ -public abstract class XTerm implements Serializable, Cloneable { +public abstract class XTerm implements Serializable, Cloneable { public XTerm() { Modified: trunk/x10.constraints/src/x10/constraint/XTerms.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XTerms.java 2010-09-17 23:52:45 UTC (rev 16546) +++ trunk/x10.constraints/src/x10/constraint/XTerms.java 2010-09-17 23:57:24 UTC (rev 16547) @@ -11,9 +11,7 @@ package x10.constraint; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; Modified: trunk/x10.constraints/src/x10/constraint/XVar.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XVar.java 2010-09-17 23:52:45 UTC (rev 16546) +++ trunk/x10.constraints/src/x10/constraint/XVar.java 2010-09-17 23:57:24 UTC (rev 16547) @@ -11,10 +11,6 @@ package x10.constraint; -import java.util.List; - - - public abstract class XVar extends XTerm { /** In case this is a field selection x.f1...fn, return x, x.f1, x.f1.f2, ... x.f1.f2...fn */ abstract XVar[] vars(); Modified: trunk/x10.dist/build.properties =================================================================== --- trunk/x10.dist/build.properties 2010-09-17 23:52:45 UTC (rev 16546) +++ trunk/x10.dist/build.properties 2010-09-17 23:57:24 UTC (rev 16547) @@ -1,4 +1,2 @@ -source.. = src/ output.. = classes/ -bin.includes = META-INF/,\ - . +bin.includes = . Modified: trunk/x10.doc/src/x10doc/doc/X10ClassDoc.java =================================================================== --- trunk/x10.doc/src/x10doc/doc/X10ClassDoc.java 2010-09-17 23:52:45 UTC (rev 16546) +++ trunk/x10.doc/src/x10doc/doc/X10ClassDoc.java 2010-09-17 23:57:24 UTC (rev 16547) @@ -6,8 +6,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.StringTokenizer; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import polyglot.types.ClassType; import polyglot.types.Ref; @@ -163,7 +161,7 @@ void initTypeParameters() { List<ParameterType> params = classDef.typeParameters(); typeParams = new LinkedHashMap<String, X10TypeVariable>(params.size()); - Ref inv = classDef.classInvariant(); + Ref<CConstraint> inv = classDef.classInvariant(); // System.out.println("classInvariant: " + ((inv == null) ? "" : inv.get())); TypeConstraint c = classDef.typeGuard().get(); for (ParameterType p: params) { Modified: trunk/x10.doc/src/x10doc/doc/X10Doc.java =================================================================== --- trunk/x10.doc/src/x10doc/doc/X10Doc.java 2010-09-17 23:52:45 UTC (rev 16546) +++ trunk/x10.doc/src/x10doc/doc/X10Doc.java 2010-09-17 23:57:24 UTC (rev 16547) @@ -486,13 +486,13 @@ //flagsToHex.put(Flags.STRICTFP.toString(), 0x0800); } - public static int flagsToModifierSpecifier(Set<Object> flags) { + public static int flagsToModifierSpecifier(Set<String> flags) { int r = 0; - for (Object flag : flags) { + for (String flag : flags) { // flag could be "property" which is not in flagsToHex (and not recognized by // the standard doclet) - if (flagsToHex.containsKey((String)flag)) { - r |= flagsToHex.get((String)flag); + if (flagsToHex.containsKey(flag)) { + r |= flagsToHex.get(flag); } } return r; Modified: trunk/x10.doc/src/x10doc/doc/X10ParameterizedType.java =================================================================== --- trunk/x10.doc/src/x10doc/doc/X10ParameterizedType.java 2010-09-17 23:52:45 UTC (rev 16546) +++ trunk/x10.doc/src/x10doc/doc/X10ParameterizedType.java 2010-09-17 23:57:24 UTC (rev 16547) @@ -6,7 +6,6 @@ import polyglot.types.ClassType; import polyglot.types.FieldDef; -import polyglot.types.Ref; import x10.constraint.XConstraint; import x10.constraint.XEQV; @@ -17,15 +16,10 @@ import x10.constraint.XName; import x10.constraint.XNameWrapper; import x10.constraint.XTerm; -import x10.constraint.XTermKind; import x10.constraint.XVar; import x10.types.ConstrainedType; import x10.types.FunctionType; -import x10.types.ParameterType; -import x10.types.ParametrizedType; -import x10.types.X10ClassDef; import x10.types.X10ClassType; -import x10.types.X10Def; import x10.types.X10TypeMixin; import com.sun.javadoc.ClassDoc; Modified: trunk/x10.tests/build.properties =================================================================== --- trunk/x10.tests/build.properties 2010-09-17 23:52:45 UTC (rev 16546) +++ trunk/x10.tests/build.properties 2010-09-17 23:57:24 UTC (rev 16547) @@ -1,4 +1,2 @@ -source.. = src/ output.. = classes/ -bin.includes = META-INF/,\ - . +bin.includes = . This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-09-29 01:18:42
|
Revision: 16771 http://x10.svn.sourceforge.net/x10/?rev=16771&view=rev Author: yzibin Date: 2010-09-29 01:18:35 +0000 (Wed, 29 Sep 2010) Log Message: ----------- - added isAsyncInit to X10LocalDef - added more test cases for properties, super, and field initializers Modified Paths: -------------- trunk/x10.compiler/src/polyglot/visit/InitChecker.java trunk/x10.compiler/src/x10/types/X10LocalDef.java trunk/x10.compiler/src/x10/types/X10LocalDef_c.java trunk/x10.compiler/src/x10/util/RunTestSuite.java trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 Modified: trunk/x10.compiler/src/polyglot/visit/InitChecker.java =================================================================== --- trunk/x10.compiler/src/polyglot/visit/InitChecker.java 2010-09-28 22:13:21 UTC (rev 16770) +++ trunk/x10.compiler/src/polyglot/visit/InitChecker.java 2010-09-29 01:18:35 UTC (rev 16771) @@ -26,6 +26,7 @@ import x10.ast.Async_c; import x10.ast.Finish_c; import x10.extension.X10Ext_c; +import x10.types.X10LocalDef; /** * Visitor which checks that all local variables must be defined before use, @@ -749,6 +750,9 @@ if (!before.equals(after) && after.equals(MinMaxInitCount.ONE) && flags !=null && flags.isFinal()) { if (ext.asyncInitVal ==null) ext.asyncInitVal = new HashSet<VarDef>(); ext.asyncInitVal.add(v); + if (v instanceof X10LocalDef) { + ((X10LocalDef)v).setAsyncInit(); + } break; // optimization, cause we already added "v" } } Modified: trunk/x10.compiler/src/x10/types/X10LocalDef.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10LocalDef.java 2010-09-28 22:13:21 UTC (rev 16770) +++ trunk/x10.compiler/src/x10/types/X10LocalDef.java 2010-09-29 01:18:35 UTC (rev 16771) @@ -15,7 +15,9 @@ import x10.constraint.XTerm; public interface X10LocalDef extends LocalDef, X10Def { - + + void setAsyncInit(); + boolean isAsyncInit(); XTerm placeTerm(); void setPlaceTerm(XTerm xt); } Modified: trunk/x10.compiler/src/x10/types/X10LocalDef_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10LocalDef_c.java 2010-09-28 22:13:21 UTC (rev 16770) +++ trunk/x10.compiler/src/x10/types/X10LocalDef_c.java 2010-09-29 01:18:35 UTC (rev 16771) @@ -45,6 +45,10 @@ super(ts, pos, flags, type, name); // TODO: Add the {self==name} constraint to the type } + + private boolean isAsyncInit = false; + public void setAsyncInit() { isAsyncInit = true; } + public boolean isAsyncInit() { return isAsyncInit; } public String toString() { ConstantValue cv = constantRef.getCached(); Modified: trunk/x10.compiler/src/x10/util/RunTestSuite.java =================================================================== --- trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-09-28 22:13:21 UTC (rev 16770) +++ trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-09-29 01:18:35 UTC (rev 16771) @@ -16,6 +16,7 @@ import java.util.Arrays; import java.util.List; import java.util.HashSet; +import java.util.Iterator; public class RunTestSuite { @@ -102,6 +103,11 @@ compileFiles(files,remainingArgs); } } + private static int count(String s, String sub) { + int index=-1, res=0; + while ((index=s.indexOf(sub,index+sub.length()))>=0) res++; + return res; + } private static void compileFiles(List<File> files, List<String> args) throws IOException { // replace \ with / ArrayList<String> fileNames = new ArrayList<String>(files.size()); @@ -159,20 +165,23 @@ !file.getName().contains("Console.x10")) { // Console defines "static ERR:Printer" foundErr = true; // try to find the matching error - boolean foundMatch = false; - for (ErrorInfo err : errors) { + int expectedMatchCount = count(line,"ERR"); + int foundMatchCount = 0; + ArrayList<ErrorInfo> errorsFound = new ArrayList<ErrorInfo>(expectedMatchCount); + for (Iterator<ErrorInfo> it=errors.iterator(); it.hasNext(); ) { + ErrorInfo err = it.next(); final Position position = err.getPosition(); if (new File(position.file()).equals(file) && position.line()==lineNum) { // found it! + errorsFound.add(err); if (Report.should_report("TestSuite", 2)) Report.report(2, "Found error: "+ err); - errors.remove(err); - foundMatch = true; - break; + it.remove(); + foundMatchCount++; } } - if (!foundMatch) - System.err.println("File "+file+" has an ERR marker on line "+lineNum+", but the compiler didn't report an error on that line!"); + if (expectedMatchCount!=foundMatchCount) + System.err.println("File "+file+" has "+expectedMatchCount+" ERR markers on line "+lineNum+", but the compiler reported "+foundMatchCount+" errors on that line! errorsFound=\n"+errorsFound); } } in.close(); Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-09-28 22:13:21 UTC (rev 16770) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-09-29 01:18:35 UTC (rev 16771) @@ -2,6 +2,177 @@ import x10.compiler.*; + + + +class SomeSuper87 { + def this(i:Int) {} +} +class TestSuperThisAndPropertyCalls(p:Int) extends SomeSuper87 { + var i:Int; + def this() { + super(i); // ERR: Can use 'this' only after 'property(...)' + property(i); // ERR: Can use 'this' only after 'property(...)' + } + def this(i:Int) { + super(i); + property(i); + } + def this(b:Boolean) { // ERR: Final field "p" might have already been initialized + this(i); // ERR: Can use 'this' only after 'property(...)' + property(1); // ERR: You cannot call 'property(...)' after 'this(...)' + } + def this(x:Double) { super(1); } // ERR: You must call 'property(...)' at least once ERR: Final field "p" might not have been initialized + def this(x:Float) { property(1); } + def this(x:Char) { + // val x = 3; // I can't check this error, because it is a parsing error: the call to "super(...)" must be the first statement. + super(1); + property(1); + } + def this(x:String) { + super(1); + val y = 3; + property(1); + } +} + + +interface BarI34 { + static x = 3; + val y = Math.sqrt(2.0); +} +class TestPropAndConstants(p:Int) implements BarI34 { + val q:Int = 3 as Int; // this will be moved (it might access properties) + val q3:Int = p+4; + val q2:Int = 42; // this is constant, so it won't be moved to the __fieldInitializers() + var x:Int; + def this() { + val w=4; + property(45); + x=2; + } + def this(i:Int) { + this(); + x=4; + } + def this(i:Boolean) { + super(); + val w=4; + { + property(42); + } + x=2; + } + +} + + +class PropertySuperTests { +static class WithouProperties {} +static class WithProperties(x:Int) { + def this() { + property(1); + } + def this(i:Int) { + property(i); + } +} +static class SubWithProperties(y:Int) extends WithProperties { + static S=1; + val k=3; + var z:Int = 4; + def this() { + super(1); + property(2); + } + def this(i:Boolean) { + this(); + } + def this(i:Int) { // ERR: Final field "y" might have already been initialized + this(); + property(1); // ERR: You cannot call 'property(...)' after 'this(...)' + } + def this(i:Double) { + super( + super.x // ERR: You can use 'super' only after 'super(...)' + ); + val w = z; // ERR: Can use 'this' only after 'property(...)' + val w2 = this.S; // ERR: Can use 'this' only after 'property(...)' + val w3 = S; + val w4 = super.x; + val w5 = this.x; // ERR: Can use 'this' only after 'property(...)' + val w6 = this.y; // ERR: Can use 'this' only after 'property(...)' + property( + this.y // ERR: Can use 'this' only after 'property(...)' + ); + } + def this(i:Float) { + property(1); + } + def this(i:String) { // ERR: You must call 'property(...)' at least once ERR: Final field "y" might not have been initialized + } + def this(i:Any) { // ERR: Final field "y" might not have been initialized + property(1); + property(1); // ERR: You can call 'property(...)' at most once ERR: Property "y" might already have been initialized + } +} +static class SubWithoutProperties extends WithProperties { + def this() { + super(1); + } + def this(i:Float) { + property(1); // ERR: The property initializer must have the same number of arguments as properties for the class. + } + def this(i:Double) { + super(1); + property(1); // ERR: The property initializer must have the same number of arguments as properties for the class. + } +} +} + + + +class TestPropertyCalls(p:Int) { + def this() {} // ERR: Final field "p" might not have been initialized ERR: You must call 'property(...)' at least once + def this(i:Int) { + property(1); + } + def this(b:Boolean) { // ERR: Final field "p" might not have been initialized + property(1); + property(1); // ERR: Property "p" might already have been initialized ERR: You can call 'property(...)' at most once + } + def this(b:Double) { // ERR: Final field "p" might not have been initialized + if (p==1) // ERR: must call 'property(...)' immediately after the 'super(...)' call. + property(1); + } + def m() { + property(1); // ERR: A property statement may only occur in the body of a constructor. + } + static def q() { + property(1); // ERR: A property statement may only occur in the body of a constructor. + } +} + + + +class TestPropertiesAndFields(i:Int, j:Int) { + def this() { + val x = 3; + property(x,x); + val closure = () => i+4; + j2 = j; + } + + val i2 :Int{self==i} = i; + val j2 :Int{self==j}; +} +class CheckCtorContextIsNotStatic[T](p:T) { + public def this(o:Any) { + property(o as T); + } +} + + //public class EscapingThisTest { class TransientTest { // The transient field '...' must have a type with a default value. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-09-30 13:55:40
|
Revision: 16806 http://x10.svn.sourceforge.net/x10/?rev=16806&view=rev Author: dgrove-oss Date: 2010-09-30 13:55:33 +0000 (Thu, 30 Sep 2010) Log Message: ----------- Implement custom serialization for HashMap; Add testcase for HashMap serialization. Modified Paths: -------------- trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 trunk/x10.runtime/src-x10/x10/util/HashMap.x10 trunk/x10.tests/examples/Constructs/At/TestCustomSerialization2.x10 Modified: trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-09-30 09:14:39 UTC (rev 16805) +++ trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-09-30 13:55:33 UTC (rev 16806) @@ -179,6 +179,14 @@ for(clock:Clock in keySet()) clock.dropInternal(); clear(); } + + // HashMap implments CustomSerialization, so we must as well + // Only constructor is actually required, but stub out serialize as well + // as a reminder that if instance fields are added to ClockPhases then + // work will have to be done here to serialize them. + public def serialize() = super.serialize(); + def this() { super(); } + def this(a:Any) { super(a); } } Modified: trunk/x10.runtime/src-x10/x10/util/HashMap.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/HashMap.x10 2010-09-30 09:14:39 UTC (rev 16805) +++ trunk/x10.runtime/src-x10/x10/util/HashMap.x10 2010-09-30 13:55:33 UTC (rev 16806) @@ -11,11 +11,10 @@ package x10.util; -import x10.compiler.Pinned; import x10.compiler.TempNoInline_1; +import x10.io.CustomSerialization; -@Pinned - public class HashMap[K,V] implements Map[K,V] { + public class HashMap[K,V] implements Map[K,V], CustomSerialization { static class HashEntry[Key,Value] implements Map.Entry[Key,Value] { public def getKey() = key; public def getValue() = value; @@ -75,13 +74,14 @@ occupation = 0; shouldRehash = false; } - + public def clear(): void { modCount++; init(MIN_SIZE); } - protected def hash(k: K): Int { + protected def hash(k: K): Int = hashInternal(k); + protected final def hashInternal(k: K): Int { return k.hashCode() * 17; } @@ -143,11 +143,12 @@ } } - public def put(k: K, v: V): Box[V] { + public def put(k: K, v: V): Box[V] = putInternal(k,v); + protected final def putInternal(k: K, v: V): Box[V] { if (occupation == table.length || (shouldRehash && occupation >= table.length / 2)) - rehash(); + rehashInternal(); - val h = hash(k); + val h = hashInternal(k); var i: int = h; while (true) { @@ -178,7 +179,8 @@ } } - public def rehash(): void { + public def rehash():void = rehashInternal(); + protected final def rehashInternal(): void { modCount++; val t = table; val oldSize = size; @@ -190,7 +192,7 @@ for (var i: int = 0; i < t.length; i++) { if (t(i) != null && ! t(i).removed) { - put(t(i).key, t(i).value); + putInternal(t(i).key, t(i).value); shouldRehash = false; } } @@ -295,4 +297,41 @@ public def clone(): EntrySet[Key,Value] { throw new UnsupportedOperationException(); } public def size(): Int = map.size(); } + + + protected static class State[Key,Value] { + val size:int; + val keys:Array[Key](1); + val vals:Array[Value](1); + + def this(map:HashMap[Key,Value]) { + size = map.size(); + keys = new Array[Key](size); + vals = new Array[Value](size); + var cur:int = 0; + val it = map.entriesIterator(); + while (it.hasNext()) { + val entry = it.next(); + keys(cur) = entry.getKey(); + vals(cur) = entry.getValue(); + cur++; + } + } + } + + /* + * Custom deserialization + */ + public def this(x:Any) { + this(); + val state = x as State[K,V]; + for ([i] in 0..state.size-1) { + putInternal(state.keys(i), state.vals(i)); + } + } + + /* + * Custom serialization + */ + public def serialize():Any = new State(this); } Modified: trunk/x10.tests/examples/Constructs/At/TestCustomSerialization2.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/At/TestCustomSerialization2.x10 2010-09-30 09:14:39 UTC (rev 16805) +++ trunk/x10.tests/examples/Constructs/At/TestCustomSerialization2.x10 2010-09-30 13:55:33 UTC (rev 16806) @@ -11,45 +11,56 @@ import harness.x10Test; import x10.io.CustomSerialization; +import x10.util.HashMap; /* * Simple test case to check to see if custom serialization * protocol is being called by runtime system */ public class TestCustomSerialization2 extends x10Test { - static class CS[X] implements CustomSerialization { - val x:X; - val y:X; - val other:X; + + static class CS implements CustomSerialization { + val x:int; + val y:int; + transient var sum:int; - public def serialize():Any = [x,y]; + public def serialize():Any = [x,y]; - def this(a:Any) { - val t = a as ValRail[X]; - x = t(0); - y = t(1); - other = y; - } + def this(a:Any) { + val t = a as ValRail[int]; + x = t(0); + y = t(1); + sum = x + y; + } - def this(a:X, b:X) { x = a; y = b; other = x;} - } + def this(a:int, b:int) { x = a; y = b; sum = x + y; } + } - public def run():boolean { - val x = new CS[int](10,20); - chk(!x.x.equals(x.y)); - chk(x.other.equals(x.x)); - at (here.next()) { - // The custom serialization logic changes other from x to y. - // Default serialzation would result in other still being equal to x. - chk(x.other.equals(x.y)); + public def run():boolean { + val map = new HashMap[String,CS](); + map.put("a", new CS(10,20)); + map.put("b", new CS(20,10)); + map.put("c", new CS(25,5)); + + val x = map.serialize(); + val map2 = new HashMap[String,CS](x); + chk(map2.get("a")().sum == 30); + chk(map2.get("b")().sum == 30); + chk(map2.get("c")().sum == 30); + + at (here.next()) { + // The custom serialization logic re-establishes that sum = x + y + // Default serialzation would result in sum having the value of zero. + chk(map.get("a")().sum == 30); + chk(map.get("b")().sum == 30); + chk(map.get("c")().sum == 30); + } + return true; } - return true; - } - public static def main(Array[String]) { - new TestCustomSerialization2().execute(); - } - + public static def main(Array[String]) { + new TestCustomSerialization2().execute(); + } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-10-04 21:35:30
|
Revision: 16951 http://x10.svn.sourceforge.net/x10/?rev=16951&view=rev Author: dgrove-oss Date: 2010-10-04 21:35:24 +0000 (Mon, 04 Oct 2010) Log Message: ----------- Place.places is now of type Iterable[Place] instead of Array[Place](1) Modified Paths: -------------- trunk/x10.dist/samples/FRASimpleDist.x10 trunk/x10.dist/samples/FSSimpleDist.x10 trunk/x10.dist/samples/HelloWholeWorld.x10 trunk/x10.dist/samples/KMeansSPMD.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v5.x10 trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 trunk/x10.runtime/src-x10/x10/array/BlockWorldDist.x10 trunk/x10.runtime/src-x10/x10/array/Dist.x10 trunk/x10.runtime/src-x10/x10/array/UniqueDist.x10 trunk/x10.runtime/src-x10/x10/lang/Place.x10 Modified: trunk/x10.dist/samples/FRASimpleDist.x10 =================================================================== --- trunk/x10.dist/samples/FRASimpleDist.x10 2010-10-04 21:31:34 UTC (rev 16950) +++ trunk/x10.dist/samples/FRASimpleDist.x10 2010-10-04 21:35:24 UTC (rev 16951) @@ -71,12 +71,12 @@ ) { finish for (var p:int=0; p<Place.MAX_PLACES; p++) { val valp = p; - at(Place.places(p)) async { + at(Place.place(p)) async { var ran:long = HPCC_starts(valp*(num_updates/Place.MAX_PLACES)); for (var i:long=0; i<num_updates/Place.MAX_PLACES; i++) { val placeId = ((ran>>logLocalTableSize) & (Place.MAX_PLACES-1)) as int; val ran2=ran; - async at(Place.places(placeId)) { + async at(Place.place(placeId)) { tables().update(ran2); } ran = (ran << 1) ^ (ran<0L ? POLY : 0L); @@ -119,10 +119,10 @@ // repeat for testing. randomAccessUpdate(num_updates, logLocalTableSize, tables); for (var i:int=0; i<Place.MAX_PLACES; i++) { - at(Place.places(i)) async { + at(Place.place(i)) async { val table = tables(); var err:int = 0; - for ([j] in table.a) // DYNAMIC_CHECK (because it is inside "async (Place.places(i)) {") + for ([j] in table.a) // DYNAMIC_CHECK (because it is inside "async (Place.place(i)) {") if (table.a(j) != j) err++; println("Found " + err + " errors."); } Modified: trunk/x10.dist/samples/FSSimpleDist.x10 =================================================================== --- trunk/x10.dist/samples/FSSimpleDist.x10 2010-10-04 21:31:34 UTC (rev 16950) +++ trunk/x10.dist/samples/FSSimpleDist.x10 2010-10-04 21:35:24 UTC (rev 16951) @@ -43,7 +43,7 @@ val p = pp; - async at(Place.places(p)) { + async at(Place.place(p)) { val a = new Array[double](localSize); val b = new Array[double](localSize); Modified: trunk/x10.dist/samples/HelloWholeWorld.x10 =================================================================== --- trunk/x10.dist/samples/HelloWholeWorld.x10 2010-10-04 21:31:34 UTC (rev 16950) +++ trunk/x10.dist/samples/HelloWholeWorld.x10 2010-10-04 21:35:24 UTC (rev 16951) @@ -17,7 +17,7 @@ */ class HelloWholeWorld { public static def main(Array[String]):void { - finish for (p in Place.places.items()) { + finish for (p in Place.places) { async at (p) Console.OUT.println("Hello World from place "+p.id); } } Modified: trunk/x10.dist/samples/KMeansSPMD.x10 =================================================================== --- trunk/x10.dist/samples/KMeansSPMD.x10 2010-10-04 21:31:34 UTC (rev 16950) +++ trunk/x10.dist/samples/KMeansSPMD.x10 2010-10-04 21:35:24 UTC (rev 16951) @@ -65,7 +65,7 @@ val file_points = new Array[Float](num_file_points*dim, init_points); //val team = Team.WORLD; - val team = Team(new Array[Place](num_slices * Place.MAX_PLACES, (i:int) => Place.places(i/num_slices))); + val team = Team(new Array[Place](num_slices * Place.MAX_PLACES, (i:int) => Place.place(i/num_slices))); val num_slice_points = num_global_points / num_slices / Place.MAX_PLACES; Modified: trunk/x10.dist/samples/tutorial/HeatTransfer_v5.x10 =================================================================== --- trunk/x10.dist/samples/tutorial/HeatTransfer_v5.x10 2010-10-04 21:31:34 UTC (rev 16950) +++ trunk/x10.dist/samples/tutorial/HeatTransfer_v5.x10 2010-10-04 21:35:24 UTC (rev 16951) @@ -53,8 +53,8 @@ // TODO: This is a really inefficient implementation of this abstraction. // Needs to be done properly and integrated into the Dist/Region/DistArray // class library in x10.array. - static def blockIt(d:Dist(2), numProcs:int):ValRail[Iterable[Point(2)]] { - val ans = ValRail.make(numProcs, (int) => new x10.util.ArrayList[Point{self.rank==d.rank}]()); + static def blockIt(d:Dist(2), numProcs:int):Rail[Iterable[Point(2)]] { + val ans = Rail.make(numProcs, (int) => new x10.util.ArrayList[Point{self.rank==d.rank}]()); var modulo:int = 0; for (p in d) { ans(modulo).add(p); @@ -69,7 +69,7 @@ val diff = DistArray.make[Double](D_Base); val scratch = DistArray.make[Double](D_Base); clocked ateach (z in D_Base) { - val blocks:ValRail[Iterable[Point(2)]] = blockIt(D | here, P); + val blocks:Rail[Iterable[Point(2)]] = blockIt(D | here, P); for ([q] in 0..P-1) clocked async { var myDiff:Double; do { Modified: trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 2010-10-04 21:31:34 UTC (rev 16950) +++ trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 2010-10-04 21:35:24 UTC (rev 16951) @@ -115,7 +115,7 @@ public def apply(pt:Point(rank)):Place { for (var i:int=0; i<regionMap.size; i++) { if (regionMap(i).contains(pt)) { - return Place.places(i); + return Place.place(i); } } raiseBoundsError(pt); @@ -268,7 +268,7 @@ public def equals(thatObj:Any): boolean { if (!(thatObj instanceof Dist)) return false; val that:Dist = thatObj as Dist; - for (p in Place.places.items()) + for (p in Place.places) if (!this.get(p).equals(that.get(p))) return false; return true; Modified: trunk/x10.runtime/src-x10/x10/array/BlockWorldDist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/BlockWorldDist.x10 2010-10-04 21:31:34 UTC (rev 16950) +++ trunk/x10.runtime/src-x10/x10/array/BlockWorldDist.x10 2010-10-04 21:35:24 UTC (rev 16951) @@ -45,7 +45,7 @@ def this(r:Region, axis:int):BlockWorldDist{this.region==r} { - super(r, false /* TODO: don't just assume this, check */, Place.MAX_PLACES==1, Place.places(0)); + super(r, false /* TODO: don't just assume this, check */, Place.MAX_PLACES==1, Place.place(0)); this.axis = axis; } @@ -101,13 +101,13 @@ public def places():Iterable[Place] { - return Place.places.items(); + return Place.places; } public def numPlaces():int = Place.MAX_PLACES; public def regions():Iterable[Region(rank)] { - return new Array[Region(rank)](Place.MAX_PLACES, (i:int)=>blockRegionForPlace(Place.places(i))).items(); + return new Array[Region(rank)](Place.MAX_PLACES, (i:int)=>blockRegionForPlace(Place.place(i))).items(); } public def get(p:Place):Region(rank) { Modified: trunk/x10.runtime/src-x10/x10/array/Dist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/Dist.x10 2010-10-04 21:31:34 UTC (rev 16950) +++ trunk/x10.runtime/src-x10/x10/array/Dist.x10 2010-10-04 21:35:24 UTC (rev 16951) @@ -425,7 +425,7 @@ * @return true if that is a sub-distribution of this distribution. */ public def isSubdistribution(that:Dist(rank)): boolean { - for (p:Place in Place.places.items()) + for (p:Place in Place.places) if (!that.get(p).contains(this.get(p))) return false; return true; Modified: trunk/x10.runtime/src-x10/x10/array/UniqueDist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/UniqueDist.x10 2010-10-04 21:31:34 UTC (rev 16950) +++ trunk/x10.runtime/src-x10/x10/array/UniqueDist.x10 2010-10-04 21:35:24 UTC (rev 16951) @@ -30,7 +30,7 @@ public def places():Iterable[Place] { - return Place.places.items(); + return Place.places; } public def numPlaces():int = Place.MAX_PLACES; @@ -53,11 +53,11 @@ public def apply(p:Place):Region(rank) = get(p); public def apply(pt:Point(rank)):Place { - return Place.places(pt(0)); + return Place.place(pt(0)); } public def apply(i0:int){rank==1} { - return Place.places(i0); + return Place.place(i0); } public def restriction(r:Region(rank)):Dist(rank) { Modified: trunk/x10.runtime/src-x10/x10/lang/Place.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Place.x10 2010-10-04 21:31:34 UTC (rev 16950) +++ trunk/x10.runtime/src-x10/x10/lang/Place.x10 2010-10-04 21:35:24 UTC (rev 16951) @@ -79,13 +79,14 @@ @Native("c++", "x10aux::child_index(#1)") public static def childIndex(id:Int):Int { throw new BadPlaceException(); } - public static places = new Array[Place](MAX_PLACES, ((id: Int) => Place(id))); - public static children = new Array[Array[Place](1)]( - ALL_PLACES, - (p: Int) => new Array[Place](numChildren(p), - (i:Int) => Place(child(p,i)))); + private static childrenArray = + new Array[Array[Place](1)](ALL_PLACES, + (p: Int) => new Array[Place](numChildren(p), (i:Int) => Place(child(p,i)))); + + public static places = new Array[Place](MAX_PLACES, ((id:Int) => Place(id))).items(); + public static children = childrenArray.items(); public static NUM_ACCELS = ALL_PLACES - MAX_PLACES; - public static FIRST_PLACE: Place(0) = places(0) as Place(0); + public static FIRST_PLACE:Place(0) = Place(0); public def this(id: Int):Place(id) { property(id); } @@ -113,9 +114,9 @@ public def numChildren() = numChildren(id); public def child(i:Int) = Place(child(id,i)); - public def children() = children(id); + public def children() = childrenArray(id); - public def parent() = places(parent(id)); + public def parent() = Place(parent(id)); public def childIndex() { if (isHost()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-10-07 14:31:27
|
Revision: 17161 http://x10.svn.sourceforge.net/x10/?rev=17161&view=rev Author: yzibin Date: 2010-10-07 14:31:21 +0000 (Thu, 07 Oct 2010) Log Message: ----------- fixed scope bug in AtEach_c (fixes half of XTENLANG-1902) Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/AtEach_c.java trunk/x10.compiler/src/x10/ast/AtStmt_c.java trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 Modified: trunk/x10.compiler/src/x10/ast/AtEach_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AtEach_c.java 2010-10-07 14:27:06 UTC (rev 17160) +++ trunk/x10.compiler/src/x10/ast/AtEach_c.java 2010-10-07 14:31:21 UTC (rev 17161) @@ -86,8 +86,9 @@ XTerm term = PlaceChecker.makePlace(); placeTerm = XConstrainedTerm.instantiate(d, term); } - - xc = (X10Context) xc.pushPlace(placeTerm); + + if (child == body) + xc = (X10Context) xc.pushPlace(placeTerm); } catch (XFailure z) { throw new InternalCompilerError("Cannot construct placeTerm from term and constraint."); Modified: trunk/x10.compiler/src/x10/ast/AtStmt_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AtStmt_c.java 2010-10-07 14:27:06 UTC (rev 17160) +++ trunk/x10.compiler/src/x10/ast/AtStmt_c.java 2010-10-07 14:31:21 UTC (rev 17161) @@ -202,7 +202,7 @@ X10Context xc = (X10Context) c; if (child == body) { if (placeTerm != null) - c = ((X10Context) c).pushPlace(placeTerm); + c = xc.pushPlace(placeTerm); } addDecls(c); } Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-07 14:27:06 UTC (rev 17160) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-07 14:31:21 UTC (rev 17161) @@ -1507,9 +1507,59 @@ var n: int = 1; at (here) n=2; finish ateach ([i] in a.dist | - (0..n)) { // todo ERR: it shouldn't give an error! + (0..n)) { // checks XTENLANG-1902 n++; // ERR: Local variable "n" is accessed at a different place, and must be declared final. } } +} + +class TestGlobalRefHomeAt { // see http://jira.codehaus.org/browse/XTENLANG-1905 + def test() { + val r = GlobalRef(this); + val r2 = r; + val r3 = GlobalRef(this); + + use(r()); + use(r2()); + use(r3()); + + at (r.home()) { + use(r()); + use(r2()); + use(r3()); // todo ERR + } + at (r2.home()) { + use(r()); // todo ERR + use(r2()); + use(r3());// todo ERR + } + at (r3.home()) { + use(r()); // todo ERR + use(r2()); // todo ERR + use(r3()); + } + at (here.next()) { + use(r()); // ERR + use(r2()); // ERR + use(r3()); // ERR + + at (r.home()) { + use(r()); + use(r2()); + use(r3()); // todo ERR + } + at (r2.home()) { + use(r()); // todo ERR + use(r2()); + use(r3());// todo ERR + } + at (r3.home()) { + use(r()); // todo ERR + use(r2()); // todo ERR + use(r3()); + } + } + } + def use(x:Any) {} } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2010-10-11 02:45:04
|
Revision: 17235 http://x10.svn.sourceforge.net/x10/?rev=17235&view=rev Author: vj0 Date: 2010-10-11 02:44:54 +0000 (Mon, 11 Oct 2010) Log Message: ----------- Initial fix for XTENLANG-1892. Implements correct definition of moreSpecificThan relation on method instances and constructor instances. Modified Paths: -------------- trunk/x10.compiler/src/polyglot/types/ConstructorInstance.java trunk/x10.compiler/src/polyglot/types/ConstructorInstance_c.java trunk/x10.compiler/src/polyglot/types/Matcher.java trunk/x10.compiler/src/polyglot/types/MethodInstance.java trunk/x10.compiler/src/polyglot/types/MethodInstance_c.java trunk/x10.compiler/src/polyglot/types/ProcedureInstance.java trunk/x10.compiler/src/polyglot/types/ProcedureInstance_c.java trunk/x10.compiler/src/polyglot/types/TypeEnv_c.java trunk/x10.compiler/src/polyglot/types/TypeSystem_c.java trunk/x10.compiler/src/x10/types/ClosureInstance_c.java trunk/x10.compiler/src/x10/types/MacroType_c.java trunk/x10.compiler/src/x10/types/X10ClassDef_c.java trunk/x10.compiler/src/x10/types/X10ConstructorInstance_c.java trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java trunk/x10.compiler/src/x10/types/X10TypeMixin.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/types/constraints/TypeConstraint.java trunk/x10.compiler/src/x10/types/matcher/Matcher.java trunk/x10.compiler/src/x10/types/matcher/X10MethodMatcher.java trunk/x10.runtime/src-x10/x10/array/Dist.x10 trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 trunk/x10.runtime/src-x10/x10/lang/Cell.x10 trunk/x10.runtime/src-x10/x10/lang/Complex.x10 trunk/x10.runtime/src-x10/x10/lang/String.x10 Added Paths: ----------- trunk/x10.compiler/src/x10/types/constraints/DepthBoundReached.java trunk/x10.compiler/src/x10/types/matcher/X10NamelessMethodMatcher.java Modified: trunk/x10.compiler/src/polyglot/types/ConstructorInstance.java =================================================================== --- trunk/x10.compiler/src/polyglot/types/ConstructorInstance.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/polyglot/types/ConstructorInstance.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -7,4 +7,6 @@ ConstructorInstance container(StructType container); ConstructorInstance formalTypes(List<Type> formalTypes); ConstructorInstance throwTypes(List<Type> throwTypes); + void setOrigMI(ConstructorInstance orig); + ConstructorInstance origMI(); } Modified: trunk/x10.compiler/src/polyglot/types/ConstructorInstance_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/types/ConstructorInstance_c.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/polyglot/types/ConstructorInstance_c.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -52,4 +52,11 @@ List<Type> argumentTypes) throws SemanticException { return this; } + protected ConstructorInstance origCI; + public void setOrigMI(ConstructorInstance ci) { + this.origCI = ci; + } + public ConstructorInstance origMI() { + return origCI; + } } Modified: trunk/x10.compiler/src/polyglot/types/Matcher.java =================================================================== --- trunk/x10.compiler/src/polyglot/types/Matcher.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/polyglot/types/Matcher.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -6,6 +6,7 @@ public interface Matcher<T> { T instantiate(T matched) throws SemanticException; + Name name(); String signature(); Modified: trunk/x10.compiler/src/polyglot/types/MethodInstance.java =================================================================== --- trunk/x10.compiler/src/polyglot/types/MethodInstance.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/polyglot/types/MethodInstance.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -53,4 +53,7 @@ boolean isSameMethod(MethodInstance mi, Context context); public MethodInstance returnTypeRef(Ref<? extends Type> returnType); + + void setOrigMI(MethodInstance orig); + MethodInstance origMI(); } Modified: trunk/x10.compiler/src/polyglot/types/MethodInstance_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/types/MethodInstance_c.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/polyglot/types/MethodInstance_c.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -99,4 +99,10 @@ public final List<MethodInstance> implemented(Context context) { return ts.implemented(this, context); } + + protected MethodInstance origMI; + public MethodInstance origMI() { return origMI;} + public void setOrigMI(MethodInstance origMI) { + this.origMI = origMI; + } } Modified: trunk/x10.compiler/src/polyglot/types/ProcedureInstance.java =================================================================== --- trunk/x10.compiler/src/polyglot/types/ProcedureInstance.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/polyglot/types/ProcedureInstance.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -40,7 +40,7 @@ * in terms of method overloading. * @param context TODO */ - boolean moreSpecific(ProcedureInstance<T> pi, Context context); + boolean moreSpecific(Type ct, ProcedureInstance<T> pi, Context context); /** * Returns true if the procedure has the given arguments. Modified: trunk/x10.compiler/src/polyglot/types/ProcedureInstance_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/types/ProcedureInstance_c.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/polyglot/types/ProcedureInstance_c.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -34,7 +34,7 @@ return this.formalTypes; } - + /** * Returns whether <code>this</code> is <i>more specific</i> than * <code>p</code>, where <i>more specific</i> is defined as JLS @@ -44,7 +44,11 @@ * does not include any info regarding Java 1.2, so all inner class * rules are found empirically using jikes and javac. */ - public boolean moreSpecific(ProcedureInstance<T> p, Context context) { + public boolean moreSpecific(Type container, ProcedureInstance<T> p, Context context) { + + // vj: Should never be invoked + assert false; + ProcedureInstance<T> p1 = this; ProcedureInstance<T> p2 = p; Modified: trunk/x10.compiler/src/polyglot/types/TypeEnv_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/types/TypeEnv_c.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/polyglot/types/TypeEnv_c.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -507,7 +507,7 @@ * <i>more specific</i> is defined as JLS 15.11.2.2 */ public <T extends ProcedureDef> boolean moreSpecific(ProcedureInstance<T> p1, ProcedureInstance<T> p2) { - return p1.moreSpecific(p2, context); + return p1.moreSpecific(null, p2, context); } /** @@ -817,7 +817,8 @@ * TODO */ public List<ConstructorInstance> findAcceptableConstructors(Type container, ConstructorMatcher matcher) throws SemanticException { - SemanticException error = null; + assert false; // should be overridden by X10TypeEnv_c.findAcceptableConstructors. + SemanticException error = null; List<ConstructorInstance> acceptable = new ArrayList<ConstructorInstance>(); Modified: trunk/x10.compiler/src/polyglot/types/TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/types/TypeSystem_c.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/polyglot/types/TypeSystem_c.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -808,6 +808,9 @@ public Context context() { return context; } + public Type container() { + return container; + } public Name name() { return Name.make("this"); @@ -861,6 +864,9 @@ n.container = container; return n; } + public Type container() { + return container; + } public MethodMatcher copy() { try { @@ -926,6 +932,9 @@ return context; } + public Type container() { + return container; + } public FieldMatcher container(Type container) { FieldMatcher n = copy(); n.container = container; @@ -977,6 +986,9 @@ this.context = context; } + public Type container() { + return container; + } public String signature() { return name.toString(); } @@ -1025,6 +1037,7 @@ return name; } + public Named instantiate(Named t) throws SemanticException { if (! t.name().equals(name)) { return null; @@ -1070,7 +1083,7 @@ } Collection<MethodInstance> maximal = - findMostSpecificProcedures(acceptable, (Matcher<MethodInstance>) matcher, context); + findMostSpecificProcedures(container, acceptable, (Matcher<MethodInstance>) matcher, context); if (maximal.size() > 1) { StringBuffer sb = new StringBuffer(); @@ -1126,11 +1139,17 @@ public <S extends ProcedureDef, T extends ProcedureInstance<S>> Collection<T> findMostSpecificProcedures(List<T> acceptable, Matcher<T> matcher, Context context) throws SemanticException { + return findMostSpecificProcedures(null, acceptable, matcher, context); + } + public <S extends ProcedureDef, T extends ProcedureInstance<S>> Collection<T> + findMostSpecificProcedures(Type container, List<T> acceptable, Matcher<T> matcher, Context context) + throws SemanticException { // now, use JLS 15.11.2.2 // First sort from most- to least-specific. - Comparator<T> msc = mostSpecificComparator(matcher, context); - acceptable = new ArrayList<T>(acceptable); // make into array list to sort + Comparator<T> msc = mostSpecificComparator(container, matcher, context); + ArrayList<T> acceptable2 = new ArrayList<T>(acceptable); // make into array list to sort + Collections.<T>sort(acceptable, msc); List<T> maximal = new ArrayList<T>(acceptable.size()); @@ -1190,7 +1209,7 @@ return maximal; } - protected <S extends ProcedureDef, T extends ProcedureInstance<S>> Comparator<T> mostSpecificComparator(Matcher<T> matcher, Context context) { + protected <S extends ProcedureDef, T extends ProcedureInstance<S>> Comparator<T> mostSpecificComparator(Type container, Matcher<T> matcher, Context context) { return new MostSpecificComparator<S,T>(context); } @@ -1230,15 +1249,17 @@ /** * Class to handle the comparisons; dispatches to moreSpecific method. */ - protected static class MostSpecificComparator<S extends ProcedureDef, T extends ProcedureInstance<S>> implements Comparator<T> { - Context context; + public static class MostSpecificComparator<S extends ProcedureDef, T extends ProcedureInstance<S>> implements Comparator<T> { + protected Context context; + public MostSpecificComparator(Context context) { this.context = context; + } public int compare(T p1, T p2) { - if (p1.moreSpecific(p2, context)) + if (p1.moreSpecific(null, p2, context)) return -1; - if (p2.moreSpecific(p1, context)) + if (p2.moreSpecific(null, p1, context)) return 1; return 0; } @@ -1301,12 +1322,13 @@ Report.report(3, "Trying " + mi); try { + MethodInstance oldmi = mi; mi = matcher.instantiate(mi); if (mi == null) { continue; } - + mi.setOrigMI(oldmi); if (isAccessible(mi, context)) { if (Report.should_report(Report.types, 3)) { Report.report(3, "->acceptable: " + mi + " in " Modified: trunk/x10.compiler/src/x10/types/ClosureInstance_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/ClosureInstance_c.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/x10/types/ClosureInstance_c.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -79,8 +79,8 @@ return true; } - public boolean moreSpecific(ProcedureInstance<ClosureDef> p, Context context) { - return X10TypeMixin.moreSpecificImpl(this, p, context); + public boolean moreSpecific(Type ct, ProcedureInstance<ClosureDef> p, Context context) { + return X10TypeMixin.moreSpecificImpl(ct, this, p, context); } public String signature() { Modified: trunk/x10.compiler/src/x10/types/MacroType_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/MacroType_c.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/x10/types/MacroType_c.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -400,8 +400,8 @@ } - public boolean moreSpecific(ProcedureInstance<TypeDef> p, Context context) { - return X10TypeMixin.moreSpecificImpl(this, p, context); + public boolean moreSpecific(Type ct, ProcedureInstance<TypeDef> p, Context context) { + return X10TypeMixin.moreSpecificImpl(ct, this, p, context); } public Type returnType() { Modified: trunk/x10.compiler/src/x10/types/X10ClassDef_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10ClassDef_c.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/x10/types/X10ClassDef_c.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -249,7 +249,7 @@ // Disable this for now since it can cause an infinite loop. // TODO: vj 08/12/09 Revisit this. - if (false && result.consistent()) { + /*if (false && result.consistent()) { // Verify that the realclause, as it stands, entails the assertions of the // property. for (X10FieldDef fi : properties) { @@ -265,14 +265,14 @@ new SemanticException("The real clause, " + result + ", does not satisfy constraints from " + fi + ".", position()); } } - } + }*/ } - catch (XFailure e) { + /* catch (XFailure e) { CConstraint result = new CConstraint(); result.setInconsistent(); this.rootClause = Types.ref(result); this.rootClauseInvalid = new SemanticException(e.getMessage(), position()); - } + }*/ finally { computing = false; } Modified: trunk/x10.compiler/src/x10/types/X10ConstructorInstance_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10ConstructorInstance_c.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/x10/types/X10ConstructorInstance_c.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -47,8 +47,18 @@ /** * An X10ConstructorInstance_c varies from a ConstructorInstance_c only in that it - * maintains a returnType. If an explicit returnType is not declared in the constructor - * then the returnType is simply a noClause variant of the container. + * maintains a returnType, and a guard. + * + * <p>If an explicit returnType is not declared in the constructor + * then the returnType is simply the container together with the constraints + * introduced by the property call in the body of the constructor (if the container has + * properties). + * + * <p> It also has a typeParameteres() method. This currently returns null. + * Constructor definitions may not specify type parameters. The type parameters of + * the container are intended to be in effect in the constructor declaration. + * + * * @author vj * */ @@ -61,8 +71,8 @@ } @Override - public boolean moreSpecific(ProcedureInstance<ConstructorDef> p, Context context) { - return X10TypeMixin.moreSpecificImpl(this, p, context); + public boolean moreSpecific(Type ct, ProcedureInstance<ConstructorDef> p, Context context) { + return X10TypeMixin.moreSpecificImpl(ct, this, p, context); } public X10ConstructorDef x10Def() { Modified: trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/x10/types/X10MethodInstance_c.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -56,8 +56,8 @@ import x10.types.matcher.Matcher; /** - * A representation of a MethodInstance. This implements the requirement that method - * annotations such as sequential, local, nonblocking, safe are preserved on overriding. + * A representation of a MethodInstance. + * * @author vj * */ @@ -69,8 +69,8 @@ } @Override - public boolean moreSpecific(ProcedureInstance<MethodDef> p, Context context) { - return X10TypeMixin.moreSpecificImpl(this, p, context); + public boolean moreSpecific(Type container, ProcedureInstance<MethodDef> p, Context context) { + return X10TypeMixin.moreSpecificImpl(container, this, p, context); } public static class NoClauseVariant implements Transformation<Type, Type> { @@ -219,9 +219,10 @@ } public static void buildSubst(X10MethodInstance mi, List<XVar> ys, List<XVar> xs, XVar thisVar) { - if (mi.x10Def().thisVar() != null && mi.x10Def().thisVar() != thisVar) { + XVar mdThisVar = mi.x10Def().thisVar(); + if (mdThisVar != null && mdThisVar != thisVar && ! xs.contains(mdThisVar)) { ys.add(thisVar); - xs.add(mi.x10Def().thisVar()); + xs.add(mdThisVar); } buildSubst(mi.container(), ys, xs, thisVar); @@ -231,7 +232,8 @@ Type container = X10TypeMixin.baseType(t); if (container instanceof X10ClassType) { X10ClassDef cd = ((X10ClassType) container).x10Def(); - if (cd.thisVar() != null && cd.thisVar() != thisVar) { + XVar cdThisVar = cd.thisVar(); + if (cdThisVar != null && cdThisVar != thisVar && ! xs.contains(cdThisVar) ) { ys.add(thisVar); xs.add(cd.thisVar()); } Modified: trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -188,29 +188,30 @@ } } + public void checkOverride(ClassType ct, MethodInstance mi0, MethodInstance mj0) throws SemanticException { - X10MethodInstance mi = (X10MethodInstance) mi0; - X10MethodInstance mj = (X10MethodInstance) mj0; + X10MethodInstance mi = (X10MethodInstance) mi0; + X10MethodInstance mj = (X10MethodInstance) mj0; - XVar thisVar = XTerms.makeUQV(XTerms.makeFreshName("this")); // XTerms.makeLocal(XTerms.makeFreshName("this")); + XVar thisVar = XTerms.makeUQV(XTerms.makeFreshName("this")); // XTerms.makeLocal(XTerms.makeFreshName("this")); - List<XVar> ys = new ArrayList<XVar>(2); - List<XVar> xs = new ArrayList<XVar>(2); + List<XVar> ys = new ArrayList<XVar>(2); + List<XVar> xs = new ArrayList<XVar>(2); - X10MethodInstance_c.buildSubst(ct, ys, xs, thisVar); - X10MethodInstance_c.buildSubst(mi, ys, xs, thisVar); - X10MethodInstance_c.buildSubst(mj, ys, xs, thisVar); - final XVar[] y = ys.toArray(new XVar[ys.size()]); - final XVar[] x = xs.toArray(new XVar[ys.size()]); + X10MethodInstance_c.buildSubst(ct, ys, xs, thisVar); + X10MethodInstance_c.buildSubst(mi, ys, xs, thisVar); + X10MethodInstance_c.buildSubst(mj, ys, xs, thisVar); + final XVar[] y = ys.toArray(new XVar[ys.size()]); + final XVar[] x = xs.toArray(new XVar[ys.size()]); - Context cxt = context; // PlaceChecker.pushHereTerm(mi.def(), (X10Context) context); - X10TypeEnv_c newEnv = new X10TypeEnv_c(cxt); - mi = newEnv.fixThis(mi, y, x); - mj = newEnv.fixThis(mj, y, x); + Context cxt = context; // PlaceChecker.pushHereTerm(mi.def(), (X10Context) context); + X10TypeEnv_c newEnv = new X10TypeEnv_c(cxt); + mi = newEnv.fixThis(mi, y, x); + mj = newEnv.fixThis(mj, y, x); - // Force evaluation to help debugging. - mi.returnType(); - mj.returnType(); + // Force evaluation to help debugging. + mi.returnType(); + mj.returnType(); newEnv.checkOverride(mi, mj, true); } @@ -511,7 +512,7 @@ // worklist.addAll(b); // } - // Expand macros, remove constraints + // Expand macros Type expanded = X10TypeMixin.baseType(w); if (expanded instanceof ParameterType) { ParameterType pt = (ParameterType) expanded; @@ -1929,12 +1930,13 @@ Report.report(3, "Trying " + ci); try { + ConstructorInstance oldCI = ci; ci = matcher.instantiate(ci); if (ci == null) { continue; } - + ci.setOrigMI(oldCI); if (isAccessible(ci)) { if (Report.should_report(Report.types, 3)) Report.report(3, "->acceptable: " + ci); Modified: trunk/x10.compiler/src/x10/types/X10TypeMixin.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -36,12 +36,16 @@ import polyglot.types.Flags; import polyglot.types.LazyRef_c; import polyglot.types.MemberInstance; +import polyglot.types.MethodDef; import polyglot.types.MethodInstance; import polyglot.types.Name; +import polyglot.types.ProcedureDef; import polyglot.types.ProcedureInstance; import polyglot.types.Ref; import polyglot.types.SemanticException; +import polyglot.types.StructType; import polyglot.types.Type; +import polyglot.types.TypeSystem_c.MethodMatcher; import polyglot.types.Types; import polyglot.types.UnknownType; import polyglot.types.QName; @@ -59,14 +63,18 @@ import x10.ast.AnnotationNode; import x10.constraint.XFailure; import x10.constraint.XLit; +import x10.constraint.XName; import x10.constraint.XNameWrapper; import x10.constraint.XVar; import x10.constraint.XTerm; import x10.constraint.XTerms; import x10.errors.Errors; import x10.types.constraints.CConstraint; +import x10.types.constraints.DepthBoundReached; import x10.types.constraints.TypeConstraint; import x10.types.constraints.XConstrainedTerm; +import x10.types.matcher.Matcher; +import x10.types.matcher.X10NamelessMethodMatcher; import x10.extension.X10Del; /** @@ -1258,12 +1266,13 @@ return null; } - public static boolean moreSpecificImpl(ProcedureInstance<?> p1, ProcedureInstance<?> p2, Context context) { - X10TypeSystem ts = (X10TypeSystem) p1.typeSystem(); + public static boolean moreSpecificImpl(Type ct, ProcedureInstance<?> xp1, ProcedureInstance<?> xp2, Context context) { + X10TypeSystem ts = (X10TypeSystem) xp1.typeSystem(); + Type ct1 = xp2 instanceof MemberInstance<?> ? ((MemberInstance<?>) xp1).container() : null; + Type ct2 = xp2 instanceof MemberInstance<?> ? ((MemberInstance<?>) xp2).container() : null; - Type t1 = p1 instanceof MemberInstance<?> ? ((MemberInstance<?>) p1).container() : null; - Type t2 = p2 instanceof MemberInstance<?> ? ((MemberInstance<?>) p2).container() : null; - + Type t1 = ct1; + Type t2 = ct2; if (t1 != null && t2 != null) { t1 = baseType(t1); t2 = baseType(t2); @@ -1271,22 +1280,35 @@ boolean descends = t1 != null && t2 != null && ts.descendsFrom(ts.classDefOf(t1), ts.classDefOf(t2)); - Flags flags1 = p1 instanceof MemberInstance<?> ? ((MemberInstance<?>) p1).flags() : Flags.NONE; - Flags flags2 = p2 instanceof MemberInstance<?> ? ((MemberInstance<?>) p2).flags() : Flags.NONE; + Flags flags1 = xp1 instanceof MemberInstance<?> ? ((MemberInstance<?>) xp1).flags() : Flags.NONE; + Flags flags2 = xp2 instanceof MemberInstance<?> ? ((MemberInstance<?>) xp2).flags() : Flags.NONE; // A static method in a subclass is always more specific. // Note: this rule differs from Java but avoids an anomaly with conversion methods. if (descends && ! ts.hasSameClassDef(t1, t2) && flags1.isStatic() && flags2.isStatic()) { return true; } - - - + boolean java = javaStyleMoreSpecificMethod(xp1, xp2, (X10Context) context, ts, ct1, t1, t2,descends); + boolean old = oldStyleMoreSpecificMethod(xp1, xp2, (X10Context) context, ts, ct1, t1, t2, descends); + if (java != old) { + System.out.println("Discrepency in moreSpecific computation for:" + + "\n\t: p1: " + xp1 + + "\n\t: at " + xp1.position() + + "\n\t: p2: " + xp2 + + "\n\t: at " + xp2.position() + + "\n\t: java/old=" + java + "/" + old); + } + return java; + } + private static boolean oldStyleMoreSpecificMethod( + ProcedureInstance<?> xp1, ProcedureInstance<?> xp2, + Context context, X10TypeSystem ts, Type ct1, Type t1, Type t2, + boolean descends) { // if the formal params of p1 can be used to call p2, p1 is more specific - if (p1.formalTypes().size() == p2.formalTypes().size() ) { - for (int i = 0; i < p1.formalTypes().size(); i++) { - Type f1 = p1.formalTypes().get(i); - Type f2 = p2.formalTypes().get(i); + if (xp1.formalTypes().size() == xp2.formalTypes().size() ) { + for (int i = 0; i < xp1.formalTypes().size(); i++) { + Type f1 = xp1.formalTypes().get(i); + Type f2 = xp2.formalTypes().get(i); // Ignore constraints. This avoids an anomaly with the translation with erased constraints // having inverting the result of the most-specific test. Fixes XTENLANG-455. Type b1 = baseType(f1); @@ -1298,9 +1320,9 @@ } // If the formal types are all equal, check the containers; otherwise p1 is more specific. - for (int i = 0; i < p1.formalTypes().size(); i++) { - Type f1 = p1.formalTypes().get(i); - Type f2 = p2.formalTypes().get(i); + for (int i = 0; i < xp1.formalTypes().size(); i++) { + Type f1 = xp1.formalTypes().get(i); + Type f2 = xp2.formalTypes().get(i); if (! ts.typeEquals(f1, f2, context)) { return true; } @@ -1321,7 +1343,94 @@ return true; } + private static boolean javaStyleMoreSpecificMethod( + ProcedureInstance<?> xp1, ProcedureInstance<?> xp2, + X10Context context, X10TypeSystem ts, Type ct1, Type t1, Type t2, + boolean descends) { + assert xp1 != null; + assert xp2 != null; + List<Type> typeArgs = Collections.<Type>emptyList(); + try { + if (xp2 instanceof X10MethodInstance) { + // For X10 2.1, instance generic methods + // are not supported. Hence ThisMI is the same as MI. + + // Static methods cannot refer to class type parameters, hence + // the only type instantiations introduced in MI are for + // method type parameters. Also, static methods cannot refer to this + // hence there are no this constraints to transfer over. + // Therefore ThisMI is the same as OrigMI. + X10MethodInstance xmi2 = (X10MethodInstance) xp2; + + X10MethodInstance thisMI2 = // xmi2.flags().isStatic() ? + (X10MethodInstance) xmi2.origMI(); + //: xmi2; + assert thisMI2 != null; + + if (! (xp1 instanceof X10MethodInstance)) + return false; + X10MethodInstance xmi1 = (X10MethodInstance) xp1; + X10MethodInstance thisMI1 = // xmi1.flags().isStatic() ? + (X10MethodInstance)xmi1.origMI(); + //: xmi1; + if (thisMI1 == null) + assert thisMI1 != null; + //typeArgs = thisMI1.typeParameters(); + List<Type> argTypes = new ArrayList<Type>(thisMI1.formalTypes()); + if (xp2.formalTypes().size() != argTypes.size()) + return false; + if (typeArgs.isEmpty() || typeArgs.size() == xmi2.typeParameters().size()) { + MethodInstance r = Matcher.inferAndCheckAndInstantiate(context, + thisMI2, ct1, typeArgs, argTypes, xp2.position()); + if (r == null) + return false; + } + } else if (xp2 instanceof X10ConstructorInstance) { + X10ConstructorInstance xmi2 = (X10ConstructorInstance) xp2; + if (! (xp1 instanceof X10ConstructorInstance)) + return false; + X10ConstructorInstance origMI1 = (X10ConstructorInstance) ((X10ConstructorInstance) xp1).origMI(); + List<Type> argTypes = new ArrayList<Type>(origMI1.formalTypes()); + if (xp2.formalTypes().size() != argTypes.size()) + return false; + X10ConstructorInstance origMI2 = (X10ConstructorInstance) xmi2.origMI(); + X10ConstructorInstance r = Matcher.inferAndCheckAndInstantiate( context, + origMI2, ct1, typeArgs, argTypes, xp2.position()); + if (r == null) + return false; + } else { + System.out.println("Unhandled MoreSpecificMatcher case: " + xp2 + " class " + xp2.getClass()); + assert false; + } + } catch (SemanticException z) { + return false; + } + // If the formal types are all equal, check the containers; otherwise p1 is more specific. + for (int i = 0; i < xp1.formalTypes().size(); i++) { + Type f1 = xp1.formalTypes().get(i); + Type f2 = xp2.formalTypes().get(i); + if (! ts.typeEquals(f1, f2, context)) { + return true; + } + } + + if (t1 != null && t2 != null) { + // If p1 overrides p2 or if p1 is in an inner class of p2, pick p1. + if (descends) { + return true; + } + if (t1.isClass() && t2.isClass()) { + if (t1.toClass().isEnclosed(t2.toClass())) { + return true; + } + } + return false; + } + + return true; + } + public static void checkMissingParameters(Receiver receiver) throws SemanticException { Type xt = receiver.type(); checkMissingParameters(xt,receiver.position()); Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -43,6 +43,7 @@ import polyglot.types.InitializerDef; import polyglot.types.LazyRef; import polyglot.types.LocalDef; +import polyglot.types.LocalInstance; import polyglot.types.Matcher; import polyglot.types.MethodDef; import polyglot.types.MethodInstance; @@ -52,6 +53,7 @@ import polyglot.types.NoMemberException; import polyglot.types.NullType; import polyglot.types.ObjectType; +import polyglot.types.ParsedClassType; import polyglot.types.PrimitiveType; import polyglot.types.ProcedureDef; import polyglot.types.ProcedureInstance; @@ -67,6 +69,7 @@ import polyglot.types.Types; import polyglot.types.UnknownType; import polyglot.types.VarDef; +import polyglot.types.TypeSystem_c.MostSpecificComparator; import polyglot.util.CollectionUtil; import polyglot.util.ErrorInfo; import polyglot.util.InternalCompilerError; @@ -371,25 +374,34 @@ return env(context).findAcceptableTypeDefs(container, matcher); } + @Override + protected <S extends ProcedureDef, T extends ProcedureInstance<S>> Comparator<T> mostSpecificComparator(Type ct, Matcher<T> matcher, Context context) { + return new X10MostSpecificComparator<S,T>(ct, matcher, context); + } protected static class X10MostSpecificComparator<S extends ProcedureDef, T extends ProcedureInstance<S>> extends MostSpecificComparator<S, T> { private Matcher<T> matcher; + Type container; - protected X10MostSpecificComparator(Matcher<T> matcher, Context context) { + protected X10MostSpecificComparator(Type container, Matcher<T> matcher, Context context) { super(context); this.matcher = matcher; + this.container=container; } + + public int compare(T p1, T p2) { + if (p1.moreSpecific(container, p2, context)) + return -1; + if (p2.moreSpecific(container, p1, context)) + return 1; + return 0; + } - public int compare(T p1, T p2) { - int cmp = super.compare(p1, p2); - return cmp; + public Type container() { + return container; } + } - @Override - protected <S extends ProcedureDef, T extends ProcedureInstance<S>> Comparator<T> mostSpecificComparator(Matcher<T> matcher, Context context) { - return new X10MostSpecificComparator<S, T>(matcher, context); - } - private boolean contains(Collection<Type> c, Type x) { Context cxt = emptyContext(); for (Type t : c) { Added: trunk/x10.compiler/src/x10/types/constraints/DepthBoundReached.java =================================================================== --- trunk/x10.compiler/src/x10/types/constraints/DepthBoundReached.java (rev 0) +++ trunk/x10.compiler/src/x10/types/constraints/DepthBoundReached.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -0,0 +1,18 @@ +package x10.types.constraints; + +import x10.constraint.XFailure; +import x10.constraint.XTerm; + +public class DepthBoundReached extends Exception { + XTerm t; + CConstraint c = new CConstraint(); + public void addIn(CConstraint c) { + try { + CConstraint d = this.c.addIn(c); + } catch (XFailure z) { + c.setInconsistent(); + } + } + public CConstraint constraint() { return c;} + public DepthBoundReached(XTerm t) { this.t=t;} +} \ No newline at end of file Property changes on: trunk/x10.compiler/src/x10/types/constraints/DepthBoundReached.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: trunk/x10.compiler/src/x10/types/constraints/TypeConstraint.java =================================================================== --- trunk/x10.compiler/src/x10/types/constraints/TypeConstraint.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/x10/types/constraints/TypeConstraint.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -295,7 +295,8 @@ } - public static <PI extends X10ProcedureInstance<?>> Type[] inferTypeArguments(PI me, Type thisType, List<Type> actuals, List<Type> formals, List<Type> typeFormals, X10Context context) throws SemanticException { + public static <PI extends X10ProcedureInstance<?>> Type[] inferTypeArguments(PI me, Type thisType, List<Type> actuals, List<Type> formals, + List<Type> typeFormals, X10Context context) throws SemanticException { X10TypeSystem xts = (X10TypeSystem) thisType.typeSystem(); TypeConstraint tenv = new TypeConstraint(); @@ -333,6 +334,7 @@ Type ytype = new ParameterType_c(xts, me.position(), Name.makeFresh(), Types.ref((X10ProcedureDef) me.def())); // TODO: should enforce this statically + if (! (xtype instanceof ParameterType)) assert xtype instanceof ParameterType : xtype + " is not a ParameterType, is a " + (xtype != null ? xtype.getClass().getName() : "null"); tenv.addTerm(new SubtypeConstraint(xtype, ytype, true)); @@ -576,8 +578,14 @@ Y[i] = upperBound; else if (lowerBound != null) Y[i] = lowerBound; - else - throw new SemanticException("Could not infer type for type parameter " + X[i] + ".", me.position()); + else { + System.err.println("Diagnostic: No constraint on type parameters. " + + + "Returning Any instead of throwing an exception." + + (X[i] != null ? "\n\t: Position: " + X[i].position().toString() : "")); + Y[i] = xts.Any(); + // throw new SemanticException("Could not infer type for type parameter " + X[i] + ".", me.position()); + } } } } Modified: trunk/x10.compiler/src/x10/types/matcher/Matcher.java =================================================================== --- trunk/x10.compiler/src/x10/types/matcher/Matcher.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/x10/types/matcher/Matcher.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -60,6 +60,11 @@ */ public class Matcher { + // Generic method resolution interacts with type inference. + // The new (2.1) semantics requires that for instance methods, given a this Type + // t and a method name m and actual type args, we proceed in two stages. + // First we determine the set S of applicable and available methods. + // public static <PI extends X10ProcedureInstance<?>> PI inferAndCheckAndInstantiate(X10Context context, PI me, Type thisType, List<Type> typeActuals, @@ -102,7 +107,7 @@ * @return -- An instantiated version of me, with actuals substituted for formals in actual types and return types. * @throws SemanticException */ - static <PI extends X10ProcedureInstance<?>> PI instantiate2(final X10Context context, final PI me, + private static <PI extends X10ProcedureInstance<?>> PI instantiate2(final X10Context context, final PI me, /*inout*/ Type[] thisTypeArray, List<Type> typeActuals, List<Type> actuals, @@ -343,8 +348,8 @@ final List<Type> myFormals = new ArrayList<Type>(newMe.formalTypes()); // copy for (int i = 0; i < formals.size(); i++) { - Type ytype = actuals.get(i); - Type xtype = Subst.subst(formals.get(i), y2eqv, x2, Y, X); + Type ytype = Subst.subst(actuals.get(i), y2eqv, x2, Y, X); + Type xtype = Subst.subst(myFormals.get(i), y2eqv, x2, Y, X); if (! xts.consistent(xtype, context2)) { throw new SemanticException("Parameter type " + xtype + " of call is inconsistent in calling context."); Modified: trunk/x10.compiler/src/x10/types/matcher/X10MethodMatcher.java =================================================================== --- trunk/x10.compiler/src/x10/types/matcher/X10MethodMatcher.java 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.compiler/src/x10/types/matcher/X10MethodMatcher.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -36,6 +36,7 @@ this.typeArgs = typeArgs; } + public List<Type> arguments() { return argTypes; } Added: trunk/x10.compiler/src/x10/types/matcher/X10NamelessMethodMatcher.java =================================================================== --- trunk/x10.compiler/src/x10/types/matcher/X10NamelessMethodMatcher.java (rev 0) +++ trunk/x10.compiler/src/x10/types/matcher/X10NamelessMethodMatcher.java 2010-10-11 02:44:54 UTC (rev 17235) @@ -0,0 +1,61 @@ + + /* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + + package x10.types.matcher; + + import java.util.Collections; + import java.util.List; + + import polyglot.types.Context; + import polyglot.types.MethodInstance; + import polyglot.types.Name; + import polyglot.types.SemanticException; + import polyglot.types.Type; + import polyglot.types.TypeSystem_c; + import polyglot.util.CollectionUtil; + import x10.types.X10Context; + import x10.types.X10MethodInstance; + + public class X10NamelessMethodMatcher extends TypeSystem_c.MethodMatcher { + protected List<Type> typeArgs; + + + + public X10NamelessMethodMatcher(Type container, List<Type> typeArgs, List<Type> argTypes, Context context) { + super(container, null, argTypes, context); + this.typeArgs = typeArgs; + } + + public List<Type> arguments() { + return argTypes; + } + + @Override + public String argumentString() { + return (typeArgs.isEmpty() ? "" : "[" + CollectionUtil.listToString(typeArgs) + "]") + "(" + CollectionUtil.listToString(argTypes) + ")"; + } + + @Override + public MethodInstance instantiate(MethodInstance mi) throws SemanticException { + if (mi.formalTypes().size() != argTypes.size()) + return null; + if (mi instanceof X10MethodInstance) { + X10MethodInstance xmi = (X10MethodInstance) mi; + Type c = container != null ? container : xmi.container(); + if (typeArgs.isEmpty() || typeArgs.size() == xmi.typeParameters().size()) + return Matcher.inferAndCheckAndInstantiate((X10Context) context, + xmi, c, typeArgs, argTypes, mi.position()); + } + return null; + } + } + Property changes on: trunk/x10.compiler/src/x10/types/matcher/X10NamelessMethodMatcher.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: trunk/x10.runtime/src-x10/x10/array/Dist.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/Dist.x10 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.runtime/src-x10/x10/array/Dist.x10 2010-10-11 02:44:54 UTC (rev 17235) @@ -568,7 +568,7 @@ var first:boolean = true; for (p:Place in places()) { if (!first) s += ","; - s += get(p) + "->" + p.id; + s += "" + get(p) + "->" + p.id; first = false; } s += ")"; Modified: trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.runtime/src-x10/x10/array/RectRegion.x10 2010-10-11 02:44:54 UTC (rev 17235) @@ -379,7 +379,7 @@ var s: String = "["; for (var i: int = 0; i<rank; i++) { if (i>0) s += ","; - s += thisMin(i) + ".." + thisMax(i); + s += "" + thisMin(i) + ".." + thisMax(i); } s += "]"; return s; Modified: trunk/x10.runtime/src-x10/x10/lang/Cell.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Cell.x10 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.runtime/src-x10/x10/lang/Cell.x10 2010-10-11 02:44:54 UTC (rev 17235) @@ -88,7 +88,7 @@ * @param x the given Cell * @return the value stored in the given Cell. */ - public static operator[T](x:Cell[T]) = x(); + public static operator[V](x:Cell[V]) = x(); /** * Create a new Cell with the given value stored in it. @@ -97,7 +97,7 @@ * @param x the given value * @return a new Cell with the given value stored in it. */ - public static operator[T](x:T) = make[T](x); + public static operator[W](x:W) = make[W](x); } // vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-x10/x10/lang/Complex.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Complex.x10 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.runtime/src-x10/x10/lang/Complex.x10 2010-10-11 02:44:54 UTC (rev 17235) @@ -224,7 +224,7 @@ * @return the string representation of this complex number. */ public def toString():String { - return (re + " + " + im + "i"); + return ("" + re + " + " + im + "i"); } } Modified: trunk/x10.runtime/src-x10/x10/lang/String.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/String.x10 2010-10-11 01:00:35 UTC (rev 17234) +++ trunk/x10.runtime/src-x10/x10/lang/String.x10 2010-10-11 02:44:54 UTC (rev 17235) @@ -529,8 +529,9 @@ * @param x the given entity * @param y the given String * @return the resulting String - */ + @Native("java", "((#4) + (#5))") @Native("c++", "((#4) + (#5))") public native static operator[T] (x:T) + (y:String): String; + */ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-10-12 18:02:14
|
Revision: 17313 http://x10.svn.sourceforge.net/x10/?rev=17313&view=rev Author: yzibin Date: 2010-10-12 18:02:05 +0000 (Tue, 12 Oct 2010) Log Message: ----------- Cleaned up many MustFailCompile (they haven't been updated in ages). Removed non-relevant test cases (like "rooted" keyword, future that tests place locality which is irrelevant in the new object model of 2.1), renamed Fib and Integrate since they also exists in work-stealing dir. Modified Paths: -------------- trunk/x10.tests/examples/Constructs/Async/AsyncTest4_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 trunk/x10.tests/examples/Constructs/DepType/NonFinalField_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/NonFinalVariable_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/PropertyMustBeAssignedInConsBody_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/PropertyNotInvoked_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/SamePropertyAncestor_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/SameSignatureMethod_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/SelfFieldLocalVarShadow_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/UninitializedProperty_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Generics/GenericInference1_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Inference/Inference7a.x10 trunk/x10.tests/examples/Constructs/Structs/StructCannotSubclassClass_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint3g_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType4_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject4_MustFailCompile.x10 trunk/x10.tests/examples/Issues/XTENLANG_1565_MustFailCompile.x10 trunk/x10.tests/examples/Samples/FibTest.x10 trunk/x10.tests/examples/Samples/IntegrateTest.x10 Added Paths: ----------- trunk/x10.dist/samples/tutorial/Fibonacci.x10 trunk/x10.dist/samples/tutorial/IntegrateTutorial.x10 Removed Paths: ------------- trunk/x10.dist/samples/tutorial/Fib.x10 trunk/x10.dist/samples/tutorial/Integrate.x10 trunk/x10.tests/examples/Constructs/DepType/SameNameGuardedFieldAccess_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureFieldAccessStatic_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureMethodInvokeRev_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureMethodInvokeStatic_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureMethodInvoke_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccessRev_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccessStatic_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccess_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/PlaceCheckInRail2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/PlaceCheckInRail_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Place/PlaceCheckStringBuilder_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Rooted/ Deleted: trunk/x10.dist/samples/tutorial/Fib.x10 =================================================================== --- trunk/x10.dist/samples/tutorial/Fib.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.dist/samples/tutorial/Fib.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -1,52 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import x10.io.Console; - -/** - * This is a small program to illustrate the use of - * <code>async</code> and <code>finish</code> in a - * prototypical recursive divide-and-conquer algorithm. - * It is obviously not intended to show a efficient way to - * compute Fibonacci numbers in X10.<p> - * - * The heart of the example is the <code>run</code> method, - * which directly embodies the recursive definition of - * <pre> - * Fib(n) = Fib(n-1)+Fib(n-2); - * </pre> - * by using an <code>async</code> to compute <code>Fib(n-1)</code> while - * the current activity computes <code>Fib(n-2)</code>. A <code>finish</code> - * is used to ensure that both computations are complete before - * their results are added together to compute <code>Fib(n)</code> - */ -public class Fib { - - public static def fib(n:int) { - if (n<=2) return 1; - - val f1:int; - val f2:int; - finish { - async { f1 = fib(n-1); } - f2 = fib(n-2); - } - return f1 + f2; - } - - public static def main(args:Array[String](1)) { - val n = (args.size > 0) ? int.parse(args(0)) : 10; - Console.OUT.println("Computing Fib("+n+")"); - val f = fib(n); - Console.OUT.println("Fib("+n+") = "+f); - } -} - Copied: trunk/x10.dist/samples/tutorial/Fibonacci.x10 (from rev 17307, trunk/x10.dist/samples/tutorial/Fib.x10) =================================================================== --- trunk/x10.dist/samples/tutorial/Fibonacci.x10 (rev 0) +++ trunk/x10.dist/samples/tutorial/Fibonacci.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -0,0 +1,52 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import x10.io.Console; + +/** + * This is a small program to illustrate the use of + * <code>async</code> and <code>finish</code> in a + * prototypical recursive divide-and-conquer algorithm. + * It is obviously not intended to show a efficient way to + * compute Fibonacci numbers in X10.<p> + * + * The heart of the example is the <code>run</code> method, + * which directly embodies the recursive definition of + * <pre> + * fib(n) = fib(n-1)+fib(n-2); + * </pre> + * by using an <code>async</code> to compute <code>fib(n-1)</code> while + * the current activity computes <code>fib(n-2)</code>. A <code>finish</code> + * is used to ensure that both computations are complete before + * their results are added together to compute <code>fib(n)</code> + */ +public class Fibonacci { + + public static def fib(n:int) { + if (n<=2) return 1; + + val f1:int; + val f2:int; + finish { + async { f1 = fib(n-1); } + f2 = fib(n-2); + } + return f1 + f2; + } + + public static def main(args:Array[String](1)) { + val n = (args.size > 0) ? int.parse(args(0)) : 10; + Console.OUT.println("Computing fib("+n+")"); + val f = fib(n); + Console.OUT.println("fib("+n+") = "+f); + } +} + Deleted: trunk/x10.dist/samples/tutorial/Integrate.x10 =================================================================== --- trunk/x10.dist/samples/tutorial/Integrate.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.dist/samples/tutorial/Integrate.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -1,55 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -/** - * This is a slightly more realistic example of the - * basic computational pattern of using async/finish - * to express recursive divide-and-conquer algorithms. - * The program does integration via Guassian Quadrature. - * <p> - * It also can serve as an example of using a closure. - */ -public class Integrate { - static val epsilon = 1.0e-9; - - val fun:(double)=>double; - - public def this(f:(double)=>double) { fun = f; } - - public def computeArea(left:double, right:double) { - return recEval(left, fun(left), right, fun(right), 0); - } - - private def recEval(l:double, fl:double, r:double, fr:double, a:double) { - val h = (r - l) / 2; - val hh = h / 2; - val c = l + h; - val fc = fun(c); - val al = (fl + fc) * hh; - val ar = (fr + fc) * hh; - val alr = al + ar; - if (Math.abs(alr - a) < epsilon) return alr; - val expr1:double; - val expr2:double; - finish { - async { expr1 = recEval(c, fc, r, fr, ar); }; - expr2 = recEval(l, fl, c, fc, al); - } - return expr1 + expr2; - } - - public static def main(args:Array[String](1)) { - val obj = new Integrate((x:double)=>(x*x + 1.0) * x); - val xMax = args.size > 0 ? Int.parse(args(0)) : 10; - val area = obj.computeArea(0, xMax); - Console.OUT.println("The area of (x*x +1) * x from 0 to "+xMax+" is "+area); - } -} Copied: trunk/x10.dist/samples/tutorial/IntegrateTutorial.x10 (from rev 17307, trunk/x10.dist/samples/tutorial/Integrate.x10) =================================================================== --- trunk/x10.dist/samples/tutorial/IntegrateTutorial.x10 (rev 0) +++ trunk/x10.dist/samples/tutorial/IntegrateTutorial.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -0,0 +1,55 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +/** + * This is a slightly more realistic example of the + * basic computational pattern of using async/finish + * to express recursive divide-and-conquer algorithms. + * The program does integration via Guassian Quadrature. + * <p> + * It also can serve as an example of using a closure. + */ +public class IntegrateTutorial { + static val epsilon = 1.0e-9; + + val fun:(double)=>double; + + public def this(f:(double)=>double) { fun = f; } + + public def computeArea(left:double, right:double) { + return recEval(left, fun(left), right, fun(right), 0); + } + + private def recEval(l:double, fl:double, r:double, fr:double, a:double) { + val h = (r - l) / 2; + val hh = h / 2; + val c = l + h; + val fc = fun(c); + val al = (fl + fc) * hh; + val ar = (fr + fc) * hh; + val alr = al + ar; + if (Math.abs(alr - a) < epsilon) return alr; + val expr1:double; + val expr2:double; + finish { + async { expr1 = recEval(c, fc, r, fr, ar); }; + expr2 = recEval(l, fl, c, fc, al); + } + return expr1 + expr2; + } + + public static def main(args:Array[String](1)) { + val obj = new IntegrateTutorial((x:double)=>(x*x + 1.0) * x); + val xMax = args.size > 0 ? Int.parse(args(0)) : 10; + val area = obj.computeArea(0, xMax); + Console.OUT.println("The area of (x*x +1) * x from 0 to "+xMax+" is "+area); + } +} Modified: trunk/x10.tests/examples/Constructs/Async/AsyncTest4_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Async/AsyncTest4_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Async/AsyncTest4_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -24,7 +24,10 @@ var s: int = 0; for (var i: int = 0; i < N; i++) { //==> compiler error expected here - async x10.io.Console.OUT.println("s="+s+" i="+i); + async x10.io.Console.OUT.println("s="+ + s+ // ERR: cannot be captured in an async if there is no enclosing finish in the same scoping-level + " i="+ + i); // ERR: cannot be captured in an async if there is no enclosing finish in the same scoping-level s += i; } } Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -188,7 +188,7 @@ this(i); // ERR: Can use 'this' only after 'property(...)' property(1); // ERR: You cannot call 'property(...)' after 'this(...)' } - def this(x:Double) { super(1); } // ERR: You must call 'property(...)' at least once ERR: Final field "p" might not have been initialized + def this(x:Double) { super(1); } // ERR: property(...) might not have been called def this(x:Float) { property(1); } def this(x:Char) { // val x = 3; // I can't check this error, because it is a parsing error: the call to "super(...)" must be the first statement. @@ -275,11 +275,11 @@ def this(i:Float) { property(1); } - def this(i:String) { // ERR: You must call 'property(...)' at least once ERR: Final field "y" might not have been initialized + def this(i:String) { // ERR: property(...) might not have been called } - def this(i:Any) { // ERR: Final field "y" might not have been initialized + def this(i:Any) { property(1); - property(1); // ERR: You can call 'property(...)' at most once ERR: Property "y" might already have been initialized + property(1); // ERR: You can call 'property(...)' at most once } } static class SubWithoutProperties extends WithProperties { @@ -298,24 +298,36 @@ -class TestPropertyCalls(p:Int) { - def this() {} // ERR: Final field "p" might not have been initialized ERR: You must call 'property(...)' at least once +class TestPropertyCalls(p:Int, p2:Int) { + def this() {} // ERR: property(...) might not have been called + def this(x:Float) { + property(1); // ERR: The property initializer must have the same number of arguments as properties for the class. + } def this(i:Int) { - property(1); + val x:Int; + if (i==1) + x=2; + else + x=3; + property(x,2); } - def this(b:Boolean) { // ERR: Final field "p" might not have been initialized - property(1); - property(1); // ERR: Property "p" might already have been initialized ERR: You can call 'property(...)' at most once + def this(i:String) { // ERR: property(...) might not have been called + async property(1,2); // ERR: A property statement may only occur in the body of a constructor. (todo: err could be improved) } - def this(b:Double) { // ERR: Final field "p" might not have been initialized - if (p==1) // ERR: must call 'property(...)' immediately after the 'super(...)' call. - property(1); + def this(b:Boolean) { + property(1,2); + property(1,2); // ERR: You can call 'property(...)' at most once } + def this(b:Double) { // ERR: property(...) might not have been called + if (b==1) + property(1,2); + } + def m() { - property(1); // ERR: A property statement may only occur in the body of a constructor. + property(1,2); // ERR: A property statement may only occur in the body of a constructor. } static def q() { - property(1); // ERR: A property statement may only occur in the body of a constructor. + property(1,2); // ERR: A property statement may only occur in the body of a constructor. } } @@ -1702,4 +1714,37 @@ return 1; // ERR: Cannot return from an async. return 2; } +} + + +// Test method resolution + +class TestMethodResolution { + def m(Int)=""; + def m(Long)=true; + def m(Any)=3; + def test(flag:Boolean) { + val arr = [1,2l]; // infers Array[Any] + val x = flag ? 1 : 2l; // infers Long + val i1:Boolean = m(x); + val i2:Int = m(arr(0)); // ShouldBeErr + } + + + def check[T](t:T)=1; + def check(t:Any)=""; + def testGenerics() { + val r1:Int = check(1); // ShouldBeErr: should resolve to the non-generic method + val r2:Int = (check.(Any))(1); // ShouldBeErr: should DEFNITELY resolve to the non-generic method + val r3:Int = check[Int](1); // be explicit + val r4:Int = (check.(Any))(1); // ShouldBeErr: ahhh? be explicit + // todo: What is the syntax for generic method selection? + // neither "(m.[String](String))" nor "(m[String].(String))" parses. + } +} +class UseMacroInNewExpr(i:Int) { + public static type Bar = UseMacroInNewExpr{i==2}; + static def test() { + val y = new Bar(2); // ERR: Constructor return type UseMacroInNewExpr is not a subtype of UseMacroInNewExpr{self.i==2}. + } } \ No newline at end of file Modified: trunk/x10.tests/examples/Constructs/DepType/NonFinalField_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/NonFinalField_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/DepType/NonFinalField_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -28,12 +28,13 @@ class Test(i: int) { public def this(ii:int):Test = { - i = ii; + property(ii); } } public def run(): boolean = { - var a: Test = new Test(52) as Test{i==52, bad}; + var a: Test = new Test(52) as + Test{i==52, bad}; // ERR return true; } public static def main(var args: Array[String](1)): void = { Modified: trunk/x10.tests/examples/Constructs/DepType/NonFinalVariable_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/NonFinalVariable_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/DepType/NonFinalVariable_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -27,14 +27,16 @@ class Test(i: int) { public def this(ii:int):Test = { - i = ii; + property(ii); } } public def run(): boolean = { var ii: int = 52; - var a: Test{i==ii} = new Test(52); + var a: + Test{i==ii} // ERR + = new Test(52); return true; } public static def main(var args: Array[String](1)): void = { Modified: trunk/x10.tests/examples/Constructs/DepType/PropertyMustBeAssignedInConsBody_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/PropertyMustBeAssignedInConsBody_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/DepType/PropertyMustBeAssignedInConsBody_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -22,8 +22,7 @@ // an invocation of property that is strong enough to entail the return type. -/** Test that the compiler detects a situation in which one branch of a conditional has - a property clause but not another. +/** property(...) must be called. *@author vj * */ @@ -33,9 +32,7 @@ public class PropertyMustBeAssignedInConsBody_MustFailCompile extends x10Test { class Tester(i: int(2) ) { - public def this(arg:int):Tester { - - } + public def this(arg:int):Tester { } // ERR: You must call 'property(...)' at least once } Modified: trunk/x10.tests/examples/Constructs/DepType/PropertyNotInvoked_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/PropertyNotInvoked_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/DepType/PropertyNotInvoked_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -35,7 +35,7 @@ class Tester(i: int(2) ) { public def this(arg:int):Tester{self.i==2} { - if (i==2) + if (arg==2) property(arg as int{self==2}); else { this.i=2; Deleted: trunk/x10.tests/examples/Constructs/DepType/SameNameGuardedFieldAccess_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/SameNameGuardedFieldAccess_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/DepType/SameNameGuardedFieldAccess_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -1,41 +0,0 @@ -// Yoav added: IGNORE_FILE -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -/** - * Tests that two guarded fields may not have the same name, even if their guard - * conditions are disjoint. - * - * @author pvarma - */ -public class SameNameGuardedFieldAccess_MustFailCompile extends x10Test { - - static class Test(i: int, j:int) { - public var v{i==5}: int = 5; - public var v{i==6}: int = 6; - def this(i:int, j:int):Test = { - this.i=i; - this.j=j; - } - } - - public def run(): boolean = { - var t: Test{self.i==5} = new Test(5, 5); - t.value = t.value + 10; - return true; - } - - public static def main(var args: Array[String](1)): void = { - new SameNameGuardedFieldAccess_MustFailCompile().execute(); - } -} Modified: trunk/x10.tests/examples/Constructs/DepType/SamePropertyAncestor_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/SamePropertyAncestor_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/DepType/SamePropertyAncestor_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -28,16 +28,15 @@ class Test(i: int, j:int) { def this(i:int, j:int):Test = { - this.i=i; - this.j=j; + property(i,j); } } - class Test2(i: int) { + class Test2(i: int) extends Test { // ERR def this(i:int):Test2 = { super(i,i); - this.i=i; + property(i); } } Modified: trunk/x10.tests/examples/Constructs/DepType/SameSignatureMethod_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/SameSignatureMethod_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/DepType/SameSignatureMethod_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -27,11 +27,10 @@ class Test(i: int, j:int) { def tester(k:int(0))=true; - def tester(l:int(0)) = l; + def tester(l:int(0)) = l; // ERR def this(i:int, j:int):Test = { - this.i=i; - this.j=j; + property(i,j); } } Modified: trunk/x10.tests/examples/Constructs/DepType/SelfFieldLocalVarShadow_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/SelfFieldLocalVarShadow_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/DepType/SelfFieldLocalVarShadow_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -28,8 +28,7 @@ class Test(i: int, j:int) { def this(i:int, j:int):Test = { - this.i=i; - this.j=j; + property(i,j); } } @@ -38,7 +37,7 @@ } public def run(): boolean = { val j: int = 0; - var t: Test{self.i==self.j} = new Test(0,3) as Test{i==j}; // here j goes to the local variable, not self.j + var t: Test{self.i==self.j} = new Test(0,3) as Test{i==j}; // ERR: here j goes to the local variable, not self.j // should fail to compile since Test(:self.i==j) is not a subtype of Test(:self.i==self.j) return m(t); } Modified: trunk/x10.tests/examples/Constructs/DepType/UninitializedProperty_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/UninitializedProperty_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/DepType/UninitializedProperty_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -26,7 +26,7 @@ public class UninitializedProperty_MustFailCompile(i:int, j:int) extends x10Test { public def this(i:int, j:int):UninitializedProperty_MustFailCompile = { - this.i=i; + property(i); // ERR } public def run()=true; Modified: trunk/x10.tests/examples/Constructs/Generics/GenericInference1_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Generics/GenericInference1_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Generics/GenericInference1_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -1,3 +1,4 @@ +// Yoav added: IGNORE_FILE /* * This file is part of the X10 project (http://x10-lang.org). * @@ -29,12 +30,16 @@ class Y extends X {static name = "Y";}; class Z extends X {static name = "Z";}; - def m[T](){T<:X} = T.name; + def m[T](){T<:X} = + T.name; // ERR: Cannot access static field of a type parameter public def run(): boolean = { // must fail compile - val a = m(); + val a = + m(); // Err or not an Err: + // used to be: Method m[T](){}[T <: GenericInference1_MustFailCompile.X]: x10.lang.String{self=="X"} in GenericInference1_MustFailCompile{self==GenericInference1_MustFailCompile#this} cannot be called with arguments (); Could not infer type for type parameter T. + // now: (Diagnostic) No constraint on type parameters. Returning Any instead of throwing an exception. check("a", a, "hi"); return result; Modified: trunk/x10.tests/examples/Constructs/Inference/Inference7a.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Inference/Inference7a.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Inference/Inference7a.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -1,3 +1,4 @@ +// Yoav added: IGNORE_FILE /* * This file is part of the X10 project (http://x10-lang.org). * Deleted: trunk/x10.tests/examples/Constructs/Place/FutureFieldAccessStatic_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Place/FutureFieldAccessStatic_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Place/FutureFieldAccessStatic_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -1,57 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -/** - * @author bdlucas - */ - -public class FutureFieldAccessStatic_MustFailCompile extends x10Test { - - static class C[S] { - property p:int = 0; - val x:GlobalRef[S]; - var y:S; - def foo() {} - def foo(x:S) {} - final def foo[T](x:T) {} - def this(s:S) { - x = GlobalRef[S](s); - y = s; - } - } - - val c = new C[String]("0"); - - public def run02(): boolean = { - val p = Place.place(1); - val cc = this.c; - val f = future (p) { - // cannot access a field that is not global - val a = cc.x(); - return true; - }; - return f.force(); - } - - public def run(): boolean { - if (Place.MAX_PLACES == 1) { - x10.io.Console.OUT.println("not enough places to run this test"); - return false; - } - return run02(); - } - - public static def main(Array[String](1)) { - new FutureFieldAccess_MustFailCompile().execute(); - } -} Deleted: trunk/x10.tests/examples/Constructs/Place/FutureMethodInvokeRev_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Place/FutureMethodInvokeRev_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Place/FutureMethodInvokeRev_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -1,58 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -/** - * @author bdlucas - */ - -public class FutureMethodInvokeRev_MustFailCompile extends x10Test { - - class C[S](home:Place) { - property p:int = 0; - val x:S; - var y:S; - def foo(){here == this.home} {} - def foo(x:S) {} - final def foo[T](x:T) {} - def this(s:S) { - property(here); - x = s; - y = s; - } - } - - val c = (future (here.next()) new C[String]("a")).force(); - - public def run02(): boolean = { - val p = Place.place(1); - val cc = this.c; - val f = future (p) { - // cannot access a field that is not global - val a = cc.foo(); - return true; - }; - return f.force(); - } - - public def run(): boolean { - if (Place.MAX_PLACES == 1) { - x10.io.Console.OUT.println("not enough places to run this test"); - return false; - } - return run02(); - } - - public static def main(Array[String](1)) { - new FutureMethodInvokeRev_MustFailCompile().execute(); - } -} Deleted: trunk/x10.tests/examples/Constructs/Place/FutureMethodInvokeStatic_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Place/FutureMethodInvokeStatic_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Place/FutureMethodInvokeStatic_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -1,58 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -/** - * @author bdlucas - */ - -public class FutureMethodInvokeStatic_MustFailCompile extends x10Test { - - static class C[S](home:Place) { - property p:int = 0; - val x:S; - var y:S; - def foo(){here == this.home} {} - def foo(x:S) {} - final def foo[T](x:T) {} - def this(s:S) { - property(here); - x = s; - y = s; - } - } - - val c = new C[String]("0"); - - public def run02(): boolean = { - val p = Place.place(1); - val cc = this.c; - val f = future (p) { - // cannot access a method with a local guard - val a = cc.foo(); - return true; - }; - return f.force(); - } - - public def run(): boolean { - if (Place.MAX_PLACES == 1) { - x10.io.Console.OUT.println("not enough places to run this test"); - return false; - } - return run02(); - } - - public static def main(Array[String](1)) { - new FutureMethodInvokeStatic_MustFailCompile().execute(); - } -} Deleted: trunk/x10.tests/examples/Constructs/Place/FutureMethodInvoke_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Place/FutureMethodInvoke_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Place/FutureMethodInvoke_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -1,58 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -/** - * @author bdlucas - */ - -public class FutureMethodInvoke_MustFailCompile extends x10Test { - - class C[S](home:Place) { - property p:int = 0; - val x:S; - var y:S; - def foo(){here == this.home} {} - def foo(x:S) {} - final def foo[T](x:T) {} - def this(s:S) { - property(here); - x = s; - y = s; - } - } - - val c = new C[String]("0"); - - public def run02(): boolean = { - val p = Place.place(1); - val cc = this.c; - val f = future (p) { - // cannot access a field that is not global - val a = cc.foo(); - return true; - }; - return f.force(); - } - - public def run(): boolean { - if (Place.MAX_PLACES == 1) { - x10.io.Console.OUT.println("not enough places to run this test"); - return false; - } - return run02(); - } - - public static def main(Array[String](1)) { - new FutureMethodInvoke_MustFailCompile().execute(); - } -} Deleted: trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccessRev_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccessRev_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccessRev_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -1,60 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -//OPTIONS: -STATIC_CALLS - -import harness.x10Test; - -/** - * In 2.1 the variable access will succeed, so this is an INVALID test. - * @author bdlucas - */ - -public class FutureVarFieldAccessRev_MustFailCompile extends x10Test { - - class C[S] { - property p:int = 0; - val x:S; - var y:S; - def foo() {} - def foo(x:S) {} - final def foo[T](x:T) {} - def this(s:S) { - x = s; - y = s; - } - } - - val c = (future (here.next()) new C[String]("a")).force(); - - public def run02(): boolean = { - val p = Place.place(1); - val cc = this.c; - val f = future (p) { - // cannot access a field that is not global - val a = cc.y; - return true; - }; - return f.force(); - } - - public def run(): boolean { - if (Place.MAX_PLACES == 1) { - x10.io.Console.OUT.println("not enough places to run this test"); - return false; - } - return run02(); - } - - public static def main(Array[String](1)) { - new FutureVarFieldAccessRev_MustFailCompile().execute(); - } -} Deleted: trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccessStatic_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccessStatic_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccessStatic_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -1,60 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -//OPTIONS: -STATIC_CALLS - -import harness.x10Test; - -/** - * In 2.1 the variable access will succeed, so this is an INVALID test. - * @author bdlucas - */ - -public class FutureVarFieldAccessStatic_MustFailCompile extends x10Test { - - static class C[S] { - property p:int = 0; - val x:S; - var y:S; - def foo() {} - def foo(x:S) {} - final def foo[T](x:T) {} - def this(s:S) { - x = s; - y = s; - } - } - - val c = new C[String]("0"); - - public def run02(): boolean = { - val p = Place.place(1); - val cc = this.c; - val f = future (p) { - // cannot access a field that is not global - val a = cc.y; - return true; - }; - return f.force(); - } - - public def run(): boolean { - if (Place.MAX_PLACES == 1) { - x10.io.Console.OUT.println("not enough places to run this test"); - return false; - } - return run02(); - } - - public static def main(Array[String](1)) { - new FutureVarFieldAccessStatic_MustFailCompile().execute(); - } -} Deleted: trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccess_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccess_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Place/FutureVarFieldAccess_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -1,61 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -//OPTIONS: -STATIC_CALLS - -import harness.x10Test; - -/** - * - * In 2.1 the variable access will succeed, so this is an INVALID test. - * @author bdlucas - */ - -public class FutureVarFieldAccess_MustFailCompile extends x10Test { - - class C[S] { - property p:int = 0; - val x:S; - var y:S; - def foo() {} - def foo(x:S) {} - final def foo[T](x:T) {} - def this(s:S) { - x = s; - y = s; - } - } - - val c = new C[String]("0"); - - public def run02(): boolean = { - val p = Place.place(1); - val cc = this.c; - val f = future (p) { - // cannot access a field that is not global - val a = cc.y; - return true; - }; - return f.force(); - } - - public def run(): boolean { - if (Place.MAX_PLACES == 1) { - x10.io.Console.OUT.println("not enough places to run this test"); - return false; - } - return run02(); - } - - public static def main(Array[String](1)) { - new FutureVarFieldAccess_MustFailCompile().execute(); - } -} Deleted: trunk/x10.tests/examples/Constructs/Place/PlaceCheckInRail2_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Place/PlaceCheckInRail2_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Place/PlaceCheckInRail2_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -1,54 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -//OPTIONS: -STATIC_CALLS - -import harness.x10Test; - -/** - * @author bdlucas - */ - -public class PlaceCheckInRail2_MustFailCompile extends x10Test { - - - class C { - val x:int = 0; - def foo() = 0; - } - - - public def run02(): boolean { - - val r = Rail.make[C](3, (int)=>new C()); - val gr = GlobalRef[Rail[C]](r); - - // should fail typecheck - (future (Place.place(1)) gr()(0).foo()).force(); - - x10.io.Console.OUT.println("01 fails"); - return false; - } - - - - public def run(): boolean { - if (Place.MAX_PLACES == 1) { - x10.io.Console.OUT.println("not enough places to run this test"); - return false; - } - return run02(); - } - - public static def main(Array[String](1)) { - new PlaceCheckInRail2_MustFailCompile().execute(); - } -} Deleted: trunk/x10.tests/examples/Constructs/Place/PlaceCheckInRail_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Place/PlaceCheckInRail_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Place/PlaceCheckInRail_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -1,51 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -//OPTIONS: -STATIC_CALLS - -import harness.x10Test; - -/** - * @author bdlucas - */ - -public class PlaceCheckInRail_MustFailCompile extends x10Test { - - - class C { - val x:int = 0; - def foo() = 0; - } - - - public def run01(): boolean { - val r = Rail.make[C](3, (int)=>new C()); - val gr = GlobalRef[Rail[C]](r); - // Should gave a place check error ... r is remote. - (future (Place.place(1)) gr()(0).x).force(); - x10.io.Console.OUT.println("01 fails"); - return false; - } - - - - public def run(): boolean { - if (Place.MAX_PLACES == 1) { - x10.io.Console.OUT.println("not enough places to run this test"); - return false; - } - return run01(); - } - - public static def main(Array[String](1)) { - new PlaceCheckInRail_MustFailCompile().execute(); - } -} Deleted: trunk/x10.tests/examples/Constructs/Place/PlaceCheckStringBuilder_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Place/PlaceCheckStringBuilder_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Place/PlaceCheckStringBuilder_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -1,37 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -//OPTIONS: -STATIC_CALLS - -import harness.x10Test; - -/** - * @author bdlucas - */ - -import x10.util.StringBuilder; - -public class PlaceCheckStringBuilder_MustFailCompile extends x10Test { - - public def run(): boolean { - val sb = new StringBuilder(); - val gsb = GlobalRef[StringBuilder](sb); - (future (Place.place(1)) { - gsb().add("foo"); - return gsb().toString(); - }).force(); - return true; - } - - public static def main(var args: Array[String](1)): void = { - new PlaceCheckStringBuilder_MustFailCompile().execute(); - } -} Modified: trunk/x10.tests/examples/Constructs/Structs/StructCannotSubclassClass_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Structs/StructCannotSubclassClass_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Structs/StructCannotSubclassClass_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -18,7 +18,7 @@ public class StructCannotSubclassClass_MustFailCompile extends x10Test { class B {} - struct A extends B { + struct A extends B { // ERR: Syntax error: Token "implements" expected instead of this input val x:int=5; } Modified: trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint3g_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint3g_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/Typedefs/TypedefConstraint3g_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -19,7 +19,9 @@ public def run():boolean = { - type T(var x:int){x==1} = int; + type T( + var x:int) // ERR: Type definition parameters must be final. + {x==1} = int; return result; } Modified: trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType4_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType4_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ObjectIsNotParameterType4_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -19,9 +19,9 @@ */ public class ObjectIsNotParameterType4_MustFailCompile extends x10Test { class GenericWrapper[T] { - incomplete def m(x:T):Void; + def m(x:T):void {} public def testAssign(y:Object) { - m(y); + m(y); // ERR: Method m(x: T): x10.lang.Void in ObjectIsNotParameterType4_MustFailCompile.GenericWrapper{self==ObjectIsNotParameterType4_MustFailCompile.GenericWrapper#this} cannot be called with arguments (x10.lang.Object{self==y}); Invalid Parameter. } } public def run()=true; Modified: trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject4_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject4_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Constructs/XtenTwoOhTypeSsytem/ParameterTypeIsNotObject4_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -19,9 +19,9 @@ */ public class ParameterTypeIsNotObject4_MustFailCompile extends x10Test { class GenericWrapper[T] { - incomplete def m(x:Object):Void; + def m(x:Object):Void = {} public def testAssign(y:T) { - m(y); + m(y); // ERR: Method m(x: x10.lang.Object): x10.lang.Void in ParameterTypeIsNotObject4_MustFailCompile.GenericWrapper{self==ParameterTypeIsNotObject4_MustFailCompile.GenericWrapper#this} cannot be called with arguments (T{self==y}); Invalid Parameter. } } public def run()=true; Modified: trunk/x10.tests/examples/Issues/XTENLANG_1565_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_1565_MustFailCompile.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Issues/XTENLANG_1565_MustFailCompile.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -13,15 +13,7 @@ /** * @author yoav - Should produce these errors: -C:\cygwin\home\Yoav\intellij\sourceforge\x10.tests\examples\Issues\XTENLANG_1565_MustFailCompile.x10:45: "n" may not have been initialized -C:\cygwin\home\Yoav\intellij\sourceforge\x10.tests\examples\Issues\XTENLANG_1565_MustFailCompile.x10:53: "k" may not have been initialized -C:\cygwin\home\Yoav\intellij\sourceforge\x10.tests\examples\Issues\XTENLANG_1565_MustFailCompile.x10:54: "n" may not have been initialized -C:\cygwin\home\Yoav\intellij\sourceforge\x10.tests\examples\Issues\XTENLANG_1565_MustFailCompile.x10:55: "j" may not have been initialized -C:\cygwin\home\Yoav\intellij\sourceforge\x10.tests\examples\Issues\XTENLANG_1565_MustFailCompile.x10:63: "j" may not have been initialized -C:\cygwin\home\Yoav\intellij\sourceforge\x10.tests\examples\Issues\XTENLANG_1565_MustFailCompile.x10:64: "q" may not have been initialized -C:\cygwin\home\Yoav\intellij\sourceforge\x10.tests\examples\Issues\XTENLANG_1565_MustFailCompile.x10:23-68: Final field "q" might not have been initialized -7 errors. + Should produce errors where the ERR markers are. */ class XTENLANG_1565_MustFailCompile extends x10Test { @@ -34,7 +26,7 @@ async { z = 0; } } - shared var i:Int, j:Int, k:Int; + var i:Int, j:Int, k:Int; i=1; // i:[1,1,1,1] @@ -75,7 +67,7 @@ // j:[1,2,1,2] f(j); } - def f(i:Int):Int=i+1; + private def f(i:Int):Int=i+1; public def run(): boolean { return true; Modified: trunk/x10.tests/examples/Samples/FibTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/FibTest.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Samples/FibTest.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -13,7 +13,7 @@ public class FibTest extends x10Test { public def run():boolean { - val res = Fib.fib(12); + val res = Fibonacci.fib(12); chk(res == 144); return true; } Modified: trunk/x10.tests/examples/Samples/IntegrateTest.x10 =================================================================== --- trunk/x10.tests/examples/Samples/IntegrateTest.x10 2010-10-12 17:55:40 UTC (rev 17312) +++ trunk/x10.tests/examples/Samples/IntegrateTest.x10 2010-10-12 18:02:05 UTC (rev 17313) @@ -13,7 +13,7 @@ public class IntegrateTest extends x10Test { public def run():boolean { - val obj = new Integrate((x:double)=>(x*x + 1.0) * x); + val obj = new IntegrateTest((x:double)=>(x*x + 1.0) * x); val area = obj.computeArea(0, 10); Console.OUT.println("Computed area is "+area); chk(area > 2549.999); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2011-01-08 12:42:00
|
Revision: 19366 http://x10.svn.sourceforge.net/x10/?rev=19366&view=rev Author: dgrove-oss Date: 2011-01-08 12:41:53 +0000 (Sat, 08 Jan 2011) Log Message: ----------- XTENLANG-2309 : Improve efficiency of Complex conjugate Modified Paths: -------------- trunk/x10.runtime/src-x10/x10/lang/Complex.x10 trunk/x10.tests/examples/Constructs/Math/TestComplex.x10 Modified: trunk/x10.runtime/src-x10/x10/lang/Complex.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Complex.x10 2011-01-08 09:51:51 UTC (rev 19365) +++ trunk/x10.runtime/src-x10/x10/lang/Complex.x10 2011-01-08 12:41:53 UTC (rev 19366) @@ -158,12 +158,7 @@ /** * @return the conjugate of this complex number. */ - public def conjugate():Complex { - if (isNaN()) { - return Complex.NaN; - } - return Complex(re, -im); - } + public def conjugate():Complex = Complex(re, -im); /** * @return this complex number. Modified: trunk/x10.tests/examples/Constructs/Math/TestComplex.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Math/TestComplex.x10 2011-01-08 09:51:51 UTC (rev 19365) +++ trunk/x10.tests/examples/Constructs/Math/TestComplex.x10 2011-01-08 12:41:53 UTC (rev 19366) @@ -24,6 +24,7 @@ val b = a.conjugate(); chk (b.conjugate() == a); + chk (Complex.NaN.conjugate().isNaN()); val c = Complex(1.0, 4.0); chk (a + c - c == a, "a + c - c = a"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ja...@us...> - 2011-01-24 20:34:03
|
Revision: 19689 http://x10.svn.sourceforge.net/x10/?rev=19689&view=rev Author: janshep Date: 2011-01-24 20:33:57 +0000 (Mon, 24 Jan 2011) Log Message: ----------- Make Stats more readily accessible by switching it to all static fields and methods Modified Paths: -------------- trunk/x10.compiler/src/polyglot/frontend/Compiler.java trunk/x10.compiler/src/polyglot/frontend/Scheduler.java trunk/x10.compiler/src/polyglot/frontend/Stats.java trunk/x10.compiler/src/polyglot/main/Main.java trunk/x10.compiler/src/polyglot/visit/DataFlow.java trunk/x10.compiler/src/polyglot/visit/InitChecker.java trunk/x10.sncode/.classpath Modified: trunk/x10.compiler/src/polyglot/frontend/Compiler.java =================================================================== --- trunk/x10.compiler/src/polyglot/frontend/Compiler.java 2011-01-24 20:20:11 UTC (rev 19688) +++ trunk/x10.compiler/src/polyglot/frontend/Compiler.java 2011-01-24 20:33:57 UTC (rev 19689) @@ -70,8 +70,6 @@ this.extensionInfo = extensionInfo; this.eq = eq; this.allExtensions = new ArrayList<ExtensionInfo>(2); - stats = new Stats(); - loader = new ClassFileLoader(extensionInfo); @@ -79,9 +77,6 @@ extensionInfo.initCompiler(this); } - /*** Compiler statistics gatherer. */ - public Stats stats; - /** Return a set of output filenames resulting from a compilation. */ public Collection<String> outputFiles() { return outputFiles; Modified: trunk/x10.compiler/src/polyglot/frontend/Scheduler.java =================================================================== --- trunk/x10.compiler/src/polyglot/frontend/Scheduler.java 2011-01-24 20:20:11 UTC (rev 19688) +++ trunk/x10.compiler/src/polyglot/frontend/Scheduler.java 2011-01-24 20:33:57 UTC (rev 19689) @@ -57,9 +57,8 @@ // TODO: remove this, we only need to intern the goal status, not the goal itself. // Actually, the lazy ref to the goal status is the goal. The run() method is the resolver for the lazy ref. public Goal intern(Goal goal) { - Compiler c = extInfo.compiler(); - c.stats.incrFrequency("intern", 1); - c.stats.incrFrequency("intern:" + Stats.incrFrequency("intern", 1); + Stats.incrFrequency("intern:" + (goal instanceof VisitorGoal ? ((VisitorGoal) goal).v.getClass().getName() : goal.getClass().getName()), 1); Goal g = internCache.get(goal); if (g == null) { @@ -328,18 +327,17 @@ Goal oldGoal = currentGoal; currentGoal = goal; String key = goal.toString(); - Compiler c = extInfo.compiler(); - c.stats.startTiming(goal.name(), key); + Stats.startTiming(goal.name(), key); - c.stats.incrFrequency(key + " attempts", 1); - c.stats.incrFrequency("total goal attempts", 1); + Stats.incrFrequency(key + " attempts", 1); + Stats.incrFrequency("total goal attempts", 1); try { result = goal.runTask(); if (result && goal.getCached() == Goal.Status.RUNNING) { - c.stats.incrFrequency(key + " reached", 1); - c.stats.incrFrequency("total goal reached", 1); + Stats.incrFrequency(key + " reached", 1); + Stats.incrFrequency("total goal reached", 1); goal.update(Status.SUCCESS); @@ -347,8 +345,8 @@ Report.report(1, "Completed pass for " + goal); } else { - c.stats.incrFrequency(key + " unreached", 1); - c.stats.incrFrequency("total goal unreached", 1); + Stats.incrFrequency(key + " unreached", 1); + Stats.incrFrequency("total goal unreached", 1); if (Report.should_report(Report.frontend, 1)) Report.report(1, "Completed (unreached) pass for " + goal); @@ -369,7 +367,7 @@ Report.stop_reporting(goal.name()); - c.stats.stopTiming(); + Stats.stopTiming(); } // pretty-print this pass if we need to. Modified: trunk/x10.compiler/src/polyglot/frontend/Stats.java =================================================================== --- trunk/x10.compiler/src/polyglot/frontend/Stats.java 2011-01-24 20:20:11 UTC (rev 19688) +++ trunk/x10.compiler/src/polyglot/frontend/Stats.java 2011-01-24 20:33:57 UTC (rev 19689) @@ -17,21 +17,20 @@ import java.util.Stack; import polyglot.main.Report; -import polyglot.util.CollectionUtil; -import x10.util.CollectionFactory; +import polyglot.util.CollectionUtil; import x10.util.CollectionFactory; /** * Statistics collection and reporting object. Extensions can override this to * collect more stats or to change reporting. */ public class Stats { - protected static class Counts { + private static class Counts { public long count; public Counter counter; } /*** Count accumulator for an object */ - private class Counter { + private static class Counter { /** Map from Objects to counts for the Object */ public Map<Object, Counts> counts; @@ -55,13 +54,13 @@ } } - private Counter phase, site, freq; - private long startTime, totalTime, reportTimeThreshold; - private int currDepth, maxDepth; - private boolean t2; + private static Counter phase, site, freq; + private static long startTime, totalTime, reportTimeThreshold; + private static int currDepth, maxDepth; + private static boolean t2; /*** Stack of phase names for timing nested phases (goals) */ - private class stackStruct { + private static class stackStruct { long startTime; Object phaseName; Object siteName; @@ -75,7 +74,7 @@ } } - private Stack<stackStruct> start; + private static Stack<stackStruct> start; /*** * Initialize statistics if reporting is requested. Subsequently, we just @@ -84,8 +83,8 @@ * * @param startTime */ - public void initialize(long startTime) { - this.startTime = startTime; + public static void initialize(long startTime) { + Stats.startTime = startTime; if (Report.should_report(Report.time, 1)) { phase = new Counter(); site = new Counter(); @@ -97,7 +96,7 @@ } /*** Increment frequency counter */ - public void incrFrequency(Object key, long count) { + public static void incrFrequency(Object key, long count) { if (freq == null) return; freq.accumulate(key, count); } @@ -108,7 +107,7 @@ * @param phaseName * @param siteName */ - public void startTiming(Object phaseName, Object siteName) { + public static void startTiming(Object phaseName, Object siteName) { if (phase == null) return; Counter c; if (start.empty()) { @@ -134,7 +133,7 @@ /*** * Stop timing a phase. This should be paired with startTiming. */ - public void stopTiming() { + public static void stopTiming() { if (phase == null) return; stackStruct s = start.pop(); long elapsed = System.nanoTime() - s.startTime; @@ -144,7 +143,7 @@ } /** Report the frequency counts. */ - public void reportFrequency() { + public static void reportFrequency() { if (freq == null) return; Report.report(1, "\nFrequency Statistics for X10c"); Report.report(1, String.format("%16s", "Count") + " Name"); @@ -158,7 +157,7 @@ } /** Report the times. */ - public void reportTime() { + public static void reportTime() { totalTime = System.nanoTime() - startTime; if (Report.should_report(Report.threshold, 1)) { reportTimeThreshold = (Report.level(Report.threshold) * totalTime) / 100; @@ -170,7 +169,7 @@ } /** Report the times. */ - private void reportTiming() { + private static void reportTiming() { if (currDepth != 0) Report.report(1, "\nWarning: mismatched start/stop times"); t2 = Report.should_report(Report.time, 2); @@ -206,7 +205,7 @@ } /*** This handles reporting nestedphases (goals) */ - private void reportPhase(int depth, Counter c) { + private static void reportPhase(int depth, Counter c) { int d; String indent = ""; for (d = 0; d < depth; d++) Modified: trunk/x10.compiler/src/polyglot/main/Main.java =================================================================== --- trunk/x10.compiler/src/polyglot/main/Main.java 2011-01-24 20:20:11 UTC (rev 19688) +++ trunk/x10.compiler/src/polyglot/main/Main.java 2011-01-24 20:33:57 UTC (rev 19689) @@ -120,11 +120,11 @@ source = new LinkedHashSet<String>(); Compiler compiler = getCompiler(argv, ext, eq, source); - compiler.stats.initialize(startTime); + Stats.initialize(startTime); boolean success = compiler.compileFiles(source); - compiler.stats.reportFrequency(); - compiler.stats.reportTime(); + Stats.reportFrequency(); + Stats.reportTime(); if (!success) { throw new TerminationException(1); Modified: trunk/x10.compiler/src/polyglot/visit/DataFlow.java =================================================================== --- trunk/x10.compiler/src/polyglot/visit/DataFlow.java 2011-01-24 20:20:11 UTC (rev 19688) +++ trunk/x10.compiler/src/polyglot/visit/DataFlow.java 2011-01-24 20:33:57 UTC (rev 19689) @@ -14,6 +14,7 @@ import polyglot.frontend.Globals; import polyglot.frontend.Job; import polyglot.frontend.Compiler; +import polyglot.frontend.Stats; import polyglot.main.Report; import polyglot.types.*; import polyglot.util.*; @@ -434,8 +435,7 @@ // Build the control flow graph. CFGBuilder v = createCFGBuilder(ts, g); - Compiler c = job().extensionInfo().compiler(); - c.stats.startTiming("DataFlow.dataflow", "DataFlow.dataflow"); + Stats.startTiming("DataFlow.dataflow", "DataFlow.dataflow"); try { hadCFG_Error = false; v.visitGraph(); @@ -446,16 +446,16 @@ return; } finally { - c.stats.stopTiming(); + Stats.stopTiming(); } - c.stats.startTiming("DataFlow.cfg.build", "DataFlow.cfg.build"); + Stats.startTiming("DataFlow.cfg.build", "DataFlow.cfg.build"); dataflow(g); - c.stats.stopTiming(); + Stats.stopTiming(); - c.stats.startTiming("DataFlow.post", "DataFlow.post"); + Stats.startTiming("DataFlow.post", "DataFlow.post"); post(g, cd); - c.stats.stopTiming(); + Stats.stopTiming(); // push the CFG onto the stack if we are dataflowing on entry if (dataflowOnEntry) Modified: trunk/x10.compiler/src/polyglot/visit/InitChecker.java =================================================================== --- trunk/x10.compiler/src/polyglot/visit/InitChecker.java 2011-01-24 20:20:11 UTC (rev 19688) +++ trunk/x10.compiler/src/polyglot/visit/InitChecker.java 2011-01-24 20:33:57 UTC (rev 19689) @@ -13,6 +13,7 @@ import polyglot.ast.*; import polyglot.frontend.Job; import polyglot.frontend.Compiler; +import polyglot.frontend.Stats; import polyglot.types.*; import polyglot.util.InternalCompilerError; import polyglot.util.Position; @@ -779,9 +780,8 @@ dfIn = createInitDFI(); } - Compiler c = job().extensionInfo().compiler(); - c.stats.incrFrequency("InitChecker.check", 1); - c.stats.startTiming("InitChecker.1","InitChecker.1"); + Stats.incrFrequency("InitChecker.check", 1); + Stats.startTiming("InitChecker.1","InitChecker.1"); DataFlowItem dfOut; if (!entry && outItems != null && !outItems.isEmpty()) { @@ -812,7 +812,7 @@ // probably a node in a finally block. Just ignore it. } - c.stats.stopTiming(); + Stats.stopTiming(); } Modified: trunk/x10.sncode/.classpath =================================================================== --- trunk/x10.sncode/.classpath 2011-01-24 20:20:11 UTC (rev 19688) +++ trunk/x10.sncode/.classpath 2011-01-24 20:33:57 UTC (rev 19689) @@ -3,5 +3,7 @@ <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/> + <classpathentry kind="lib" path="/x10.dist/lib/x10.jar"/> + <classpathentry kind="lib" path="/x10.dist/lib/x10c.jar"/> <classpathentry kind="output" path="bin"/> </classpath> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2011-01-27 23:41:13
|
Revision: 19779 http://x10.svn.sourceforge.net/x10/?rev=19779&view=rev Author: yzibin Date: 2011-01-27 23:41:05 +0000 (Thu, 27 Jan 2011) Log Message: ----------- * added the container to the name of methods that return the outer this. * an assertion failed (moved it into the if) * excluded FrontEndTests_MustFailCompile and some other tests from the suite * changed the error markers of some tests Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java trunk/x10.compiler/src/x10/ast/X10Special_c.java trunk/x10.compiler/src/x10/util/RunTestSuite.java trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.dist/samples/CUDA/CUDABlackScholes.x10 trunk/x10.tests/examples/Constructs/Array/ArrayAccessWithMismatchingPointRank_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Class/InconsistentInvariant_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/ClassDepClause_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/DepTypeConsistency1_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/DepTypeConsistency2_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/DepTypeConsistency_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/InconsistentInterfaceInvariants_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Structs/StructObscuringExample.x10 trunk/x10.tests/examples/Issues/XTENLANG_2330.x10 trunk/x10.tests/examples/Misc/x10/frontend/tests/FrontEndTests_MustFailCompile.x10 Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2011-01-27 22:49:58 UTC (rev 19778) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2011-01-27 23:41:05 UTC (rev 19779) @@ -501,33 +501,42 @@ // adding methods to access the outer instances (used in Desugarer.desugarCall) - // e.g., + // The method name includes both the container name and the qualifier name to handle this nasty case: + //class A[T] { + // public final def A$$A$this() = A.this; + // class Inner extends A[Int] { + // public final def Inner$$A$this() = A.this; // the return type is different! + // public final def Inner$$Inner$this() = Inner.this; + // } + //} + // Another simpler example: // class A { - // public def A$this() = A.this; + // public final def A$$A$this() = A.this; // class B { - // public def B$this() = B.this; - // public def A$this() = A.this; + // public final def B$$B$this() = B.this; + // public final def B$$A$this() = A.this; // } // class D extends B { - // public def D$this() = D.this; - // public def A$this() = A.this; // this is why the methods cannot be FINAL + // public final def D$$D$this() = D.this; + // public final def D$$A$this() = A.this; // } // static class C { - // public def C$this() = C.this; + // public final def C$$C$this() = C.this; // } // } { final Position pos = n.position().markCompilerGenerated(); - final Flags flags = Flags.PUBLIC; + final Flags flags = Flags.PUBLIC.Final(); final NodeFactory nf = tb.nodeFactory(); + final QName containerName = def.fullName(); ClassType curr = def.asType(); while (curr!=null) { if (curr.flags().isInterface()) break; final UnknownTypeNode returnType = nf.UnknownTypeNode(pos); final QName fullName = curr.fullName(); - MethodDecl md = nf.MethodDecl(pos,nf.FlagsNode(pos,flags),returnType,nf.Id(pos,getThisMethod(fullName)),Collections.<Formal>emptyList(), + MethodDecl md = nf.MethodDecl(pos,nf.FlagsNode(pos,flags),returnType,nf.Id(pos,getThisMethod(containerName,fullName)),Collections.<Formal>emptyList(), nf.Block(pos,nf.Return(pos,nf.Special(pos, Special.Kind.THIS, nf.TypeNodeFromQualifiedName(pos,fullName))))); n = (X10ClassDecl_c) n.body(n.body().addMember(md)); @@ -539,8 +548,12 @@ return n; } - public static Name getThisMethod(QName n) { - return Name.make(n.toString().replace('.','$')+"$this"); + public static Name getThisMethod(QName containerName, QName n) { + return Name.make( + containerName.toString().replace('.','$')+ + "$$"+ + n.toString().replace('.','$')+ + "$this"); } private X10ClassDecl_c superPreBuildTypes(TypeBuilder tb) throws SemanticException { Modified: trunk/x10.compiler/src/x10/ast/X10Special_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Special_c.java 2011-01-27 22:49:58 UTC (rev 19778) +++ trunk/x10.compiler/src/x10/ast/X10Special_c.java 2011-01-27 23:41:05 UTC (rev 19779) @@ -156,8 +156,8 @@ cc = cc == null ? new CConstraint() : cc.copy(); try { XVar var = (XVar) xts.xtypeTranslator().translate(cc, this, c); - assert var instanceof CThis; if (var != null) { + assert var instanceof CThis; cc.addSelfBinding(var); cc.setThisVar(var); //PlaceChecker.AddThisHomeEqualsPlaceTerm(cc, var, c); Modified: trunk/x10.compiler/src/x10/util/RunTestSuite.java =================================================================== --- trunk/x10.compiler/src/x10/util/RunTestSuite.java 2011-01-27 22:49:58 UTC (rev 19778) +++ trunk/x10.compiler/src/x10/util/RunTestSuite.java 2011-01-27 23:41:05 UTC (rev 19779) @@ -151,13 +151,17 @@ public static String SOURCE_PATH_SEP = File.pathSeparator; // on MAC the separator is ":" and on windows it is ";" private static void println(String s) { - if (!QUIET) System.out.println(s); + if (!QUIET) { + System.out.println(s); + System.out.flush(); + } } private static int EXIT_CODE = 0; private static java.lang.StringBuilder ALL_ERRORS = new StringBuilder(); private static void err(String s) { EXIT_CODE = 1; System.err.println(s); + System.err.flush(); ALL_ERRORS.append(s).append("\n"); } @@ -171,6 +175,8 @@ "NOT_WORKING", // to exclude some benchmarks: https://x10.svn.sourceforge.net/svnroot/x10/benchmarks/trunk }; private static final String[] EXCLUDE_FILES = { + "FrontEndTests_MustFailCompile.x10", + // difference on MAC and PC (on PC the compiler crashes, on MAC it outputs this error: Semantic Error: Type definition type static TypedefOverloading06_MustFailCompile.A = x10.lang.String has the same name as member class TypedefOverloading06_MustFailCompile.A. "TypedefOverloading04_MustFailCompile.x10", "TypedefOverloading06_MustFailCompile.x10", @@ -181,6 +187,7 @@ // LangSpec is auto-generated, so I can't fix those files to make a clean test suite "Classes250.x10","Classes160.x10","Classes170.x10", + "Interfaces3l4a.x10", "Interfaces_static_val.x10", "Types2y3i.x10", "Types6a9m.x10", "InnerClasses5p9v.x10","Packages5t5g.x10","Stimulus.x10","Statements51.x10", "ClassCtor30_MustFailCompile.x10", "ThisEscapingViaAt_MustFailCompile.x10", }; private static final String[] EXCLUDE_FILES_WITH = { Modified: trunk/x10.compiler/src/x10/visit/Desugarer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Desugarer.java 2011-01-27 22:49:58 UTC (rev 19778) +++ trunk/x10.compiler/src/x10/visit/Desugarer.java 2011-01-27 23:41:05 UTC (rev 19779) @@ -484,7 +484,7 @@ // qualifer doesn't have type info because it was created in Synthesizer.makeExpr qualifer = (TypeNode) qualifer.visit(new X10TypeBuilder(job, ts, nf)).visit(new X10TypeChecker(job, ts, nf, job.nodeMemo()).context(closureContext)); ClassType ct = qualifer.type().toClass(); - return nf.Call(pos,newReceiver, nf.Id(pos,X10ClassDecl_c.getThisMethod(ct.fullName()))); + return nf.Call(pos,newReceiver, nf.Id(pos,X10ClassDecl_c.getThisMethod(newReceiver.type().toClass().def().fullName(),ct.fullName()))); } if (n instanceof AmbExpr) { AmbExpr amb = (AmbExpr) n; Modified: trunk/x10.dist/samples/CUDA/CUDABlackScholes.x10 =================================================================== --- trunk/x10.dist/samples/CUDA/CUDABlackScholes.x10 2011-01-27 22:49:58 UTC (rev 19778) +++ trunk/x10.dist/samples/CUDA/CUDABlackScholes.x10 2011-01-27 23:41:05 UTC (rev 19779) @@ -150,11 +150,11 @@ Console.OUT.println("Generating a second set of results at place " + cpu); doBlackScholes(cpu, - new RemoteArray[Float](h_OptionYears), - new RemoteArray[Float](h_StockPrice), - new RemoteArray[Float](h_OptionStrike), - new RemoteArray[Float](h_CallResultCPU), - new RemoteArray[Float](h_PutResultCPU), + new RemoteArray[Float](h_OptionYears) as RemoteArray[Float]{home==cpu && rank==1}, + new RemoteArray[Float](h_StockPrice) as RemoteArray[Float]{home==cpu && rank==1}, + new RemoteArray[Float](h_OptionStrike) as RemoteArray[Float]{home==cpu && rank==1}, + new RemoteArray[Float](h_CallResultCPU) as RemoteArray[Float]{home==cpu && rank==1}, + new RemoteArray[Float](h_PutResultCPU) as RemoteArray[Float]{home==cpu && rank==1}, OPT_N, RISKFREE, VOLATILITY); Modified: trunk/x10.tests/examples/Constructs/Array/ArrayAccessWithMismatchingPointRank_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayAccessWithMismatchingPointRank_MustFailCompile.x10 2011-01-27 22:49:58 UTC (rev 19778) +++ trunk/x10.tests/examples/Constructs/Array/ArrayAccessWithMismatchingPointRank_MustFailCompile.x10 2011-01-27 23:41:05 UTC (rev 19779) @@ -11,6 +11,8 @@ import harness.x10Test; +// OPTIONS: -STATIC_CALLS because without will just insert a cast: Warning: Expression 'p' was cast to type ... + /** * Simple array test. * Testing that ia(p) gives an error, where ia:Array[int](1) and p:Point(2). @@ -28,7 +30,7 @@ val p1 = [1] as Point; a(ia(p1)); // ok - a(ia(p)); // ERR ShouldNotBeERR should fail at compile time because of mismatching rank. + a(ia(p)); // ERR should fail at compile time because of mismatching rank. return true; } Modified: trunk/x10.tests/examples/Constructs/Class/InconsistentInvariant_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Class/InconsistentInvariant_MustFailCompile.x10 2011-01-27 22:49:58 UTC (rev 19778) +++ trunk/x10.tests/examples/Constructs/Class/InconsistentInvariant_MustFailCompile.x10 2011-01-27 23:41:05 UTC (rev 19779) @@ -21,7 +21,7 @@ public class InconsistentInvariant_MustFailCompile extends x10Test { - interface Inv(i:Int){i==0, i==1}{} // ERR: Class invariant is inconsistent. + interface Inv(i:Int){i==0, i==1}{} // ShouldBeErr: Class invariant is inconsistent. public def run()=false; public static def main(Array[String](1)) { new InconsistentInvariant_MustFailCompile().execute(); Modified: trunk/x10.tests/examples/Constructs/DepType/ClassDepClause_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/ClassDepClause_MustFailCompile.x10 2011-01-27 22:49:58 UTC (rev 19778) +++ trunk/x10.tests/examples/Constructs/DepType/ClassDepClause_MustFailCompile.x10 2011-01-27 23:41:05 UTC (rev 19779) @@ -21,7 +21,8 @@ public static type ClassDepClause_MustFailCompile(i:int, j:int)=ClassDepClause_MustFailCompile{self.i==i,self.j==j}; public def this(i: int, j: int): ClassDepClause_MustFailCompile(i,j) = { property(i,j);} // ShouldBeErr public def run(): boolean = { - var x: ClassDepClause_MustFailCompile(2,3) = new ClassDepClause_MustFailCompile(2,3); // ShouldBeErr + var x: ClassDepClause_MustFailCompile(2,3) = // ERR: Semantic Error: Invalid type; the real clause of ClassDepClause_MustFailCompile{self.i==2, self.j==3} is inconsistent. + new ClassDepClause_MustFailCompile(2,3); // ERR: Semantic Error: Cannot assign expression to target. return true; } Modified: trunk/x10.tests/examples/Constructs/DepType/DepTypeConsistency1_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/DepTypeConsistency1_MustFailCompile.x10 2011-01-27 22:49:58 UTC (rev 19778) +++ trunk/x10.tests/examples/Constructs/DepType/DepTypeConsistency1_MustFailCompile.x10 2011-01-27 23:41:05 UTC (rev 19779) @@ -20,8 +20,8 @@ public class DepTypeConsistency1_MustFailCompile extends x10Test { /* free variable i is not parametrically consistent */ - class Tester(i:int{self == 2}){i == 3} { // ShouldBeErr - public def this(arg:int):Tester = { property(arg);} // ShouldNotBeERR ShouldNotBeERR (The return type of the constructor (DepTypeConsistency1_MustFailCompile.Tester) must be derived from the type of the class (DepTypeConsistency1_MustFailCompile.Tester) on which the constructor is defined.) + class Tester(i:int{self == 2}){i == 3} { // ERR ERR ERR ERR: [Semantic Error: Invalid type; the real clause of DepTypeConsistency1_MustFailCompile.Tester{self==DepTypeConsistency1_MustFailCompile.Tester#this} is inconsistent. , Semantic Error: Invalid type; the real clause of DepTypeConsistency1_MustFailCompile.Tester is inconsistent.] + public def this(arg:int):Tester = { property(arg);} // ShouldNotBeERR: [Semantic Error: Invalid type; the real clause of DepTypeConsistency1_MustFailCompile.Tester{self.i==arg} is inconsistent.] } public def run()=true; Modified: trunk/x10.tests/examples/Constructs/DepType/DepTypeConsistency2_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/DepTypeConsistency2_MustFailCompile.x10 2011-01-27 22:49:58 UTC (rev 19778) +++ trunk/x10.tests/examples/Constructs/DepType/DepTypeConsistency2_MustFailCompile.x10 2011-01-27 23:41:05 UTC (rev 19779) @@ -20,8 +20,8 @@ public class DepTypeConsistency2_MustFailCompile extends x10Test { /* free variable i is not parametrically consistent */ - class Tester(i:int{self == 2,self==3}) { // ERR ERR: Type x10.lang.Int{inconsistent} is inconsistent. Invalid type; the real clause of x10.lang.Int{inconsistent} is inconsistent. - public def this(arg:int):Tester = { property(arg);} + class Tester(i:int{self == 2,self==3}) { // ERR ERR ERR: Type x10.lang.Int{inconsistent} is inconsistent. Invalid type; the real clause of x10.lang.Int{inconsistent} is inconsistent. + public def this(arg:int):Tester = { property(arg);} // ShouldNotBeERR: Semantic Error: Invalid type; the real clause of DepTypeConsistency2_MustFailCompile.Tester{self.i==arg} is inconsistent. } public def run()=true; Modified: trunk/x10.tests/examples/Constructs/DepType/DepTypeConsistency_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/DepTypeConsistency_MustFailCompile.x10 2011-01-27 22:49:58 UTC (rev 19778) +++ trunk/x10.tests/examples/Constructs/DepType/DepTypeConsistency_MustFailCompile.x10 2011-01-27 23:41:05 UTC (rev 19779) @@ -20,7 +20,7 @@ public class DepTypeConsistency_MustFailCompile extends x10Test { static val j:int = 3; /* free variable j is not parametrically consistent */ - class Tester(i:int){j == 2} { // ERR + class Tester(i:int){j == 2} { // ShouldBeErr public def this(arg:int):Tester { property(arg); } } Modified: trunk/x10.tests/examples/Constructs/DepType/InconsistentInterfaceInvariants_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/InconsistentInterfaceInvariants_MustFailCompile.x10 2011-01-27 22:49:58 UTC (rev 19778) +++ trunk/x10.tests/examples/Constructs/DepType/InconsistentInterfaceInvariants_MustFailCompile.x10 2011-01-27 23:41:05 UTC (rev 19779) @@ -17,6 +17,7 @@ * */ import harness.x10Test; +import x10.compiler.tests.*; // err markers /** Tests that invariants due to a super constraint and a sub constraint are * consistent with each other. @@ -29,7 +30,7 @@ public def put():int; } - public static interface Test1{this.l == 0, this.m == 1} extends Test { + @ERR public static interface Test1{this.l == 0, this.m == 1} extends Test { // Semantic Error: Class invariant is inconsistent. public def foo(): int; } Modified: trunk/x10.tests/examples/Constructs/Structs/StructObscuringExample.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Structs/StructObscuringExample.x10 2011-01-27 22:49:58 UTC (rev 19778) +++ trunk/x10.tests/examples/Constructs/Structs/StructObscuringExample.x10 2011-01-27 23:41:05 UTC (rev 19779) @@ -21,7 +21,7 @@ import x10.compiler.*; // @Uncounted @NonEscaping @NoThisAccess import x10.compiler.tests.*; // err markers -public class StructObscuringExample extends x10Test { +public class StructObscuringExample extends x10Test { // ShouldNotBeERR ShouldNotBeERR: Could not find type "eg.eg.StructObscuringExample". public static def main(Array[String](1)){ val p = new StructObscuringExample(); p.execute(); @@ -34,9 +34,9 @@ } -struct eg { // ShouldNotBeERR +struct eg { // ShouldNotBeERR ShouldNotBeERR static def ow()= 1; - static struct Bite { // ShouldNotBeERR ShouldNotBeERR + static struct Bite { // ShouldNotBeERR ShouldNotBeERR ShouldNotBeERR def ow() = 2; } def example() { Modified: trunk/x10.tests/examples/Issues/XTENLANG_2330.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_2330.x10 2011-01-27 22:49:58 UTC (rev 19778) +++ trunk/x10.tests/examples/Issues/XTENLANG_2330.x10 2011-01-27 23:41:05 UTC (rev 19779) @@ -181,7 +181,7 @@ try { this(z+51) += z+0; fail(); } catch (e:UnsatisfiedGuardException) {} // ERR // We already handle: Call, New, Binary, Unary, SettableAssign, Cast - // We still need to handle in the desugarer: ConstructorCall (XTENLANG_2376) , ClosureCall & Unary (XTENLANG_2329) + // We still need to handle in the desugarer: ConstructorCall (XTENLANG_2376) , ClosureCall (XTENLANG_2329) // far to do: after XTENLANG_2376 is resolved, we should check runtime checks for guards for ctor calls (super&this) // todo: After XTENLANG_2329 is resolved, we could check guards for closure calls @@ -248,13 +248,13 @@ super(i); property(i); } - def this(i1:Int, i2:Int) {i1!=i2, i1==p} : C { // testing 2 binary expressions + def this(i1:Int, i2:Int) {i1!=i2, i1==p} { // testing 2 binary expressions super(i1); property(i2); } class D(d:Int) extends A { - def this(i1:Int, i2:Int) {i1!=i2, i1==p, i2==c} : D { // testing 3 binary expressions + def this(i1:Int, i2:Int) {i1!=i2, i1==p, i2==c} { // testing 3 binary expressions super(i1); property(i2); } @@ -272,7 +272,6 @@ // Here I just test that post-compilation works on more complicated examples (but I don't check runtime behaviour) class TestWithoutGenerics { - public static def main(argv:Array[String](1)) {} static def m2(a:Int, b:Outer.A) {a==44, b.x.x.y==35} = 1; class Outer(zz:Int) { Modified: trunk/x10.tests/examples/Misc/x10/frontend/tests/FrontEndTests_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Misc/x10/frontend/tests/FrontEndTests_MustFailCompile.x10 2011-01-27 22:49:58 UTC (rev 19778) +++ trunk/x10.tests/examples/Misc/x10/frontend/tests/FrontEndTests_MustFailCompile.x10 2011-01-27 23:41:05 UTC (rev 19779) @@ -12,6 +12,9 @@ package x10.frontend.tests; // TODO: We should put ALL our tests in different packages according to the directory structure +// OPTIONS: -STATIC_CALLS + + import harness.x10Test; import x10.compiler.*; // @Uncounted @NonEscaping @NoThisAccess @@ -2233,10 +2236,10 @@ } } interface I2 extends I{p==2} {} // ShouldBeErr - interface I3 {p==3} extends I2 {} // ShouldBeErr + @ERR interface I3 {p==3} extends I2 {} // Class invariant is inconsistent. static def test(i:I) { - @ShouldBeErr var i1:I{p==5} = i; - var i2:I{p==1} = i; + @ERR var i1:I{p==5} = i; + @ShouldNotBeERR var i2:I{p==1} = i; } } @@ -2248,8 +2251,8 @@ static def test(a:OuterThisConstraint{i==3}) { val inner:OuterThisConstraint{self.i==3}.Inner = a.new Inner(); val x1:OuterThisConstraint{i==3} = a.m1(); - val x2:OuterThisConstraint{i==3} = inner.m2(); - @ShouldBeErr val x3:OuterThisConstraint{i==4} = inner.m2(); + @ShouldNotBeERR val x2:OuterThisConstraint{i==3} = inner.m2(); + @ERR val x3:OuterThisConstraint{i==4} = inner.m2(); } } @@ -3254,7 +3257,7 @@ class XTENLANG_1574(v:Int) {v==1} { static def m(a:XTENLANG_1574) { val b:XTENLANG_1574{self.v==1} = a; - @ERR val b2:XTENLANG_1574{self.v==2} = a; + @ERR @ERR val b2:XTENLANG_1574{self.v==2} = a; // [Semantic Error: Cannot assign expression to target. Expression: a Expected type: x10.frontend.tests.XTENLANG_1574{self.v==2} Found type: x10.frontend.tests.XTENLANG_1574{self==a}, Semantic Error: Invalid type; the real clause of x10.frontend.tests.XTENLANG_1574{self.v==2} is inconsistent.] } } class TestMethodGuards[T](a:Int, p:Place) { @@ -3585,13 +3588,13 @@ static class A(v:Int) {v==1} { static def m(a:A) { val b:A{self.v==1} = a; - @ERR val b2:A{self.v==2} = a; + @ERR @ERR val b2:A{self.v==2} = a; } def m2(a:A) { val b1:A{self.v==1} = this; val b2:A{this.v==1} = this; val b3:A{self.v==1} = a; - @ERR val b33:A{self.v==2} = a; + @ERR @ERR val b33:A{self.v==2} = a; val b4:A{this.v==1} = a; } } @@ -4068,9 +4071,9 @@ property i() = 5; @ERR class R extends R {i()==5} {} @ERR class R1 {i()==3} {} - @ERR class R2 {@ERR i()==3} extends R2 {} + @ERR class R2 {i()==3} extends R2 {} // [Semantic Error: Circular inheritance involving x10.frontend.tests.CircularityTestsWithInheritanceInterfacesAndStructs.R2] class R3 {} - @ERR @ERR @ERR class R4 extends R3 {@ERR i()==3} {} + @ERR @ERR class R4 extends R3 {i()==3} {} // [Semantic Error: Invalid type; the real clause of x10.frontend.tests.CircularityTestsWithInheritanceInterfacesAndStructs.R3{inconsistent} is inconsistent., Semantic Error: Type x10.frontend.tests.CircularityTestsWithInheritanceInterfacesAndStructs.R3{inconsistent} is inconsistent.] @ERR static class W extends W {} static val i=3; @@ -4496,4 +4499,38 @@ property(6); // ShouldNotBeERR: Semantic Error: Instances created by this constructor do not satisfy return type Constraint satisfied: {X.C#this.b==5, X.C#this.c==6, i1!=i2} Constraint required: {X.C#this.b==5, X.C#this.c==6, i1!=i2} } } +} +class CodegenForHasZeroTest[T] { // see XTENLANG-2388 + def m() { + @ShouldNotBeERR val b = T haszero; // Unhandled node type: class x10.ast.HasZeroTest_c + } +} +class XTENLANG_2389 { + property foo()=A.this; + class B { + property bar()=A.this; + property foo2()=B.this; + } + def bla(a1:A, a2:A{this==a1}) { + @ShouldBeErr val a3:A{self==a1} = a2; + @ShouldBeErr val a4:A{self!=a1} = a2; + } + + def test1(a1:A, a2:A{self.foo()==a1}) {} + def test2(a1:A, a2:A{A.this==a1}) { + @ERR { test1(a1,a2); } + } + def test3(a1:A, b2:B{self.bar()==a1}) {} + def test4(a:A, b:B{A.this==a}) { + @ShouldBeErr { test3(a,b); } + } +} + +class XTENLANG_2390 { + protected val a:Int; + def this(x:Int) { + a = x; + } + def m1(i:Int{self==a}) {} // ShouldBeErr + def m2() {2==a} {} // ShouldBeErr } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2011-02-04 03:49:54
|
Revision: 19916 http://x10.svn.sourceforge.net/x10/?rev=19916&view=rev Author: vj0 Date: 2011-02-04 03:49:48 +0000 (Fri, 04 Feb 2011) Log Message: ----------- Restore hasVar(XVar) on popular demand. Modified Paths: -------------- trunk/x10.compiler/src/polyglot/types/Types.java trunk/x10.compiler/src/x10/types/XTypeTranslator.java trunk/x10.compiler/src/x10/types/constraints/CSelf.java trunk/x10.compiler/src/x10/types/constraints/CThis.java trunk/x10.constraints/src/x10/constraint/XEQV.java trunk/x10.constraints/src/x10/constraint/XField.java trunk/x10.constraints/src/x10/constraint/XFormula.java trunk/x10.constraints/src/x10/constraint/XLocal.java trunk/x10.constraints/src/x10/constraint/XTerm.java trunk/x10.constraints/src/x10/constraint/XUQV.java Modified: trunk/x10.compiler/src/polyglot/types/Types.java =================================================================== --- trunk/x10.compiler/src/polyglot/types/Types.java 2011-02-04 03:29:27 UTC (rev 19915) +++ trunk/x10.compiler/src/polyglot/types/Types.java 2011-02-04 03:49:48 UTC (rev 19916) @@ -501,7 +501,7 @@ return null; } - /*public static boolean hasVar(Type t, XVar x) { + public static boolean hasVar(Type t, XVar x) { if (t instanceof ConstrainedType) { ConstrainedType ct = (ConstrainedType) t; Type b = baseType(t); @@ -518,7 +518,7 @@ } return false; } -*/ + /** Modified: trunk/x10.compiler/src/x10/types/XTypeTranslator.java =================================================================== --- trunk/x10.compiler/src/x10/types/XTypeTranslator.java 2011-02-04 03:29:27 UTC (rev 19915) +++ trunk/x10.compiler/src/x10/types/XTypeTranslator.java 2011-02-04 03:49:48 UTC (rev 19916) @@ -329,10 +329,10 @@ return (Type) val; } - /* public boolean hasVar(XVar v) { + public boolean hasVar(XVar v) { return Types.hasVar(type(), v); } -*/ + public XTypeLit subst(XTerm y, XVar x, boolean propagate) { XTypeLit n = (XTypeLit) super.subst(y, x, propagate); Type newVal = n.type(); Modified: trunk/x10.compiler/src/x10/types/constraints/CSelf.java =================================================================== --- trunk/x10.compiler/src/x10/types/constraints/CSelf.java 2011-02-04 03:29:27 UTC (rev 19915) +++ trunk/x10.compiler/src/x10/types/constraints/CSelf.java 2011-02-04 03:49:48 UTC (rev 19916) @@ -28,6 +28,10 @@ public int hashCode() { return num; } + + public boolean hasVar(XVar v) { + return equals(v); + } public boolean equals(Object o) { if (this == o) return true; Modified: trunk/x10.compiler/src/x10/types/constraints/CThis.java =================================================================== --- trunk/x10.compiler/src/x10/types/constraints/CThis.java 2011-02-04 03:29:27 UTC (rev 19915) +++ trunk/x10.compiler/src/x10/types/constraints/CThis.java 2011-02-04 03:49:48 UTC (rev 19916) @@ -42,6 +42,11 @@ public int hashCode() { return num; } + + + public boolean hasVar(XVar v) { + return equals(v); + } @Override public boolean equals(Object o) { if (this == o) Modified: trunk/x10.constraints/src/x10/constraint/XEQV.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XEQV.java 2011-02-04 03:29:27 UTC (rev 19915) +++ trunk/x10.constraints/src/x10/constraint/XEQV.java 2011-02-04 03:49:48 UTC (rev 19916) @@ -41,7 +41,10 @@ public boolean prefersBeingBound() { return true; } - + + public boolean hasVar(XVar v) { + return equals(v); + } @Override public boolean hasEQV() { return true; Modified: trunk/x10.constraints/src/x10/constraint/XField.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XField.java 2011-02-04 03:29:27 UTC (rev 19915) +++ trunk/x10.constraints/src/x10/constraint/XField.java 2011-02-04 03:49:48 UTC (rev 19916) @@ -70,11 +70,11 @@ public String name() { return field.toString(); } -/* + public boolean hasVar(XVar v) { return equals(v) || receiver.hasVar(v); } -*/ + public XVar receiver() { return receiver; } Modified: trunk/x10.constraints/src/x10/constraint/XFormula.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XFormula.java 2011-02-04 03:29:27 UTC (rev 19915) +++ trunk/x10.constraints/src/x10/constraint/XFormula.java 2011-02-04 03:49:48 UTC (rev 19916) @@ -114,14 +114,14 @@ public List<XTerm> arguments() { return arguments; } -/* public boolean hasVar(XVar v) { + public boolean hasVar(XVar v) { for (XTerm arg : arguments) { if (arg.hasVar(v)) return true; } return false; } -*/ + public XPromise internIntoConstraint(XConstraint c, XPromise last) { assert last == null; // Evaluate left == right, if both are literals. Modified: trunk/x10.constraints/src/x10/constraint/XLocal.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XLocal.java 2011-02-04 03:29:27 UTC (rev 19915) +++ trunk/x10.constraints/src/x10/constraint/XLocal.java 2011-02-04 03:49:48 UTC (rev 19916) @@ -35,7 +35,11 @@ public int hashCode() { return name.hashCode(); } - @Override + + public boolean hasVar(XVar v) { + return equals(v); + } + public boolean equals(Object o) { if (this == o) return true; Modified: trunk/x10.constraints/src/x10/constraint/XTerm.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XTerm.java 2011-02-04 03:29:27 UTC (rev 19915) +++ trunk/x10.constraints/src/x10/constraint/XTerm.java 2011-02-04 03:49:48 UTC (rev 19916) @@ -130,7 +130,7 @@ * @param v -- the variable being checked. * @return true if v occurs in this */ - //public abstract boolean hasVar(XVar v); + public abstract boolean hasVar(XVar v); /** Intern this term into constraint and return the promise Modified: trunk/x10.constraints/src/x10/constraint/XUQV.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XUQV.java 2011-02-04 03:29:27 UTC (rev 19915) +++ trunk/x10.constraints/src/x10/constraint/XUQV.java 2011-02-04 03:49:48 UTC (rev 19916) @@ -41,6 +41,9 @@ return false; } + public boolean hasVar(XVar v) { + return equals(v); + } @Override public String toString() { return str == null ? "uqv" + num: str; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2011-03-07 19:09:30
|
Revision: 20538 http://x10.svn.sourceforge.net/x10/?rev=20538&view=rev Author: yzibin Date: 2011-03-07 19:09:23 +0000 (Mon, 07 Mar 2011) Log Message: ----------- * removed the auto-generated nullary property method for every property field. * fixed suite accordingly Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/PropertyDecl_c.java trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java trunk/x10.runtime/src-x10/x10/array/Array.x10 trunk/x10.runtime/src-x10/x10/array/Point.x10 trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 trunk/x10.runtime/src-x10/x10/lang/GlobalRef.x10 trunk/x10.runtime/src-x10/x10/lang/MultipleExceptions.x10 trunk/x10.runtime/src-x10/x10/lang/Place.x10 trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeClassOne.x10 trunk/x10.tests/examples/Constructs/DepType/InterfaceProp.x10 trunk/x10.tests/examples/Constructs/DepType/InterfaceTypeInvariant.x10 trunk/x10.tests/examples/Constructs/DepType/InterfaceTypeInvariant_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/DepType/SamePropertyAncestor_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Inheritance/InheritedInvariantMustBeEntailed_MustFailCompile.x10 trunk/x10.tests/examples/Misc/x10/frontend/tests/FrontEndTests_MustFailCompile.x10 Modified: trunk/x10.compiler/src/x10/ast/PropertyDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/PropertyDecl_c.java 2011-03-07 18:24:31 UTC (rev 20537) +++ trunk/x10.compiler/src/x10/ast/PropertyDecl_c.java 2011-03-07 19:09:23 UTC (rev 20538) @@ -62,7 +62,6 @@ * @param properties -- properties declared with the class or interface. * @param body -- the body of the class or interface * @return body, with properties and getters added. - */ public static ClassBody addPropertyGetters(List<PropertyDecl> properties, ClassBody body, NodeFactory nf) { if (properties != null) { @@ -72,6 +71,7 @@ } return body; } + */ /** * Return body, augmented with getters. Used for interfaces. May be called during @@ -80,7 +80,6 @@ * @param properties -- properties declared with the class or interface. * @param body -- the body of the class or interface * @return body, with properties and getters added. - */ public static ClassBody addAbstractGetters(List<PropertyDecl> properties, ClassBody body, NodeFactory nf) { if (properties != null) { for (PropertyDecl p : properties) { @@ -89,7 +88,9 @@ } return body; } + */ + /* private Position getCompilerGenPos() { return Position.compilerGenerated(position()); } protected MethodDecl getter(NodeFactory nf) { TypeSystem ts = (TypeSystem) nf.extensionInfo().typeSystem(); @@ -106,16 +107,17 @@ MethodDecl getter = nf.MethodDecl(pos, nf.FlagsNode(pos, flags), type, name, formals, body); return getter; } + */ /** * For Interfaces with properties, an abstract method signature for each property * is generated in the interface body. * Any class implementing the interface has to have the same property - * <RAJ> - */ + * <RAJ> protected MethodDecl abstractGetter(NodeFactory nf) { MethodDecl abstractGetter = nf.MethodDecl(getCompilerGenPos(), nf.FlagsNode(getCompilerGenPos(), Flags.PROPERTY.Public().Abstract()), type, name, Collections.<Formal>emptyList(), null); return abstractGetter; } + */ } Modified: trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java 2011-03-07 18:24:31 UTC (rev 20537) +++ trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java 2011-03-07 19:09:23 UTC (rev 20538) @@ -301,12 +301,11 @@ private X10ClassDecl ClassDecl(Position pos, FlagsNode flags, Id name, List<TypeParamNode> typeParameters, List<PropertyDecl> properties, TypeNode superClass, List<TypeNode> interfaces, ClassBody body, DepParameterExpr tci) { - boolean isInterface = flags.flags().isInterface(); - if (flags.flags().isInterface()) { + /*if (flags.flags().isInterface()) { body = PropertyDecl_c.addAbstractGetters(properties, body, this); } else { body = PropertyDecl_c.addPropertyGetters(properties, body, this); - } + }*/ X10ClassDecl n = new X10ClassDecl_c(pos, flags, name, typeParameters, properties, tci, superClass, interfaces, body); n = (X10ClassDecl)n.ext(extFactory().extClassDecl()); n = (X10ClassDecl)n.del(delFactory().delClassDecl()); Modified: trunk/x10.runtime/src-x10/x10/array/Array.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/Array.x10 2011-03-07 18:24:31 UTC (rev 20537) +++ trunk/x10.runtime/src-x10/x10/array/Array.x10 2011-03-07 19:09:23 UTC (rev 20538) @@ -86,6 +86,13 @@ size:Int ) implements (Point(region.rank))=>T, Iterable[Point(region.rank)] { + + public property region():Region{self != null} = region; + public property rank():int{self==region.rank} = rank; + public property rect():boolean{self==region.rect} = rect; + public property zeroBased():boolean{self==region.zeroBased} = zeroBased; + public property rail():boolean{self==region.rail} = rail; + public property size():Int = size; /** * The backing storage for the array's elements @@ -355,6 +362,7 @@ // TODO: Should be annonymous nested class in values, // but that's too fragile with the 2.1 implementation of generics. private class ValueSequence(size:int) implements Sequence[T] { + public property size():int = size; val array = Array.this as Array[T](1); public def iterator() = new ValueIterator(Array.this); def this() { Modified: trunk/x10.runtime/src-x10/x10/array/Point.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/Point.x10 2011-03-07 18:24:31 UTC (rev 20537) +++ trunk/x10.runtime/src-x10/x10/array/Point.x10 2011-03-07 19:09:23 UTC (rev 20538) @@ -26,6 +26,8 @@ public final class Point(rank:Int) implements (Int) => Int, Ordered[Point(rank)], Comparable[Point(rank)] { + public property rank():Int = rank; + private val c0:int; private val c1:int; private val c2:int; Modified: trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 2011-03-07 18:24:31 UTC (rev 20537) +++ trunk/x10.runtime/src-x10/x10/array/PolyMat.x10 2011-03-07 19:09:23 UTC (rev 20538) @@ -24,6 +24,7 @@ * object. */ class PolyMat(rank: int) extends Mat[PolyRow] { + public property rank():int = rank; static type PolyMat(rank:Int) = PolyMat{self.rank==rank}; static type PolyMatBuilder(rank:Int) = PolyMatBuilder{self.rank==rank}; Modified: trunk/x10.runtime/src-x10/x10/lang/GlobalRef.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/GlobalRef.x10 2011-03-07 18:24:31 UTC (rev 20537) +++ trunk/x10.runtime/src-x10/x10/lang/GlobalRef.x10 2011-03-07 19:09:23 UTC (rev 20538) @@ -29,7 +29,8 @@ public struct GlobalRef[T]( @Native("java", "(#0).home") @Native("c++", "x10::lang::Place_methods::place((#this)->location)") - home:Place) {T <: Object} { + home:Place) {T <: Object} { + public property home():Place = home; /** * Create a value encapsulating the given object of type T. Modified: trunk/x10.runtime/src-x10/x10/lang/MultipleExceptions.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/MultipleExceptions.x10 2011-03-07 18:24:31 UTC (rev 20537) +++ trunk/x10.runtime/src-x10/x10/lang/MultipleExceptions.x10 2011-03-07 19:09:23 UTC (rev 20538) @@ -20,6 +20,7 @@ * @author tardieu */ public class MultipleExceptions(exceptions:Array[Throwable](1){rail}) extends Exception { + public property exceptions():Array[Throwable](1){rail} = exceptions; public def this(stack:Stack[Throwable]) { property(stack.toArray()); Modified: trunk/x10.runtime/src-x10/x10/lang/Place.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Place.x10 2011-03-07 18:24:31 UTC (rev 20537) +++ trunk/x10.runtime/src-x10/x10/lang/Place.x10 2011-03-07 19:09:23 UTC (rev 20538) @@ -25,6 +25,7 @@ * @author Dave Cunningham */ public final struct Place(id: Int) { + public property id():Int = id; /** The number of places including accelerators. * Accelerator places have limitations on the kinds of code they can run. Modified: trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeClassOne.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeClassOne.x10 2011-03-07 18:24:31 UTC (rev 20537) +++ trunk/x10.tests/examples/Constructs/Cast/ReferenceDependentTypeCast/X10DepTypeClassOne.x10 2011-03-07 19:09:23 UTC (rev 20538) @@ -16,7 +16,7 @@ * @author vcave **/ public class X10DepTypeClassOne(p:int) extends x10Test implements X10InterfaceOne { - + public property p():int = p; public def this(p: int): X10DepTypeClassOne{self.p==p} = { property(p); Modified: trunk/x10.tests/examples/Constructs/DepType/InterfaceProp.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/InterfaceProp.x10 2011-03-07 18:24:31 UTC (rev 20537) +++ trunk/x10.tests/examples/Constructs/DepType/InterfaceProp.x10 2011-03-07 19:09:23 UTC (rev 20538) @@ -34,6 +34,7 @@ } class E(m:int, k:int) extends D implements J{ + public property k():int = k; public def this(mm:int, nn:int, ii:int, kk:int):E { super(nn,ii); property(mm, kk); @@ -43,6 +44,7 @@ } } class D(n:int, i:int) implements I { + public property i():int = i; public def this(nn:int, ii:int):D { property(nn, ii); } public def a():void= { var x:int; Modified: trunk/x10.tests/examples/Constructs/DepType/InterfaceTypeInvariant.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/InterfaceTypeInvariant.x10 2011-03-07 18:24:31 UTC (rev 20537) +++ trunk/x10.tests/examples/Constructs/DepType/InterfaceTypeInvariant.x10 2011-03-07 19:09:23 UTC (rev 20538) @@ -27,6 +27,8 @@ } class Tester(l:int, m:int){this.m == this.l} implements Test { + public property l():int = l; + public property m():int = m; public def this(arg:int):Tester { property(arg,arg); } public def put()=0; } Modified: trunk/x10.tests/examples/Constructs/DepType/InterfaceTypeInvariant_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/InterfaceTypeInvariant_MustFailCompile.x10 2011-03-07 18:24:31 UTC (rev 20537) +++ trunk/x10.tests/examples/Constructs/DepType/InterfaceTypeInvariant_MustFailCompile.x10 2011-03-07 19:09:23 UTC (rev 20538) @@ -34,20 +34,28 @@ def put():int; } - @ERR class Tester1(n: int, m:int) implements Test{ + class Tester1(n: int, m:int) implements Test{ + public property n():int = n; + @ERR public property m():int = m; public def this() = { property(3,2); } public def put()=0; } - @ShouldNotBeERR class Tester2(n: int, m:int{self==this.n()}) implements Test{ + class Tester2(n: int, m:int{self==this.n()}) implements Test{ + public property n():int = n; + @ShouldNotBeERR public property m():int{self==this.n()} = m; @ERR @ERR public def this() = { property(3,2); } // [Semantic Error: Invalid type; the real clause of InterfaceTypeInvariant_MustFailCompile.Tester2{self.n==3, self.m==2} is inconsistent.] public def put()=0; } - @ShouldNotBeERR class Tester3(n: int, m:int{self==this.n()}) implements Test{ + class Tester3(n: int, m:int{self==this.n()}) implements Test{ + public property n():int = n; + @ShouldNotBeERR public property m():int{self==this.n()} = m; public def this() = { property(3,3); } public def put()=0; } - @ERR @ERR class Tester(l: int, m:int){m == 2 && l == 3} implements Test{ // InterfaceTypeInvariant_MustFailCompile.Tester should be declared abstract; it does not define n(): x10.lang.Int, which is declared in InterfaceTypeInvariant_MustFailCompile.Test + class Tester(l: int, m:int){m == 2 && l == 3} implements Test{ // InterfaceTypeInvariant_MustFailCompile.Tester should be declared abstract; it does not define n(): x10.lang.Int, which is declared in InterfaceTypeInvariant_MustFailCompile.Test + public property n():int = n; + @ERR public property m():int = m; public def this():Tester = { property(3,2); } public def put()=0; } Modified: trunk/x10.tests/examples/Constructs/DepType/SamePropertyAncestor_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/SamePropertyAncestor_MustFailCompile.x10 2011-03-07 18:24:31 UTC (rev 20537) +++ trunk/x10.tests/examples/Constructs/DepType/SamePropertyAncestor_MustFailCompile.x10 2011-03-07 19:09:23 UTC (rev 20538) @@ -32,7 +32,7 @@ } } - class Test2(i: int) extends Test { // ERR ERR ([Semantic Error: i(): x10.lang.Int in SamePropertyAncestor_MustFailCompile.Test2 cannot override i(): x10.lang.Int in SamePropertyAncestor_MustFailCompile.Test; overridden method is final, Semantic Error: Class SamePropertyAncestor_MustFailCompile.Test2 cannot override property i of superclass SamePropertyAncestor_MustFailCompile.Test.]) + class Test2(i: int) extends Test { // ERR ([Semantic Error: Class cannot override property of superclass.]) def this(i:int):Test2 = { super(i,i); Modified: trunk/x10.tests/examples/Constructs/Inheritance/InheritedInvariantMustBeEntailed_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Inheritance/InheritedInvariantMustBeEntailed_MustFailCompile.x10 2011-03-07 18:24:31 UTC (rev 20537) +++ trunk/x10.tests/examples/Constructs/Inheritance/InheritedInvariantMustBeEntailed_MustFailCompile.x10 2011-03-07 19:09:23 UTC (rev 20538) @@ -24,8 +24,10 @@ def put():int; } - // must fail here + // must fail here. todo: why? what is wrong here? class Tester (l:int, m:int) implements Test { + public property l():int = l; + public property m():int = m; public def this(arg:int):Tester { property(arg,arg); } public def put()=0; } Modified: trunk/x10.tests/examples/Misc/x10/frontend/tests/FrontEndTests_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Misc/x10/frontend/tests/FrontEndTests_MustFailCompile.x10 2011-03-07 18:24:31 UTC (rev 20537) +++ trunk/x10.tests/examples/Misc/x10/frontend/tests/FrontEndTests_MustFailCompile.x10 2011-03-07 19:09:23 UTC (rev 20538) @@ -909,6 +909,7 @@ class PropertyTest(p:Int) { + public property p():Int = p; static val i = 3; def this() { property(1); @@ -2238,6 +2239,7 @@ public property p():Int; } class C(p:Int) implements I { + public property p():Int = p; def this() { property(0); // ShouldBeErr } @@ -4149,8 +4151,12 @@ interface Comparable[T] { public property i():T; } - class Foo(i:Foo) implements Comparable[Foo] {} - @ERR class Foo2(i:Comparable[Foo2]) implements Comparable[Foo2] {} + class Foo(i:Foo) implements Comparable[Foo] { + public property i():Foo = i; + } + class Foo2(i:Comparable[Foo2]) implements Comparable[Foo2] { + @ERR public property i():Comparable[Foo2] = i; + } } class ConformanceChecks { // see XTENLANG-989 @@ -4242,6 +4248,8 @@ public property i():Int; } class B(i:Int{self==0}) implements A { + public property i():Int = i; + val k1:Int{self==0} = this.i; @ERR val k2:Int{self==1} = this.i; } @@ -4807,6 +4815,7 @@ public property p():Int; } class C(p:Int) implements I { + public property p():Int = p; def this() { property(0); // ShouldBeErr } @@ -5048,10 +5057,12 @@ def m() {z==1} : void; } class Example1(z:Int) implements I5 { + public property z():Int = z; def example() = a; public def m() {z==1} {}; } class Example2(z:Int) implements I5,I3 { + public property z():Int = z; def example() = a; public def m() {z==1} {}; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2011-03-10 18:40:33
|
Revision: 20618 http://x10.svn.sourceforge.net/x10/?rev=20618&view=rev Author: dgrove-oss Date: 2011-03-10 18:40:22 +0000 (Thu, 10 Mar 2011) Log Message: ----------- XTENLANG-587 : Array init closure is evaulated sequentially. Augmented API doc for Array and DistArray constructor to clarify how closure will be evaluated (and in particular to make this test case invalid). Delete test case as it has been ruled invalid. Modified Paths: -------------- trunk/x10.runtime/src-x10/x10/array/Array.x10 trunk/x10.runtime/src-x10/x10/array/DistArray.x10 trunk/x10.runtime/src-x10/x10/array/Region.x10 Removed Paths: ------------- trunk/x10.tests/examples/Issues/XTENLANG_587.x10 Modified: trunk/x10.runtime/src-x10/x10/array/Array.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/Array.x10 2011-03-10 18:23:58 UTC (rev 20617) +++ trunk/x10.runtime/src-x10/x10/array/Array.x10 2011-03-10 18:40:22 UTC (rev 20618) @@ -65,7 +65,7 @@ rank:int{self==region.rank}, /** - * Is this array defined over a rectangular region? + * Is this array defined over a rectangular region? */ rect:boolean{self==region.rect}, @@ -141,7 +141,15 @@ /** * Construct an Array over the region reg whose * values are initialized as specified by the init function. + * The function will be evaluated exactly once for each point + * in reg in an arbitrary order to + * compute the initial value for each array element.</p> * + * It is unspecified whether the function evaluations will + * be done sequentially for each point by the current activity + * or concurrently for disjoint sets of points by one or more + * child activities. + * * @param reg The region over which to construct the array. * @param init The function to use to initialize the array. */ @@ -231,7 +239,16 @@ /** * Construct Array over the region 0..(size-1) whose * values are initialized as specified by the init function. + * The function will be evaluated exactly once for each point + * in reg in an arbitrary order to + * compute the initial value for each array element.</p> * + * It is unspecified whether the function evaluations will + * be done sequentially for each point by the current activity + * or concurrently for disjoint sets of points by one or more + * child activities. + * + * * @param reg The region over which to construct the array. * @param init The function to use to initialize the array. */ Modified: trunk/x10.runtime/src-x10/x10/array/DistArray.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/DistArray.x10 2011-03-10 18:23:58 UTC (rev 20617) +++ trunk/x10.runtime/src-x10/x10/array/DistArray.x10 2011-03-10 18:40:22 UTC (rev 20618) @@ -115,8 +115,14 @@ /** * Create a distributed array over the argument distribution whose elements * are initialized by executing the given initializer function for each - * element of the array in the place where the argument Point is mapped. - * + * element of the array in the place where the argument Point is mapped. + * The function will be evaluated exactly once for each point + * in dist in an arbitrary order to compute the initial value for each array element.</p> + * + * Within each place, it is unspecified whether the function evaluations will + * be done sequentially by a single activity for each point or concurrently for disjoint sets + * of points by one or more child activities. + * * @param dist the given distribution * @param init the initializer function * @return the newly created DistArray Modified: trunk/x10.runtime/src-x10/x10/array/Region.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/Region.x10 2011-03-10 18:23:58 UTC (rev 20617) +++ trunk/x10.runtime/src-x10/x10/array/Region.x10 2011-03-10 18:40:22 UTC (rev 20618) @@ -31,10 +31,13 @@ rank: int, /** * Is the region rectangular? + * A rectangular region is defined to be region such that every point contained + * in the bounding box of the region is a point in the region. */ rect: boolean, /** * Is the region zero-based? + * A region is zero based if for each dimension the min value is 0. */ zeroBased: boolean, /** @@ -54,14 +57,12 @@ /** * Construct an empty region of the specified rank. */ - public static @TempNoInline_0 def makeEmpty(rank: int): Region(rank){self!=null} = new EmptyRegion(rank); /** * Construct an unbounded region of a given rank that contains all * points of that rank. */ - public static def makeFull(rank: int): Region(rank){self !=null} = new FullRegion(rank); /** @@ -360,8 +361,6 @@ * Returns the projection of a region onto all axes but the * specified axis. */ - - abstract public def eliminate(axis: int): Region /*(rank-1)*/; @@ -372,7 +371,6 @@ * for (p:Point in r) * ... p ... */ - public abstract def iterator(): Iterator[Point(rank)]; Deleted: trunk/x10.tests/examples/Issues/XTENLANG_587.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_587.x10 2011-03-10 18:23:58 UTC (rev 20617) +++ trunk/x10.tests/examples/Issues/XTENLANG_587.x10 2011-03-10 18:40:22 UTC (rev 20618) @@ -1,40 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -/** - * Test that the closures initializing each array element are called - * within separate asyncs. - */ - -public class XTENLANG_587 extends x10Test { - public static def main(Array[String](1)) { - new XTENLANG_587().execute(); - } - public def run() { - class Cell { - var f:Int=1; - } - val cell = new Cell(); - val cell2 = new Cell(); - val x = new Array[Int](0..1, ([i]:Point) => - { - when (cell.f==i) { - cell.f = (i+1)%2; - cell2.f = i; - } - i - } - ); - return cell2.f == 0; - } -} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2011-03-21 18:41:20
|
Revision: 20874 http://x10.svn.sourceforge.net/x10/?rev=20874&view=rev Author: tardieu Date: 2011-03-21 18:41:12 +0000 (Mon, 21 Mar 2011) Log Message: ----------- WS: no need for root frame Modified Paths: -------------- trunk/x10.dist/samples/work-stealing/Fib.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/AsyncFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/RootFinish.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/Worker.x10 Removed Paths: ------------- trunk/x10.runtime/src-x10/x10/compiler/ws/RootFrame.x10 Modified: trunk/x10.dist/samples/work-stealing/Fib.x10 =================================================================== --- trunk/x10.dist/samples/work-stealing/Fib.x10 2011-03-21 18:19:37 UTC (rev 20873) +++ trunk/x10.dist/samples/work-stealing/Fib.x10 2011-03-21 18:41:12 UTC (rev 20874) @@ -18,10 +18,10 @@ val t1:Int; val t2:Int; if (n < 2) return 1; - finish { - async t1 = fib(n-1); - t2 = fib(n-2); - } + {{{{ finish {{{{ + {{{{ async t1 = fib(n-1); }}}} + {{{{ async t2 = fib(n-2); }}}} + }}}} }}}} return t1 + t2; } Modified: trunk/x10.runtime/src-x10/x10/compiler/ws/AsyncFrame.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/ws/AsyncFrame.x10 2011-03-21 18:19:37 UTC (rev 20873) +++ trunk/x10.runtime/src-x10/x10/compiler/ws/AsyncFrame.x10 2011-03-21 18:41:12 UTC (rev 20874) @@ -34,7 +34,6 @@ } } worker.unroll(ff); - throw Abort.ABORT; } return; } Modified: trunk/x10.runtime/src-x10/x10/compiler/ws/RootFinish.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/ws/RootFinish.x10 2011-03-21 18:19:37 UTC (rev 20873) +++ trunk/x10.runtime/src-x10/x10/compiler/ws/RootFinish.x10 2011-03-21 18:41:12 UTC (rev 20874) @@ -1,10 +1,10 @@ package x10.compiler.ws; -import x10.util.Stack; +import x10.compiler.Abort; public final class RootFinish extends FinishFrame { public def this() { - super(new RootFrame()); + super(NULL[Frame]()); asyncs = 1; } @@ -14,4 +14,10 @@ } public def remap():FinishFrame = this; + + public def wrapResume(worker:Worker) { + super.wrapResume(worker); + Worker.allStop(worker); + throw Abort.ABORT; + } } \ No newline at end of file Deleted: trunk/x10.runtime/src-x10/x10/compiler/ws/RootFrame.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/ws/RootFrame.x10 2011-03-21 18:19:37 UTC (rev 20873) +++ trunk/x10.runtime/src-x10/x10/compiler/ws/RootFrame.x10 2011-03-21 18:41:12 UTC (rev 20874) @@ -1,15 +0,0 @@ -package x10.compiler.ws; - -import x10.compiler.Header; - -public final class RootFrame extends Frame { - @Header public def this() { - super(NULL[Frame]()); - } - - public def remap():Frame = this; - - public def wrapResume(worker:Worker) { - Worker.allStop(worker); - } -} \ No newline at end of file Modified: trunk/x10.runtime/src-x10/x10/compiler/ws/Worker.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/ws/Worker.x10 2011-03-21 18:19:37 UTC (rev 20873) +++ trunk/x10.runtime/src-x10/x10/compiler/ws/Worker.x10 2011-03-21 18:41:12 UTC (rev 20874) @@ -153,7 +153,6 @@ while (true) { frame.wrapResume(this); up = frame.up; - if (Frame.isNULL(up)) return; up.wrapBack(this, frame); if (!(frame instanceof MainFrame) && !(frame instanceof RootFinish)) { Runtime.deallocObject(frame); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2011-04-01 16:36:23
|
Revision: 21102 http://x10.svn.sourceforge.net/x10/?rev=21102&view=rev Author: yzibin Date: 2011-04-01 16:36:16 +0000 (Fri, 01 Apr 2011) Log Message: ----------- * added test cases * for LangSpec, if there is a single ERR marker then it can match multiple errors. Modified Paths: -------------- trunk/x10.compiler/src/x10/util/RunTestSuite.java trunk/x10.tests/examples/Misc/x10/frontend/tests/FrontEndTests_MustFailCompile.x10 Modified: trunk/x10.compiler/src/x10/util/RunTestSuite.java =================================================================== --- trunk/x10.compiler/src/x10/util/RunTestSuite.java 2011-04-01 16:35:18 UTC (rev 21101) +++ trunk/x10.compiler/src/x10/util/RunTestSuite.java 2011-04-01 16:36:16 UTC (rev 21102) @@ -151,6 +151,7 @@ public static boolean QUIET = !SHOW_EXPECTED_ERRORS && getBoolProp("QUIET"); public static String SOURCE_PATH_SEP = File.pathSeparator; // on MAC the separator is ":" and on windows it is ";" + public static String LANGSPEC = "LangSpec"; // in LangSpec directory we ignore multiple errors on the same line (so one ERR marker matches any number of errors) private static void println(String s) { if (!QUIET) { @@ -501,6 +502,9 @@ if (expectedErrCount!=foundErrCount && // we try to have at most 1 or 2 errors in a line. (expectedErrCount<3 || foundErrCount<3)) { // if the compiler reports more than 3 errors, and we marked more than 3, then it's too many errors on one line and it marks the fact the compiler went crazy and issues too many wrong errors. + if (foundErrCount>1 && expectedErrCount==1 && summary.fileName.contains(LANGSPEC)) { + // nothing to do - a single ERR marker in LangSpec match multiple errors + } else err("File "+file+" has "+expectedErrCount+" ERR markers on line "+lineNum+", but the compiler reported "+ foundErrCount+" errors on that line! errorsFound=\n"+errorsFound); } } Modified: trunk/x10.tests/examples/Misc/x10/frontend/tests/FrontEndTests_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Misc/x10/frontend/tests/FrontEndTests_MustFailCompile.x10 2011-04-01 16:35:18 UTC (rev 21101) +++ trunk/x10.tests/examples/Misc/x10/frontend/tests/FrontEndTests_MustFailCompile.x10 2011-04-01 16:36:16 UTC (rev 21102) @@ -6231,3 +6231,6 @@ } } +struct XTENLANG_2022(B:Region,NBRS: Array[Point(B.rank)](1)) {} + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2011-04-27 18:25:00
|
Revision: 21463 http://x10.svn.sourceforge.net/x10/?rev=21463&view=rev Author: ipeshansky Date: 2011-04-27 18:24:53 +0000 (Wed, 27 Apr 2011) Log Message: ----------- Fix some assertion failures when compiling CUDAKernelTest with the C++ backend. Modified Paths: -------------- trunk/x10.compiler/src/polyglot/types/TypeSystem_c.java trunk/x10.compiler/src/x10/ast/Closure_c.java trunk/x10.compiler/src/x10cuda/types/SharedMem.java trunk/x10.dist/samples/CUDA/CUDAKernelTest.x10 trunk/x10.runtime/src-x10/x10/array/RemoteArray.x10 Modified: trunk/x10.compiler/src/polyglot/types/TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/types/TypeSystem_c.java 2011-04-27 17:47:41 UTC (rev 21462) +++ trunk/x10.compiler/src/polyglot/types/TypeSystem_c.java 2011-04-27 18:24:53 UTC (rev 21463) @@ -793,6 +793,12 @@ private boolean emptyContextSubtype(Type t, X10ClassType xlass) { return isSubtype(t, xlass, EMPTY_CONTEXT); } + /** + * A shortcut version of the subtype test -- only works if xclass cannot be subclassed. + * @param t the type to test + * @param xlass the potential supertype + * @return true if t is a subtype of xclass, and false otherwise + */ private boolean finalSubtype(Type t, X10ClassType xlass) { assert xlass.flags().isStruct() || xlass.flags().isFinal(); return hasSameClassDef(t,xlass) || isUnknown(t); Modified: trunk/x10.compiler/src/x10/ast/Closure_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Closure_c.java 2011-04-27 17:47:41 UTC (rev 21462) +++ trunk/x10.compiler/src/x10/ast/Closure_c.java 2011-04-27 18:24:53 UTC (rev 21463) @@ -338,7 +338,7 @@ @Override public Context enterChildScope(Node child, Context c) { // We should have entered the method scope already. - if ( c.currentCode() != this.closureDef()) + if (c.currentCode() != this.closureDef()) assert c.currentCode() == this.closureDef(); if (child != body()) { Modified: trunk/x10.compiler/src/x10cuda/types/SharedMem.java =================================================================== --- trunk/x10.compiler/src/x10cuda/types/SharedMem.java 2011-04-27 17:47:41 UTC (rev 21462) +++ trunk/x10.compiler/src/x10cuda/types/SharedMem.java 2011-04-27 18:24:53 UTC (rev 21463) @@ -154,7 +154,7 @@ @Override public void visitChildren(Node parent, NodeVisitor v) { numElements = (Expr) parent.visitChild(numElements, v); - if (init!=null) init = (Expr) init.visitChildren(v); + if (init!=null) init = (Expr) parent.visitChild(init, v); } } private static class Var extends Decl { Modified: trunk/x10.dist/samples/CUDA/CUDAKernelTest.x10 =================================================================== --- trunk/x10.dist/samples/CUDA/CUDAKernelTest.x10 2011-04-27 17:47:41 UTC (rev 21462) +++ trunk/x10.dist/samples/CUDA/CUDAKernelTest.x10 2011-04-27 18:24:53 UTC (rev 21463) @@ -1,4 +1,3 @@ - /* * This file is part of the X10 project (http://x10-lang.org). * Modified: trunk/x10.runtime/src-x10/x10/array/RemoteArray.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/array/RemoteArray.x10 2011-04-27 17:47:41 UTC (rev 21462) +++ trunk/x10.runtime/src-x10/x10/array/RemoteArray.x10 2011-04-27 18:24:53 UTC (rev 21463) @@ -30,7 +30,7 @@ * at (rawData.home()) { (this.rawData)() == (this.array)().raw() } * </pre> */ -public class RemoteArray[T]( +public final class RemoteArray[T]( /** * The Region of the remote array */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2011-05-06 23:03:28
|
Revision: 21621 http://x10.svn.sourceforge.net/x10/?rev=21621&view=rev Author: yzibin Date: 2011-05-06 23:03:22 +0000 (Fri, 06 May 2011) Log Message: ----------- Fixed regression for XTENLANG_2330 (in expanding property methods) Modified Paths: -------------- trunk/x10.compiler/src/x10/types/ConstrainedType.java trunk/x10.compiler/src/x10/types/XTypeTranslator.java trunk/x10.tests/examples/Issues/XTENLANG_2638.x10 Modified: trunk/x10.compiler/src/x10/types/ConstrainedType.java =================================================================== --- trunk/x10.compiler/src/x10/types/ConstrainedType.java 2011-05-06 20:25:43 UTC (rev 21620) +++ trunk/x10.compiler/src/x10/types/ConstrainedType.java 2011-05-06 23:03:22 UTC (rev 21621) @@ -511,13 +511,15 @@ MethodInstance mi = Types.getPropertyMethod(this, name); if (mi != null) { val = translator.translate(var, mi); - // expand it in order to handle Dist.rank() - val = XTypeTranslator.expandSelfPropertyMethod(val); } } } } } + if (val!=null) { + // expand it in order to handle Dist.rank() + val = XTypeTranslator.expandSelfPropertyMethod(val); + } return val; // todo: val can be null! if we build a synthetic term, then why not always build it??? } Modified: trunk/x10.compiler/src/x10/types/XTypeTranslator.java =================================================================== --- trunk/x10.compiler/src/x10/types/XTypeTranslator.java 2011-05-06 20:25:43 UTC (rev 21620) +++ trunk/x10.compiler/src/x10/types/XTypeTranslator.java 2011-05-06 23:03:22 UTC (rev 21621) @@ -63,6 +63,7 @@ import x10.constraint.XTerm; import x10.constraint.XTerms; import x10.constraint.XVar; +import x10.constraint.XField; import x10.errors.Errors; import x10.errors.Errors.IllegalConstraint; import x10.types.checker.PlaceChecker; @@ -258,10 +259,13 @@ aDef = cAtom.def(); args = cAtom.arguments(); } - if (term instanceof CField) { - CField cField = (CField) term; - aDef = cField.field(); - args = Collections.<XTerm>singletonList(cField.receiver); + if (term instanceof XField) { + XField cField = (XField) term; + Object o = cField.field(); + if (o instanceof Def) { + aDef = (Def) o; + args = Collections.<XTerm>singletonList(cField.receiver); + } } if (aDef==null || !(aDef instanceof X10MethodDef)) return term; XTerm receiver = args.get(0); Modified: trunk/x10.tests/examples/Issues/XTENLANG_2638.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_2638.x10 2011-05-06 20:25:43 UTC (rev 21620) +++ trunk/x10.tests/examples/Issues/XTENLANG_2638.x10 2011-05-06 23:03:22 UTC (rev 21621) @@ -27,7 +27,7 @@ { at (place) { - for (pt:Point in mat | here)//(mat.dist | here)) + for (pt in mat | here)//(mat.dist | here)) { val x = mat(pt); val y = rhs(pt); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2011-05-10 00:00:12
|
Revision: 21629 http://x10.svn.sourceforge.net/x10/?rev=21629&view=rev Author: ipeshansky Date: 2011-05-09 23:59:58 +0000 (Mon, 09 May 2011) Log Message: ----------- Fix XTENLANG-2684: Remove thrown SemanticExceptions from disambiguate() methods in FunctionTypeNode_c and AmbPrefix_c. X10TypeChecker.leaveCall() no longer throws SemanticExceptions. Change signature of Node.disambiguate() to not throw SemanticException. Cleanup: merge X10ParsedName into ParsedName. Cleanup: remove ParsedName.toQualifier(). Cleanup: remove AmbQualifierNode and subclasses. Change signature of ConstantPropagator.HideControlFlow.leaveCall() to not throw SemanticException. Cleanup: remove dead AscriptionVisitor and Node.childExpectedType(). Add TypeSystem.FailedDynamicCheckException(). Cleanup: remove NodeFactory.TypeNodeFromQualifiedName() and create CanonicalTypeNodes with the appropriate types instead. This fixes XTENLANG-2266. Update test case. Cleanup: change signature of Node_c.copy() to not throw SemanticException. Modified Paths: -------------- trunk/x10.compiler/src/polyglot/ast/AbstractDelFactory_c.java trunk/x10.compiler/src/polyglot/ast/AbstractExtFactory_c.java trunk/x10.compiler/src/polyglot/ast/AbstractNodeFactory_c.java trunk/x10.compiler/src/polyglot/ast/AmbPrefix_c.java trunk/x10.compiler/src/polyglot/ast/AmbReceiver_c.java trunk/x10.compiler/src/polyglot/ast/ArrayAccess_c.java trunk/x10.compiler/src/polyglot/ast/ArrayInit_c.java trunk/x10.compiler/src/polyglot/ast/Assert_c.java trunk/x10.compiler/src/polyglot/ast/Assign_c.java trunk/x10.compiler/src/polyglot/ast/Call_c.java trunk/x10.compiler/src/polyglot/ast/Case_c.java trunk/x10.compiler/src/polyglot/ast/Conditional_c.java trunk/x10.compiler/src/polyglot/ast/ConstructorCall_c.java trunk/x10.compiler/src/polyglot/ast/DelFactory.java trunk/x10.compiler/src/polyglot/ast/Do_c.java trunk/x10.compiler/src/polyglot/ast/Eval_c.java trunk/x10.compiler/src/polyglot/ast/ExtFactory.java trunk/x10.compiler/src/polyglot/ast/FieldDecl_c.java trunk/x10.compiler/src/polyglot/ast/Field_c.java trunk/x10.compiler/src/polyglot/ast/For_c.java trunk/x10.compiler/src/polyglot/ast/If_c.java trunk/x10.compiler/src/polyglot/ast/Instanceof_c.java trunk/x10.compiler/src/polyglot/ast/JL_c.java trunk/x10.compiler/src/polyglot/ast/LocalDecl_c.java trunk/x10.compiler/src/polyglot/ast/NewArray_c.java trunk/x10.compiler/src/polyglot/ast/New_c.java trunk/x10.compiler/src/polyglot/ast/Node.java trunk/x10.compiler/src/polyglot/ast/NodeFactory.java trunk/x10.compiler/src/polyglot/ast/NodeOps.java trunk/x10.compiler/src/polyglot/ast/Node_c.java trunk/x10.compiler/src/polyglot/ast/Return_c.java trunk/x10.compiler/src/polyglot/ast/Switch_c.java trunk/x10.compiler/src/polyglot/ast/Synchronized_c.java trunk/x10.compiler/src/polyglot/ast/Throw_c.java trunk/x10.compiler/src/polyglot/ast/Unary_c.java trunk/x10.compiler/src/polyglot/ast/While_c.java trunk/x10.compiler/src/polyglot/parse/ParsedName.java trunk/x10.compiler/src/polyglot/types/TypeSystem.java trunk/x10.compiler/src/polyglot/types/TypeSystem_c.java trunk/x10.compiler/src/polyglot/visit/TypeChecker.java trunk/x10.compiler/src/x10/ast/Async_c.java trunk/x10.compiler/src/x10/ast/AtExpr_c.java trunk/x10.compiler/src/x10/ast/AtHomeExpr_c.java trunk/x10.compiler/src/x10/ast/AtHomeStmt_c.java trunk/x10.compiler/src/x10/ast/AtStmt_c.java trunk/x10.compiler/src/x10/ast/Atomic_c.java trunk/x10.compiler/src/x10/ast/ClosureCall_c.java trunk/x10.compiler/src/x10/ast/FinishExpr_c.java trunk/x10.compiler/src/x10/ast/FunctionTypeNode_c.java trunk/x10.compiler/src/x10/ast/HasTypeNode_c.java trunk/x10.compiler/src/x10/ast/SettableAssign_c.java trunk/x10.compiler/src/x10/ast/Tuple_c.java trunk/x10.compiler/src/x10/ast/X10Binary_c.java trunk/x10.compiler/src/x10/ast/X10Call_c.java trunk/x10.compiler/src/x10/ast/X10Cast_c.java trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java trunk/x10.compiler/src/x10/ast/X10LocalDecl_c.java trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java trunk/x10.compiler/src/x10/emitter/TryCatchExpander.java trunk/x10.compiler/src/x10/parser/X10SemanticRules.java trunk/x10.compiler/src/x10/util/Struct.java trunk/x10.compiler/src/x10/util/Synthesizer.java trunk/x10.compiler/src/x10/visit/ConstantPropagator.java trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.compiler/src/x10/visit/X10DelegatingVisitor.java trunk/x10.compiler/src/x10/visit/X10TypeChecker.java trunk/x10.tests/examples/Constructs/Structs/StructObscuringExample.x10 Removed Paths: ------------- trunk/x10.compiler/src/polyglot/ast/AmbQualifierNode.java trunk/x10.compiler/src/polyglot/ast/AmbQualifierNode_c.java trunk/x10.compiler/src/polyglot/visit/AscriptionVisitor.java trunk/x10.compiler/src/x10/ast/X10AmbQualifierNode.java trunk/x10.compiler/src/x10/ast/X10AmbQualifierNode_c.java trunk/x10.compiler/src/x10/parser/X10ParsedName.java Modified: trunk/x10.compiler/src/polyglot/ast/AbstractDelFactory_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/AbstractDelFactory_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/AbstractDelFactory_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -125,16 +125,6 @@ return postDelAmbPrefix(e); } - public final JL delAmbQualifierNode() { - JL e = delAmbQualifierNodeImpl(); - - if (nextDelFactory != null) { - JL e2 = nextDelFactory.delAmbQualifierNode(); - e = composeDels(e, e2); - } - return postDelAmbQualifierNode(e); - } - public final JL delAmbReceiver() { JL e = delAmbReceiverImpl(); @@ -920,14 +910,6 @@ } /** - * Create the delegate for a <code>AmbQualifierNode</code> AST node. - * @return the delegate for a <code>AmbQualifierNode</code> AST node. - */ - protected JL delAmbQualifierNodeImpl() { - return delNodeImpl(); - } - - /** * Create the delegate for a <code>AmbReceiver</code> AST node. * @return the delegate for a <code>AmbReceiver</code> AST node. */ @@ -1538,10 +1520,6 @@ return postDelNode(del); } - protected JL postDelAmbQualifierNode(JL del) { - return postDelNode(del); - } - protected JL postDelAmbReceiver(JL del) { return postDelNode(del); } Modified: trunk/x10.compiler/src/polyglot/ast/AbstractExtFactory_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/AbstractExtFactory_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/AbstractExtFactory_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -122,16 +122,6 @@ return postExtAmbPrefix(e); } - public final Ext extAmbQualifierNode() { - Ext e = extAmbQualifierNodeImpl(); - - if (nextExtFactory != null) { - Ext e2 = nextExtFactory.extAmbQualifierNode(); - e = composeExts(e, e2); - } - return postExtAmbQualifierNode(e); - } - public final Ext extAmbReceiver() { Ext e = extAmbReceiverImpl(); @@ -917,14 +907,6 @@ } /** - * Create the <code>Ext</code> object for a <code>AmbQualifierNode</code> AST node. - * @return the <code>Ext</code> object for a <code>AmbQualifierNode</code> AST node. - */ - protected Ext extAmbQualifierNodeImpl() { - return extNodeImpl(); - } - - /** * Create the <code>Ext</code> object for a <code>AmbReceiver</code> AST node. * @return the <code>Ext</code> object for a <code>AmbReceiver</code> AST node. */ @@ -1542,10 +1524,6 @@ return postExtNode(ext); } - protected Ext postExtAmbQualifierNode(Ext ext) { - return postExtNode(ext); - } - protected Ext postExtAmbReceiver(Ext ext) { return postExtNode(ext); } Modified: trunk/x10.compiler/src/polyglot/ast/AbstractNodeFactory_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/AbstractNodeFactory_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/AbstractNodeFactory_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -36,15 +36,6 @@ return AmbPrefix(pos, PrefixFromQualifiedName(pos2, qualifiedName.qualifier()), Id(pos, qualifiedName.name())); } - public TypeNode TypeNodeFromQualifiedName(Position pos, QName qualifiedName) { - if (qualifiedName.qualifier() == null) - return AmbTypeNode(pos, null, Id(pos, qualifiedName.name())); - - Position pos2 = pos.truncateEnd(qualifiedName.name().toString().length()+1); - - return AmbTypeNode(pos, QualifierNodeFromQualifiedName(pos2, qualifiedName.qualifier()), Id(pos, qualifiedName.name())); - } - public Receiver ReceiverFromQualifiedName(Position pos, QName qualifiedName) { if (qualifiedName.qualifier() == null) return AmbReceiver(pos, null, Id(pos, qualifiedName.name())); @@ -64,15 +55,6 @@ return Field(pos, ReceiverFromQualifiedName(pos2, qualifiedName.qualifier()), Id(pos, qualifiedName.name())); } - public QualifierNode QualifierNodeFromQualifiedName(Position pos, QName qualifiedName) { - if (qualifiedName.qualifier() == null) - return AmbQualifierNode(pos, null, Id(pos, qualifiedName.name())); - - Position pos2 = pos.truncateEnd(qualifiedName.name().toString().length()+1); - - return AmbQualifierNode(pos, QualifierNodeFromQualifiedName(pos2, qualifiedName.qualifier()), Id(pos, qualifiedName.name())); - } - public CanonicalTypeNode CanonicalTypeNode(Position pos, Type type) { return CanonicalTypeNode(pos, Types.<Type>ref(type)); } @@ -85,10 +67,6 @@ return AmbReceiver(pos, null, name); } - public final AmbQualifierNode AmbQualifierNode(Position pos, Id name) { - return AmbQualifierNode(pos, null, name); - } - public final AmbTypeNode AmbTypeNode(Position pos, Id name) { return AmbTypeNode(pos, null, name); } Modified: trunk/x10.compiler/src/polyglot/ast/AmbPrefix_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/AmbPrefix_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/AmbPrefix_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -8,9 +8,13 @@ package polyglot.ast; +import polyglot.types.QName; import polyglot.types.SemanticException; +import polyglot.types.TypeSystem; import polyglot.util.*; import polyglot.visit.*; +import x10.errors.Errors; +import x10.types.X10ClassType; /** * An <code>AmbPrefix</code> is an ambiguous AST node composed of dot-separated @@ -71,8 +75,20 @@ return reconstruct(prefix, name); } + @Override + public Node disambiguate(ContextVisitor ar) { + try { + return superDisambiguate(ar); + } catch (SemanticException e) { + Errors.issue(ar.job(), e, this); + TypeSystem xts = ar.typeSystem(); + X10ClassType ct = xts.createFakeClass(QName.make(null, name.id()), e); + return ar.nodeFactory().CanonicalTypeNode(position(), ct); + } + } + /** Disambiguate the prefix. */ - public Node disambiguate(ContextVisitor ar) throws SemanticException { + public Node superDisambiguate(ContextVisitor ar) throws SemanticException { Position pos = position(); Disamb disamb = ar.nodeFactory().disamb(); Node n = disamb.disambiguate(this, ar, pos, prefix, name); Deleted: trunk/x10.compiler/src/polyglot/ast/AmbQualifierNode.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/AmbQualifierNode.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/AmbQualifierNode.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -1,25 +0,0 @@ -/* - * This file is part of the Polyglot extensible compiler framework. - * - * Copyright (c) 2000-2006 Polyglot project group, Cornell University - * - */ - -package polyglot.ast; - -/** - * An <code>AmbQualifierNode</code> is an ambiguous AST node composed of - * dot-separated list of identifiers that must resolve to a type qualifier. - */ -public interface AmbQualifierNode extends Ambiguous, QualifierNode -{ - /** - * Qualifier of the qualifier. - */ - Prefix prefix(); - - /** - * Ambiguous name. - */ - Id name(); -} Deleted: trunk/x10.compiler/src/polyglot/ast/AmbQualifierNode_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/AmbQualifierNode_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/AmbQualifierNode_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -1,139 +0,0 @@ -/* - * This file is part of the Polyglot extensible compiler framework. - * - * Copyright (c) 2000-2007 Polyglot project group, Cornell University - * Copyright (c) 2006-2007 IBM Corporation - * - */ - -package polyglot.ast; - - -import polyglot.frontend.*; -import polyglot.types.*; -import polyglot.util.*; -import polyglot.visit.*; -import x10.visit.X10TypeChecker; - -/** - * An <code>AmbQualifierNode</code> is an ambiguous AST node composed of - * dot-separated list of identifiers that must resolve to a type qualifier. - */ -public class AmbQualifierNode_c extends Node_c implements AmbQualifierNode -{ - protected LazyRef<Qualifier> qualifier; - protected Prefix qual; - protected Id name; - - public AmbQualifierNode_c(Position pos, Prefix qual, Id name) { - super(pos); - assert(name != null); // qual may be null - - this.qual = qual; - this.name = name; - } - - public LazyRef<? extends Qualifier> qualifierRef() { - return this.qualifier; - } - - public Id name() { - return this.name; - } - - public AmbQualifierNode name(Id name) { - AmbQualifierNode_c n = (AmbQualifierNode_c) copy(); - n.name = name; - return n; - } - - public Prefix prefix() { - return this.qual; - } - - protected AmbQualifierNode qual(Prefix qual) { - AmbQualifierNode_c n = (AmbQualifierNode_c) copy(); - n.qual = qual; - return n; - } - - protected AmbQualifierNode qualifierRef(LazyRef<Qualifier> qualifier) { - AmbQualifierNode_c n = (AmbQualifierNode_c) copy(); - n.qualifier = qualifier; - return n; - } - - protected AmbQualifierNode_c reconstruct(Prefix qual, Id name) { - if (qual != this.qual || name != this.name) { - AmbQualifierNode_c n = (AmbQualifierNode_c) copy(); - n.qual = qual; - n.name = name; - return n; - } - - return this; - } - - public Node visitChildren(NodeVisitor v) { - Id name = (Id) visitChild(this.name, v); - Prefix qual = (Prefix) visitChild(this.qual, v); - return reconstruct(qual, name); - } - - public Node buildTypes(TypeBuilder tb) { - TypeSystem ts = tb.typeSystem(); - LazyRef<Qualifier> sym = Types.<Qualifier>lazyRef(ts.unknownQualifier(position()), new SetResolverGoal(tb.job()).intern(tb.job().extensionInfo().scheduler())); - return qualifierRef(sym); - } - - public Qualifier qualifier() { - return qualifierRef().get(); - } - - public Node disambiguate(ContextVisitor ar) throws SemanticException { - SemanticException ex; - - try { - Node n = ar.nodeFactory().disamb().disambiguate(this, ar, position(), qual, name); - - if (n instanceof QualifierNode) { - QualifierNode qn = (QualifierNode) n; - Qualifier q = qn.qualifierRef().get(); - qualifier.update(q); - return n; - } - - ex = new SemanticException("Could not find type or package \"" + (qual == null ? name.toString() : qual.toString() + "." + name.toString()) + "\".", position()); - } - catch (SemanticException e) { - ex = e; - } - - // Mark the type as an error, so we don't try looking it up again. - LazyRef<Qualifier> sym = (LazyRef<Qualifier>) qualifier; - sym.update(ar.typeSystem().unknownQualifier(position())); - - throw ex; - } - - public Node exceptionCheck(ExceptionChecker ec) { - throw new InternalCompilerError(position(), - "Cannot exception check ambiguous node " + this + "."); - } - - public void prettyPrint(CodeWriter w, PrettyPrinter tr) { - if (qual != null) { - print(qual, w, tr); - w.write("."); - w.allowBreak(2, 3, "", 0); - } - - tr.print(this, name, w); - } - - public String toString() { - return (qual == null - ? name.toString() - : qual.toString() + "." + name.toString()) + "{amb}"; - } -} Modified: trunk/x10.compiler/src/polyglot/ast/AmbReceiver_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/AmbReceiver_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/AmbReceiver_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -45,14 +45,14 @@ /** Disambiguate the receiver. */ public Node disambiguate(ContextVisitor ar) { - try { +// try { return super.disambiguate(ar); - } catch (SemanticException e) { - Errors.issue(ar.job(), e, this); - TypeSystem xts = ar.typeSystem(); - X10LocalInstance li = xts.createFakeLocal(name.id(), e); - return ar.nodeFactory().Local(position(), name).localInstance(li).type(li.type()); - } +// } catch (SemanticException e) { +// Errors.issue(ar.job(), e, this); +// TypeSystem xts = ar.typeSystem(); +// X10LocalInstance li = xts.createFakeLocal(name.id(), e); +// return ar.nodeFactory().Local(position(), name).localInstance(li).type(li.type()); +// } } Modified: trunk/x10.compiler/src/polyglot/ast/ArrayAccess_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/ArrayAccess_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/ArrayAccess_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -104,20 +104,6 @@ return type(arrayType.toArray().base()); } - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = av.typeSystem(); - - if (child == index) { - return ts.Int(); - } - - if (child == array) { - return ts.arrayOf(this.type); - } - - return child.type(); - } - public String toString() { return array + "[" + index + "]"; } Modified: trunk/x10.compiler/src/polyglot/ast/ArrayInit_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/ArrayInit_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/ArrayInit_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -88,36 +88,6 @@ } } - public Type childExpectedType(Expr child, AscriptionVisitor av) { - if (elements.isEmpty()) { - return child.type(); - } - - Type t = av.toType(); - - if (! t.isArray()) { - throw new InternalCompilerError("Type of array initializer must " + - "be an array.", position()); - } - - t = t.toArray().base(); - - TypeSystem ts = av.typeSystem(); - - for (Expr e : elements) { - if (e == child) { - if (ts.numericConversionValid(t, e.constantValue(), av.context())) { - return child.type(); - } - else { - return t; - } - } - } - - return child.type(); - } - public void typeCheckElements(ContextVisitor tc, Type lhsType) { TypeSystem ts = tc.typeSystem(); Modified: trunk/x10.compiler/src/polyglot/ast/Assert_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Assert_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Assert_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -83,22 +83,6 @@ return this; } - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = av.typeSystem(); - - if (child == cond) { - return ts.Boolean(); - } - - /* - if (child == errorMessage) { - return ts.String(); - } - */ - - return child.type(); - } - /** Visit the children of the statement. */ public Node visitChildren(NodeVisitor v) { Expr cond = (Expr) visitChild(this.cond, v); Modified: trunk/x10.compiler/src/polyglot/ast/Assign_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Assign_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Assign_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -81,23 +81,6 @@ /** Type check the expression. */ public abstract Node typeCheck(ContextVisitor tc); - public Type childExpectedType(Expr child, AscriptionVisitor av) { - if (child == right) { - TypeSystem ts = av.typeSystem(); - - // If the RHS is an integral constant, we can relax the expected - // type to the type of the constant. - if (ts.numericConversionValid(leftType(), child.constantValue(), av.context())) { - return child.type(); - } - else { - return leftType(); - } - } - - return child.type(); - } - /** Get the throwsArithmeticException of the expression. */ public boolean throwsArithmeticException() { // conservatively assume that any division or mod may throw Modified: trunk/x10.compiler/src/polyglot/ast/Call_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Call_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Call_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -25,7 +25,6 @@ import polyglot.util.InternalCompilerError; import polyglot.util.Position; import polyglot.util.TypedList; -import polyglot.visit.AscriptionVisitor; import polyglot.visit.CFGBuilder; import polyglot.visit.ContextVisitor; import polyglot.visit.ExceptionChecker; Modified: trunk/x10.compiler/src/polyglot/ast/Case_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Case_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Case_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -122,16 +122,6 @@ return this; } - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = av.typeSystem(); - - if (child == expr) { - return ts.Int(); - } - - return child.type(); - } - public String toString() { if (expr == null) { return "default:"; Modified: trunk/x10.compiler/src/polyglot/ast/Conditional_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Conditional_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Conditional_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -98,20 +98,6 @@ /** Type check the expression. */ public abstract Node typeCheck(ContextVisitor tc); - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = av.typeSystem(); - - if (child == cond) { - return ts.Boolean(); - } - - if (child == consequent || child == alternative) { - return type(); - } - - return child.type(); - } - public String toString() { return cond + " ? " + consequent + " : " + alternative; } Modified: trunk/x10.compiler/src/polyglot/ast/ConstructorCall_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/ConstructorCall_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/ConstructorCall_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -112,29 +112,6 @@ /** Type check the call. */ public abstract Node typeCheck(ContextVisitor tc); - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = av.typeSystem(); - - if (child == qualifier) { - // FIXME: Can be more specific - return ts.Object(); - } - - Iterator<Expr> i = this.arguments.iterator(); - Iterator<Type> j = ci.formalTypes().iterator(); - - while (i.hasNext() && j.hasNext()) { - Expr e = i.next(); - Type t = j.next(); - - if (e == child) { - return t; - } - } - - return child.type(); - } - public abstract String toString(); /** Write the call to an output file. */ Modified: trunk/x10.compiler/src/polyglot/ast/DelFactory.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/DelFactory.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/DelFactory.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -28,8 +28,6 @@ JL delAmbPrefix(); - JL delAmbQualifierNode(); - JL delAmbReceiver(); JL delAmbTypeNode(); Modified: trunk/x10.compiler/src/polyglot/ast/Do_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Do_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Do_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -79,16 +79,6 @@ /** Type check the statement. */ public abstract Node typeCheck(ContextVisitor tc); - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = av.typeSystem(); - - if (child == cond) { - return ts.Boolean(); - } - - return child.type(); - } - public String toString() { return "do " + body + " while (" + cond + ")"; } Modified: trunk/x10.compiler/src/polyglot/ast/Eval_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Eval_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Eval_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -53,16 +53,6 @@ return this; } - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = av.typeSystem(); - - if (child == expr) { - return ts.Void(); - } - - return child.type(); - } - /** Visit the children of the statement. */ public Node visitChildren(NodeVisitor v) { Expr expr = (Expr) visitChild(this.expr, v); Modified: trunk/x10.compiler/src/polyglot/ast/ExtFactory.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/ExtFactory.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/ExtFactory.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -35,8 +35,6 @@ Ext extAmbPrefix(); - Ext extAmbQualifierNode(); - Ext extAmbReceiver(); Ext extAmbTypeNode(); Modified: trunk/x10.compiler/src/polyglot/ast/FieldDecl_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/FieldDecl_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/FieldDecl_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -305,8 +305,6 @@ return ec.push(new ExceptionChecker.CodeTypeReporter("A field initializer")); } - public abstract Type childExpectedType(Expr child, AscriptionVisitor av); - public Term firstChild() { return type; } Modified: trunk/x10.compiler/src/polyglot/ast/Field_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Field_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Field_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -142,15 +142,6 @@ return this; } - public Type childExpectedType(Expr child, AscriptionVisitor av) - { - if (child == target) { - return fi.container(); - } - - return child.type(); - } - /** Write the field to an output file. */ public void prettyPrint(CodeWriter w, PrettyPrinter tr) { w.begin(0); Modified: trunk/x10.compiler/src/polyglot/ast/For_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/For_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/For_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -147,16 +147,6 @@ return this; } - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = av.typeSystem(); - - if (child == cond) { - return ts.Boolean(); - } - - return child.type(); - } - /** Write the statement to an output file. */ public void prettyPrint(CodeWriter w, PrettyPrinter tr) { w.write("for ("); Modified: trunk/x10.compiler/src/polyglot/ast/If_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/If_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/If_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -98,16 +98,6 @@ /** Type check the statement. */ public abstract Node typeCheck(ContextVisitor tc); - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = av.typeSystem(); - - if (child == cond) { - return ts.Boolean(); - } - - return child.type(); - } - public String toString() { return "if (" + cond + ") " + consequent + (alternative != null ? " else " + alternative : ""); Modified: trunk/x10.compiler/src/polyglot/ast/Instanceof_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Instanceof_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Instanceof_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -82,16 +82,6 @@ /** Type check the expression. */ public abstract Node typeCheck(ContextVisitor tc); - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = av.typeSystem(); - - if (child == expr) { - return ts.Object(); - } - - return child.type(); - } - public String toString() { return expr + " instanceof " + compareType; } Modified: trunk/x10.compiler/src/polyglot/ast/JL_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/JL_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/JL_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -133,7 +133,7 @@ * * @param ar The visitor which disambiguates. */ - public Node disambiguate(ContextVisitor ar) throws SemanticException { + public Node disambiguate(ContextVisitor ar) { return jl().disambiguate(ar); } Modified: trunk/x10.compiler/src/polyglot/ast/LocalDecl_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/LocalDecl_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/LocalDecl_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -198,8 +198,6 @@ return this; } - public abstract Type childExpectedType(Expr child, AscriptionVisitor av); - public abstract String toString(); public abstract void prettyPrint(CodeWriter w, PrettyPrinter tr); Modified: trunk/x10.compiler/src/polyglot/ast/NewArray_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/NewArray_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/NewArray_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -139,14 +139,6 @@ return type(type); } - public Type childExpectedType(Expr child, AscriptionVisitor av) { - if (child == init) { - return this.type(); - } - - return child.type(); - } - public String toString() { return "new " + baseType + "[...]"; } Modified: trunk/x10.compiler/src/polyglot/ast/New_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/New_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/New_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -319,35 +319,6 @@ return this; } - public Type childExpectedType(Expr child, AscriptionVisitor av) { - if (child == qualifier) { - ContainerType t = ci.container(); - - if (t.isClass() && t.toClass().isMember()) { - t = t.toClass().container(); - return t; - } - - return child.type(); - } - - Iterator<Expr> i = this.arguments.iterator(); - Iterator<Type> j = ci.formalTypes().iterator(); - - while (i.hasNext() && j.hasNext()) { - Expr e = i.next(); - Type t = j.next(); - - if (e == child) { - return t; - } - } - - return child.type(); - } - - - /** Get the precedence of the expression. */ public Precedence precedence() { return Precedence.LITERAL; Modified: trunk/x10.compiler/src/polyglot/ast/Node.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Node.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Node.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -11,7 +11,6 @@ import polyglot.types.Type; import polyglot.util.*; -import polyglot.visit.AscriptionVisitor; import polyglot.visit.NodeVisitor; /** @@ -113,22 +112,6 @@ public <T extends Node> List<T> visitList(List<T> l, NodeVisitor v); /** - * Get the expected type of a child expression of <code>this</code>. - * The expected type is determined by the context in that the child occurs - * (e.g., for <code>x = e</code>, the expected type of <code>e</code> is - * the declared type of <code>x</code>. - * - * The expected type should impose the least constraints on the child's - * type that are allowed by the parent node. - * - * @param child A child expression of this node. - * @param av An ascription visitor. - * @return The expected type of <code>child</code>. - */ - Type childExpectedType(Expr child, AscriptionVisitor av); - - - /** * Dump the AST node for debugging purposes. */ void dump(CodeWriter w); Modified: trunk/x10.compiler/src/polyglot/ast/NodeFactory.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/NodeFactory.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/NodeFactory.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -56,11 +56,6 @@ AmbReceiver AmbReceiver(Position pos, Prefix prefix, Id name); Receiver ReceiverFromQualifiedName(Position pos, QName qualifiedName); - // package or type - AmbQualifierNode AmbQualifierNode(Position pos, Id name); - AmbQualifierNode AmbQualifierNode(Position pos, Prefix qual, Id name); - QualifierNode QualifierNodeFromQualifiedName(Position pos, QName qualifiedName); - // package or type or expr AmbPrefix AmbPrefix(Position pos, Id name); AmbPrefix AmbPrefix(Position pos, Prefix prefix, Id name); @@ -68,7 +63,6 @@ AmbTypeNode AmbTypeNode(Position pos, Id name); AmbTypeNode AmbTypeNode(Position pos, Prefix qualifier, Id name); - TypeNode TypeNodeFromQualifiedName(Position pos, QName qualifiedName); ArrayTypeNode ArrayTypeNode(Position pos, TypeNode base); CanonicalTypeNode CanonicalTypeNode(Position pos, Type type); Modified: trunk/x10.compiler/src/polyglot/ast/NodeOps.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/NodeOps.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/NodeOps.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -113,7 +113,7 @@ * * @param ar The visitor which disambiguates. */ - Node disambiguate(ContextVisitor ar) throws SemanticException; + Node disambiguate(ContextVisitor ar); Node setResolverOverride(Node parent, TypeCheckPreparer v); void setResolver(Node parent, TypeCheckPreparer v); Modified: trunk/x10.compiler/src/polyglot/ast/Node_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Node_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Node_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -298,7 +298,7 @@ return this; } - public Node disambiguate(ContextVisitor ar) throws SemanticException { + public Node disambiguate(ContextVisitor ar) { return this; } @@ -323,10 +323,6 @@ return this; } - public Type childExpectedType(Expr child, AscriptionVisitor av) { - return child.type(); - } - public NodeVisitor exceptionCheckEnter(ExceptionChecker ec) { return ec.push(); } @@ -455,7 +451,7 @@ "not implement copy(NodeFactory). This compiler extension should" + " either implement the method, or not invoke this method."); } - public final Node copy(ExtensionInfo extInfo) throws SemanticException { + public final Node copy(ExtensionInfo extInfo) { return this.del().copy(extInfo.nodeFactory()); } Modified: trunk/x10.compiler/src/polyglot/ast/Return_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Return_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Return_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -63,30 +63,6 @@ /** Type check the statement. */ public abstract Node typeCheck(ContextVisitor tc); - public Type childExpectedType(Expr child, AscriptionVisitor av) { - if (child == expr) { - Context c = av.context(); - CodeDef ci = c.currentCode(); - - if (ci instanceof MethodDef) { - MethodDef mi = (MethodDef) ci; - - TypeSystem ts = av.typeSystem(); - - // If expr is an integral constant, we can relax the expected - // type to the type of the constant. - if (ts.numericConversionValid(mi.returnType().get(), child.constantValue(), c)) { - return child.type(); - } - else { - return mi.returnType().get(); - } - } - } - - return child.type(); - } - public String toString() { return "return" + (expr != null ? " " + expr : "") + ";"; } Modified: trunk/x10.compiler/src/polyglot/ast/Switch_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Switch_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Switch_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -143,16 +143,6 @@ return n; } - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = av.typeSystem(); - - if (child == expr) { - return ts.Int(); - } - - return child.type(); - } - public String toString() { return "switch (" + expr + ") { ... }"; } Modified: trunk/x10.compiler/src/polyglot/ast/Synchronized_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Synchronized_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Synchronized_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -89,16 +89,6 @@ return this; } - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = av.typeSystem(); - - if (child == expr) { - return ts.Object(); - } - - return child.type(); - } - public String toString() { return "synchronized (" + expr + ") { ... }"; } Modified: trunk/x10.compiler/src/polyglot/ast/Throw_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Throw_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Throw_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -71,16 +71,6 @@ return this; } - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = av.typeSystem(); - - if (child == expr) { - return ts.Throwable(); - } - - return child.type(); - } - public String toString() { return "throw " + expr + ";"; } Modified: trunk/x10.compiler/src/polyglot/ast/Unary_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Unary_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/Unary_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -77,48 +77,6 @@ /** Type check the expression. */ public abstract Node typeCheck(ContextVisitor tc); - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = av.typeSystem(); - Context context = av.context(); - try { - if (child == expr) { - if (op == POST_INC || op == POST_DEC || - op == PRE_INC || op == PRE_DEC) { - - if (ts.isImplicitCastValid(child.type(), av.toType(), context)) { - return ts.promote(child.type()); - } - else { - return av.toType(); - } - } - else if (op == NEG || op == POS) { - if (ts.isImplicitCastValid(child.type(), av.toType(), context)) { - return ts.promote(child.type()); - } - else { - return av.toType(); - } - } - else if (op == BIT_NOT) { - if (ts.isImplicitCastValid(child.type(), av.toType(), context)) { - return ts.promote(child.type()); - } - else { - return av.toType(); - } - } - else if (op == NOT) { - return ts.Boolean(); - } - } - } - catch (SemanticException e) { - } - - return child.type(); - } - /** Check exceptions thrown by the statement. */ public String toString() { if (op == NEG && expr instanceof IntLit && ((IntLit) expr).boundary()) { Modified: trunk/x10.compiler/src/polyglot/ast/While_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/While_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/ast/While_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -79,16 +79,6 @@ /** Type check the statement. */ public abstract Node typeCheck(ContextVisitor tc); - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = av.typeSystem(); - - if (child == cond) { - return ts.Boolean(); - } - - return child.type(); - } - public String toString() { return "while (" + cond + ") ..."; } Modified: trunk/x10.compiler/src/polyglot/parse/ParsedName.java =================================================================== --- trunk/x10.compiler/src/polyglot/parse/ParsedName.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/parse/ParsedName.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -62,15 +62,6 @@ return nf.AmbPrefix(pos, prefix.toPrefix(), name); } - // type or package - public QualifierNode toQualifier() { - if (prefix == null) { - return nf.AmbQualifierNode(pos, name); - } - - return nf.AmbQualifierNode(pos, prefix.toQualifier(), name); - } - // package public PackageNode toPackage() { if (prefix == null) { @@ -87,7 +78,7 @@ return nf.AmbTypeNode(pos, name); } - return nf.AmbTypeNode(pos, prefix.toQualifier(), name); + return nf.AmbTypeNode(pos, prefix.toPrefix(), name); } public String toString() { Modified: trunk/x10.compiler/src/polyglot/types/TypeSystem.java =================================================================== --- trunk/x10.compiler/src/polyglot/types/TypeSystem.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/types/TypeSystem.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -914,6 +914,10 @@ X10ClassType Runtime(); // used by asyncCodeInstance + /** + * <code>x10.lang.FailedDynamicCheckException</code> + */ + X10ClassType FailedDynamicCheckException(); // types used in WS codegen X10ClassType Frame(); Modified: trunk/x10.compiler/src/polyglot/types/TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/types/TypeSystem_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/types/TypeSystem_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -2300,6 +2300,10 @@ } public X10ClassType ClassCastException() { + return FailedDynamicCheckException(); + } + + public X10ClassType FailedDynamicCheckException() { return load("x10.lang.FailedDynamicCheckException"); } Deleted: trunk/x10.compiler/src/polyglot/visit/AscriptionVisitor.java =================================================================== --- trunk/x10.compiler/src/polyglot/visit/AscriptionVisitor.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/visit/AscriptionVisitor.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -1,126 +0,0 @@ -/* - * This file is part of the Polyglot extensible compiler framework. - * - * Copyright (c) 2000-2006 Polyglot project group, Cornell University - * - */ - -package polyglot.visit; - -import polyglot.ast.*; -import polyglot.frontend.Job; -import polyglot.types.*; - -/** Visitor which allows type information to be utilized to perform AST - modifications. - - The major advantage of this visitor is the new <code>ascribe()</code> - method, which allows AST translations based on the expression - and also the type that is expected. For the base translation (standard - Java), the type of the expression and the type that is expceted - are the same. Language extensions however may not have this property, - and can take advantage of the <code>ascribe</code> method to transform - the AST into a different form that will pass Java type-checking. - - @see #ascribe - */ -public class AscriptionVisitor extends ContextVisitor -{ - protected Type type; - protected AscriptionVisitor outerAscriptionVisitor; - - /** - * Default constructor. See the constructor in <code> ErrorHandingVisitor - * </code> for more details. - * - * @see polyglot.visit.ErrorHandlingVisitor#ErrorHandlingVisitor - */ - public AscriptionVisitor(Job job, TypeSystem ts, NodeFactory nf) { - super(job, ts, nf); - type = null; - outerAscriptionVisitor = null; - } - - // FIXME: what does this do? - /** - */ - public AscriptionVisitor pop() { - return outerAscriptionVisitor; - } - - /** Returns the type that is expected of the expression that is being - * visited. - */ - public Type toType() { - return type; - } - - // TODO is this comment revealing too much implementation? - /** Sets up the expected type information for later calls to - * <code>ascribe()</code>. Other than that, plays the same role - * as the <code>enterCall</code> method in - * <code>ErrorHandlingVisitor</code>. - */ - public NodeVisitor enterCall(Node parent, Node n) throws SemanticException { - Type t = null; - - if (parent != null && n instanceof Expr) { - t = parent.childExpectedType((Expr) n, this); - } - - AscriptionVisitor v = (AscriptionVisitor) shallowCopy(); - v.outerAscriptionVisitor = this; - v.type = t; - - return v; - } - - /** The <code>ascribe()</code> method is called for each expression - * and is passed the type the expression is <i>used at</i> rather - * than the type the type - * checker assigns to it. - * - * For instance, with the following code: - * - * <code>Object o = new Integer(3);</code> - * - * <code>ascribe()</code> will be called with expression - * <code>new Integer(3)</code> and type <code>Object</code>. - * - * @param e The expression that is being visited - * @param toType The type that the parent node is expecting. - * @return The new translated Expr node, or if nothing has changed, just - * e. - */ - public Expr ascribe(Expr e, Type toType) throws SemanticException { - return e; - } - - // TODO is this comment revealing too much implementation? - /** Calls <code>ascribe()<code> with the expected type and expression - * as appropriate. Otherwise functionally the same as the <code> - * leaveCall</code> method in <code>ErrorHandlingVisitor</code>. - */ - public Node leaveCall(Node parent, Node old, Node n, NodeVisitor v) - throws SemanticException { - - if (n instanceof Expr) { - Expr e = (Expr) n; - if (parent instanceof LocalAssign && ((LocalAssign) parent).local() == e) { - return e; - } - if (parent instanceof Unary) { - Unary u = (Unary) parent; - if (u.expr() == e) { - if (u.operator() == Unary.PRE_DEC || u.operator() == Unary.PRE_INC || u.operator() == Unary.POST_DEC || u.operator() == Unary.POST_INC) { - return e; - } - } - } - Type type = ((AscriptionVisitor) v).type; - return ascribe(e, type); - } - - return n; - } -} Modified: trunk/x10.compiler/src/polyglot/visit/TypeChecker.java =================================================================== --- trunk/x10.compiler/src/polyglot/visit/TypeChecker.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/polyglot/visit/TypeChecker.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -51,7 +51,7 @@ return v; } - protected Node leaveCall(Node old, final Node n, NodeVisitor v) throws SemanticException { + protected Node leaveCall(Node old, final Node n, NodeVisitor v) { final TypeChecker tc = (TypeChecker) v; // Check for expressions with unknown type. This avoids reporting too many type errors. Modified: trunk/x10.compiler/src/x10/ast/Async_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Async_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/x10/ast/Async_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -35,7 +35,6 @@ import polyglot.util.CodeWriter; import polyglot.util.CollectionUtil; import x10.util.CollectionFactory; import polyglot.util.Position; -import polyglot.visit.AscriptionVisitor; import polyglot.visit.CFGBuilder; import polyglot.visit.ContextVisitor; import polyglot.visit.FlowGraph; @@ -235,11 +234,6 @@ } - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = (TypeSystem) av.typeSystem(); - return child.type(); - } - public String toString() { return "async { ... }"; } Modified: trunk/x10.compiler/src/x10/ast/AtExpr_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AtExpr_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/x10/ast/AtExpr_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -28,7 +28,6 @@ import polyglot.util.CodeWriter; import polyglot.util.Position; import polyglot.util.InternalCompilerError; -import polyglot.visit.AscriptionVisitor; import polyglot.visit.CFGBuilder; import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; @@ -220,14 +219,6 @@ return succs; } - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = (TypeSystem) av.typeSystem(); - if ( child == place ) { - return ts.Place(); - } - return child.type(); - } - public String toString() { return "(#" + hashCode() + // todo: using hashCode leads to non-determinism in the output of the compiler ") at[" + returnType + "](" + place + ") " + body; Modified: trunk/x10.compiler/src/x10/ast/AtHomeExpr_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AtHomeExpr_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/x10/ast/AtHomeExpr_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -30,7 +30,6 @@ import polyglot.util.CodeWriter; import polyglot.util.Position; import polyglot.util.InternalCompilerError; -import polyglot.visit.AscriptionVisitor; import polyglot.visit.CFGBuilder; import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; Modified: trunk/x10.compiler/src/x10/ast/AtHomeStmt_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AtHomeStmt_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/x10/ast/AtHomeStmt_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -41,7 +41,6 @@ import x10.util.CollectionFactory; import polyglot.util.InternalCompilerError; import polyglot.util.Position; -import polyglot.visit.AscriptionVisitor; import polyglot.visit.CFGBuilder; import polyglot.visit.ContextVisitor; import polyglot.visit.FlowGraph; Modified: trunk/x10.compiler/src/x10/ast/AtStmt_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AtStmt_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/x10/ast/AtStmt_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -40,7 +40,6 @@ import x10.util.CollectionFactory; import polyglot.util.InternalCompilerError; import polyglot.util.Position; -import polyglot.visit.AscriptionVisitor; import polyglot.visit.CFGBuilder; import polyglot.visit.ContextVisitor; import polyglot.visit.FlowGraph; @@ -315,15 +314,6 @@ return c; } - - public Type childExpectedType(Expr child, AscriptionVisitor av) { - TypeSystem ts = (TypeSystem) av.typeSystem(); - if (child == place) { - return ts.Place(); - } - return child.type(); - } - public String toString() { return "at (" + place + ") " + body; } Modified: trunk/x10.compiler/src/x10/ast/Atomic_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Atomic_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/x10/ast/Atomic_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -24,7 +24,6 @@ import polyglot.types.TypeSystem; import polyglot.util.CodeWriter; import polyglot.util.Position; -import polyglot.visit.AscriptionVisitor; import polyglot.visit.CFGBuilder; import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; Modified: trunk/x10.compiler/src/x10/ast/ClosureCall_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ClosureCall_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/x10/ast/ClosureCall_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -36,7 +36,6 @@ import polyglot.util.Pair; import polyglot.util.Position; import polyglot.util.TypedList; -import polyglot.visit.AscriptionVisitor; import polyglot.visit.CFGBuilder; import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; @@ -246,27 +245,6 @@ } } - public Type childExpectedType(Expr child, AscriptionVisitor av) - { - if (child == target) { - return ci.container(); - } - - Iterator<Expr> i = this.arguments.iterator(); - Iterator<Type> j = ci.formalTypes().iterator(); - - while (i.hasNext() && j.hasNext()) { - Expr e = i.next(); - Type t = j.next(); - - if (e == child) { - return t; - } - } - - return child.type(); - } - public String toString() { StringBuffer buff= new StringBuffer(); buff.append(target) Modified: trunk/x10.compiler/src/x10/ast/FinishExpr_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/FinishExpr_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/x10/ast/FinishExpr_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -17,7 +17,6 @@ import polyglot.types.Types; import polyglot.util.CollectionUtil; import x10.util.CollectionFactory; import polyglot.util.Position; -import polyglot.visit.AscriptionVisitor; import polyglot.visit.CFGBuilder; import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; Modified: trunk/x10.compiler/src/x10/ast/FunctionTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/FunctionTypeNode_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/x10/ast/FunctionTypeNode_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -44,6 +44,7 @@ import polyglot.visit.TypeCheckPreparer; import polyglot.visit.TypeChecker; +import x10.errors.Errors; import x10.types.ClosureDef; import x10.types.FunctionType; import x10.types.ParameterType; @@ -74,7 +75,7 @@ } @Override - public Node disambiguate(ContextVisitor ar) throws SemanticException { + public Node disambiguate(ContextVisitor ar) { NodeFactory nf = (NodeFactory) ar.nodeFactory(); TypeSystem ts = (TypeSystem) ar.typeSystem(); FunctionTypeNode_c n = this; @@ -94,10 +95,15 @@ //if (guard != null) // throw new SemanticException("Function types with guards are currently unsupported.", position()); if (guard != null && guard.typeConstraint() != null && !Types.get(guard.typeConstraint()).terms().isEmpty()) { - throw new SemanticException("Type constraints not permitted in function type guards.", position()); + Errors.issue(ar.job(), + new SemanticException("Type constraints not permitted in function type guards.", position())); + guard = guard.typeConstraint(null); } - if (typeParams.size() != 0) - throw new SemanticException("Function types with type parameters are currently unsupported.", position()); + if (typeParams.size() != 0) { + Errors.issue(ar.job(), + new SemanticException("Function types with type parameters are currently unsupported.", position())); + typeParams = Collections.<ParameterType>emptyList(); + } FunctionType result = ts.functionType(position(), returnType.typeRef(), typeParams, formalTypes, formalNames, guard != null ? guard.valueConstraint() : Types.lazyRef(new CConstraint()) Modified: trunk/x10.compiler/src/x10/ast/HasTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/HasTypeNode_c.java 2011-05-09 22:01:18 UTC (rev 21628) +++ trunk/x10.compiler/src/x10/ast/HasTypeNode_c.java 2011-05-09 23:59:58 UTC (rev 21629) @@ -22,7 +22,6 @@ i... [truncated message content] |
From: <mt...@us...> - 2011-05-10 03:09:48
|
Revision: 21635 http://x10.svn.sourceforge.net/x10/?rev=21635&view=rev Author: mtake Date: 2011-05-10 03:09:42 +0000 (Tue, 10 May 2011) Log Message: ----------- Stop passing rtt to java raw class's methods without relying on @Native annotation to interface method Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime/src-x10/x10/lang/Comparable.x10 Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2011-05-10 02:40:40 UTC (rev 21634) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2011-05-10 03:09:42 UTC (rev 21635) @@ -1689,9 +1689,10 @@ boolean isDispatchMethod = false; if (isSelfDispatch) { - Type tt = Types.baseType(target.type()); + Type tt = Types.baseType(targetType); if (tt instanceof X10ClassType && ((X10ClassType) tt).flags().isInterface()) { - if (containsTypeParam(mi.def().formalTypes())) { + // N.B. stop passing rtt to java raw class's methods + if (containsTypeParam(mi.def().formalTypes()) && !Emitter.isNativeRepedToJava(tt)) { isDispatchMethod = true; } } else if (target instanceof ParExpr && ((ParExpr) target).expr() instanceof Closure_c) { @@ -1828,9 +1829,10 @@ } else if (isSelfDispatch && xts.isParameterType(targetType)) { ct = (X10ClassType) Types.baseType(mi.container()); } + // N.B. stop passing rtt to java raw class's methods if (ct != null - && ((ct.flags().isInterface() || (xts.isFunctionType(ct) && ct.isAnonymous())) && Emitter - .containsTypeParam(defType))) { + && ((ct.flags().isInterface() || (xts.isFunctionType(ct) && ct.isAnonymous())) && Emitter.containsTypeParam(defType)) + && !Emitter.isNativeRepedToJava(ct)) { w.write(","); new RuntimeTypeExpander(er, c.methodInstance().formalTypes().get(i)).expand(); } Modified: trunk/x10.runtime/src-x10/x10/lang/Comparable.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Comparable.x10 2011-05-10 02:40:40 UTC (rev 21634) +++ trunk/x10.runtime/src-x10/x10/lang/Comparable.x10 2011-05-10 03:09:42 UTC (rev 21635) @@ -40,7 +40,7 @@ * @return a negative integer, zero, or a positive integer if this entity is less than, equal * to, or greater than the given entity. */ - @Native("java", "#this.compareTo(#that)") + // @Native("java", "#this.compareTo(#that)") @Native("c++", "x10::lang::Comparable<#T >::compareTo(#this, #that)") def compareTo(that:T):Int; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |