From: <ta...@us...> - 2010-02-08 16:03:13
|
Revision: 12824 http://x10.svn.sourceforge.net/x10/?rev=12824&view=rev Author: tardieu Date: 2010-02-08 16:02:44 +0000 (Mon, 08 Feb 2010) Log Message: ----------- miror r12817 for java backend: permit native instance methods to refer to type parameters of enclosing class removed dummy type parameter of copyTo/From methods Modified Paths: -------------- trunk/x10.compiler/src/x10/emitter/Emitter.java trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime/src-x10/x10/lang/Rail.x10 trunk/x10.runtime/src-x10/x10/lang/System.x10 trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 Modified: trunk/x10.compiler/src/x10/emitter/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10/emitter/Emitter.java 2010-02-08 11:57:05 UTC (rev 12823) +++ trunk/x10.compiler/src/x10/emitter/Emitter.java 2010-02-08 16:02:44 UTC (rev 12824) @@ -4,6 +4,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -988,7 +989,7 @@ String pat = getJavaImplForDef(md.x10Def()); if (pat != null) { String target = "this"; - emitNativeAnnotation(pat, target, md.typeParameters(), dispatchArgs); + emitNativeAnnotation(pat, target, md.typeParameters(), dispatchArgs, Collections.<Type>emptyList()); w.write("; }"); return; } @@ -1124,8 +1125,8 @@ * object for B #7 = a #8 = b */ public void emitNativeAnnotation(String pat, Object target, - List<Type> types, List<? extends Object> args) { - Object[] components = new Object[1 + types.size() * 3 + args.size()]; + List<Type> types, List<? extends Object> args, List<Type> typeArguments) { + Object[] components = new Object[1 + types.size() * 3 + args.size() + typeArguments.size() * 3]; int i = 0; components[i++] = target; for (Type at : types) { @@ -1136,6 +1137,11 @@ for (Object e : args) { components[i++] = e; } + for (Type at : typeArguments) { + components[i++] = new TypeExpander(this, at, true, false, false); + components[i++] = new TypeExpander(this, at, true, true, false); + components[i++] = new RuntimeTypeExpander(this, at); + } this.dumpRegex("Native", components, tr, pat); } Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-02-08 11:57:05 UTC (rev 12823) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-02-08 16:02:44 UTC (rev 12824) @@ -931,7 +931,12 @@ if (needsHereCheck && ! (target instanceof TypeNode || target instanceof New)) { tmp = new Template(er, "place-check", new TypeExpander(er, target.type(), true, false, false), target); } - er.emitNativeAnnotation(pat, null == tmp ? target : tmp, mi.typeParameters(), c.arguments()); + List<Type> typeArguments = Collections.<Type>emptyList(); + if (mi.container().isClass() && !mi.flags().isStatic()) { + X10ClassType ct = (X10ClassType) mi.container().toClass(); + typeArguments = ct.typeArguments(); + } + er.emitNativeAnnotation(pat, null == tmp ? target : tmp, mi.typeParameters(), c.arguments(), typeArguments); return; } @@ -1403,7 +1408,7 @@ String pat = er.getJavaImplForDef(mi.x10Def()); if (pat != null) { - er.emitNativeAnnotation(pat, null == tmp ? array : tmp, mi.typeParameters(), args); + er.emitNativeAnnotation(pat, null == tmp ? array : tmp, mi.typeParameters(), args, Collections.<Type>emptyList()); return; } else { // otherwise emit the hardwired code. Modified: trunk/x10.runtime/src-x10/x10/lang/Rail.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Rail.x10 2010-02-08 11:57:05 UTC (rev 12823) +++ trunk/x10.runtime/src-x10/x10/lang/Rail.x10 2010-02-08 16:02:44 UTC (rev 12824) @@ -100,70 +100,60 @@ // Transfer functions - @Native("java", "x10.lang.System.copyTo(#3, #0,#4,#5,#6,#7)") - @Native("c++", "(#0)->copyTo(#4,#5,#6,#7)") - // U must be T. hack to get the type info. - public native def copyTo[U] (src_off:Int, dst:Rail[U], dst_off:Int, len:Int) : Void; + @Native("java", "x10.lang.System.copyTo(#7, #0,#1,#2,#3,#4)") + @Native("c++", "(#0)->copyTo(#1,#2,#3,#4)") + public native def copyTo (src_off:Int, dst:Rail[T], dst_off:Int, len:Int) : Void; - @Native("java", "x10.lang.System.copyTo(#3, #0,#4,#5,#6,#7)") - @Native("c++", "(#0)->copyTo(#4,#5,#6,#7)") - // U must be T. hack to get the type info. - public native def copyTo[U] (src_off:Int, - dst_place:Place, dst_finder:()=>Pair[Rail[U],Int], - len:Int) : Void; + @Native("java", "x10.lang.System.copyTo(#7, #0,#1,#2,#3,#4)") + @Native("c++", "(#0)->copyTo(#1,#2,#3,#4)") + public native def copyTo (src_off:Int, + dst_place:Place, dst_finder:()=>Pair[Rail[T],Int], + len:Int) : Void; - @Native("java", "x10.lang.System.copyTo(#3, #0,#4,#5,#6,#7,#8)") - @Native("c++", "(#0)->copyTo(#4,#5,#6,#7,#8)") - // U must be T. hack to get the type info. - public native def copyTo[U] (src_off:Int, - dst_place:Place, dst_finder:()=>Pair[Rail[U],Int], - len:Int, notifier:()=>Void) : Void; + @Native("java", "x10.lang.System.copyTo(#8, #0,#1,#2,#3,#4,#5)") + @Native("c++", "(#0)->copyTo(#1,#2,#3,#4,#5)") + public native def copyTo (src_off:Int, + dst_place:Place, dst_finder:()=>Pair[Rail[T],Int], + len:Int, notifier:()=>Void) : Void; - @Native("java", "x10.lang.System.copyTo(#3, #0,#4,#5,#6,#7,#8)") - @Native("c++", "x10::lang::System::copyTo(#0,#4,#5,#6,#7,#8)") - // U must be T. hack to get the type info. - public native def copyTo[U] (src_off:Int, - dst_place:Place, dst_handle:PlaceLocalHandle[Rail[U]], dst_off:Int, - len:Int) : Void; + @Native("java", "x10.lang.System.copyTo(#8, #0,#1,#2,#3,#4,#5)") + @Native("c++", "x10::lang::System::copyTo(#0,#1,#2,#3,#4,#5)") + public native def copyTo (src_off:Int, + dst_place:Place, dst_handle:PlaceLocalHandle[Rail[T]], dst_off:Int, + len:Int) : Void; - @Native("java", "x10.lang.System.copyTo(#3, #0,#4,#5,#6,#7,#8,#9)") - @Native("c++", "x10::lang::System::copyTo(#0,#4,#5,#6,#7,#8,#9)") - // U must be T. hack to get the type info. - public native def copyTo[U] (src_off:Int, - dst_place:Place, dst_handle:PlaceLocalHandle[Rail[U]], dst_off:Int, - len:Int, notifier:()=>Void) : Void; + @Native("java", "x10.lang.System.copyTo(#9, #0,#1,#2,#3,#4,#5,#6)") + @Native("c++", "x10::lang::System::copyTo(#0,#1,#2,#3,#4,#5,#6)") + public native def copyTo (src_off:Int, + dst_place:Place, dst_handle:PlaceLocalHandle[Rail[T]], dst_off:Int, + len:Int, notifier:()=>Void) : Void; - @Native("java", "x10.lang.System.copyTo(#3 #0,#4,#5,#6,#7,#8)") - @Native("c++", "x10::lang::System::copyTo(#0,#4,#5,#6,#7,#8)") - // U must be T. hack to get the type info. - public native def copyTo[U] (src_off:Int, dst:Rail[U], dst_off:Int, - len:Int, notifier:()=>Void) : Void; + @Native("java", "x10.lang.System.copyTo(#8 #0,#1,#2,#3,#4,#5)") + @Native("c++", "x10::lang::System::copyTo(#0,#1,#2,#3,#4,#5)") + public native def copyTo (src_off:Int, dst:Rail[T], dst_off:Int, + len:Int, notifier:()=>Void) : Void; - @Native("java", "x10.lang.System.copyFrom(#3, #0,#4,#5,#6,#7)") - @Native("c++", "(#0)->copyFrom(#4,#5,#6,#7)") - // U must be T. hack to get the type info. - public native def copyFrom[U] (dst_off:Int, src:Rail[U], src_off:Int, len:Int) : Void; + @Native("java", "x10.lang.System.copyFrom(#7, #0,#1,#2,#3,#4)") + @Native("c++", "(#0)->copyFrom(#1,#2,#3,#4)") + public native def copyFrom (dst_off:Int, src:Rail[T], src_off:Int, len:Int) : Void; - @Native("java", "x10.lang.System.copyFrom(#3, #0,#4,#5,#6,#7)") - @Native("c++", "(#0)->copyFrom(#4,#5,#6,#7)") - // U must be T. hack to get the type info. - public native def copyFrom[U] (dst_off:Int, - src_place:Place, src_finder:()=>Pair[Rail[U],Int], - len:Int) : Void; + @Native("java", "x10.lang.System.copyFrom(#7, #0,#1,#2,#3,#4)") + @Native("c++", "(#0)->copyFrom(#1,#2,#3,#4)") + public native def copyFrom (dst_off:Int, + src_place:Place, src_finder:()=>Pair[Rail[T],Int], + len:Int) : Void; - @Native("java", "x10.lang.System.copyFrom(#3, #0,#4,#5,#6,#7)") - @Native("c++", "(#0)->copyFrom(#4,#5,#6,#7)") - // U must be T. hack to get the type info. - public native def copyFrom[U] (dst_off:Int, src:ValRail[U], src_off:Int, len:Int):Void; + @Native("java", "x10.lang.System.copyFrom(#7, #0,#1,#2,#3,#4)") + @Native("c++", "(#0)->copyFrom(#1,#2,#3,#4)") + public native def copyFrom (dst_off:Int, src:ValRail[T], src_off:Int, len:Int):Void; - @Native("java", "x10.lang.System.copyFrom(#3, #0,#4,#5,#6,#7)") - @Native("c++", "(#0)->copyFrom(#4,#5,#6,#7)") - // U must be T. hack to get the type info. - public native def copyFrom[U] (dst_off:Int, - src_place:Place, src_finder:()=>Pair[ValRail[U],Int], - len:Int) : Void; + @Native("java", "x10.lang.System.copyFrom(#7, #0,#1,#2,#3,#4)") + @Native("c++", "(#0)->copyFrom(#1,#2,#3,#4)") + public native def copyFrom (dst_off:Int, + src_place:Place, src_finder:()=>Pair[ValRail[T],Int], + len:Int) : Void; - @Native("java", "#0.view()") + @Native("java", "#0.view()") @Native("c++", "#0->view()") public native def view(): ValRail[T]{self.length==this.length}; Modified: trunk/x10.runtime/src-x10/x10/lang/System.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/System.x10 2010-02-08 11:57:05 UTC (rev 12823) +++ trunk/x10.runtime/src-x10/x10/lang/System.x10 2010-02-08 16:02:44 UTC (rev 12824) @@ -245,7 +245,7 @@ dst_place:Place, dst_handle:PlaceLocalHandle[Rail[T]]!, dst_off:Int, len:Int) { val finder = ()=> Pair[Rail[T],Int](dst_handle(), dst_off); - src.copyTo[T](src_off, dst_place, finder, len); + src.copyTo(src_off, dst_place, finder, len); Runtime.dealloc(finder); } @@ -267,7 +267,7 @@ dst:Place, dst_handle:PlaceLocalHandle[Rail[T]]!, dst_off:Int, len:Int, notifier:()=>Void) { val finder = ()=> Pair[Rail[T],Int](dst_handle(), dst_off); - src.copyTo[T](src_off, dst, finder, len, notifier); + src.copyTo(src_off, dst, finder, len, notifier); Runtime.dealloc(finder); Runtime.dealloc(notifier); } @@ -287,7 +287,7 @@ public static def copyTo[T](handle:PlaceLocalHandle[Rail[T]]!, dst_place:Place, len:Int, notifier:()=>Void) { val finder = ()=>Pair[Rail[T],Int](handle(), 0); - handle().copyTo[T](0, dst_place, finder, len, notifier); + handle().copyTo(0, dst_place, finder, len, notifier); Runtime.dealloc(finder); Runtime.dealloc(notifier); } @@ -306,7 +306,7 @@ public static def copyTo[T](src:Rail[T]!, src_off:Int, dst:Rail[T], dst_off:Int, len:Int, notifier:()=>Void) { val finder = ()=>Pair[Rail[T],Int](dst,dst_off); - src.copyTo[T](src_off, dst.home, finder, len, notifier); + src.copyTo(src_off, dst.home, finder, len, notifier); Runtime.dealloc(finder); Runtime.dealloc(notifier); } Modified: trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 2010-02-08 11:57:05 UTC (rev 12823) +++ trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 2010-02-08 16:02:44 UTC (rev 12824) @@ -86,7 +86,7 @@ } next; // every place has transmitted contents to master val handle = data; // avoid 'this' being serialised - finish local_.copyFrom[T](0, firstPlace, ()=>Pair[Rail[T],Int](handle(),0), local_.length); + finish local_.copyFrom(0, firstPlace, ()=>Pair[Rail[T],Int](handle(),0), local_.length); } else { next; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |