Permalink
Browse files

[java] augment FindMethod and Invoke with SpecialFindMethod and Speci…

…alInvoke, still passing 45 NQP tests out of the 299 that dotnet/ does
  • Loading branch information...
mberends committed Jan 25, 2011
1 parent 4252adf commit b3bdc96cb026345591c36c2411b709c72713415f
@@ -481,7 +481,7 @@ our multi sub jst_for(PAST::Block $block) {
# low level code object.
if $block.blocktype eq 'immediate' {
return JST::MethodCall.new(
- :name('getSTable().Invoke.Invoke'), :type('RakudoObject'),
+ :name('getSTable().Invoke'), :type('RakudoObject'),
"StaticBlockInfo[$our_sbi]",
TC(),
"StaticBlockInfo[$our_sbi]",
@@ -588,7 +588,7 @@ our multi sub jst_for(PAST::Op $op) {
my $callee := JST::Local.new(
:name(get_unique_id('callee')), :isdecl(1), :type('RakudoObject'),
JST::MethodCall.new(
- :on($inv.name), :name('getSTable().FindMethod.FindMethod'), :type('RakudoObject'),
+ :on($inv.name), :name('getSTable().FindMethod'), :type('RakudoObject'),
TC(),
$inv.name,
$name,
@@ -622,7 +622,7 @@ our multi sub jst_for(PAST::Op $op) {
return JST::Stmts.new(
$inv,
JST::MethodCall.new(
- :name('getSTable().Invoke.Invoke'), :type('RakudoObject'),
+ :name('getSTable().Invoke'), :type('RakudoObject'),
$callee,
'TC',
$callee.name,
@@ -668,7 +668,7 @@ our multi sub jst_for(PAST::Op $op) {
# Emit call.
return JST::MethodCall.new(
- :name('getSTable().Invoke.Invoke'), :type('RakudoObject'),
+ :name('getSTable().Invoke'), :type('RakudoObject'),
$callee,
TC(),
$callee.name,
View
@@ -30,7 +30,7 @@
# | | | | | | |
# | | +-------> Ops P6hash | | | |
# | | | | P6int | | | |
-# | | 4 P6opaque IFindMethod | REPRRegistry
+# | | 4 P6opaque ISpecialFindMethod| REPRRegistry
# | | | | | | |
# | | | CaptureHelper | | |
# | | | | | | |
@@ -51,8 +51,6 @@ CLASSES = classes/
ALL_BUILD_TARGETS = \
$(CLASSES)Rakudo/Metamodel/Hints.class \
$(CLASSES)Rakudo/Serialization/SerializationContext.class \
- $(CLASSES)Rakudo/Runtime/Context.class \
- $(CLASSES)Rakudo/Runtime/ExecutionDomain.class \
$(CLASSES)Rakudo/Metamodel/RakudoObject.class \
$(CLASSES)Rakudo/Metamodel/REPRRegistry.class \
$(CLASSES)Rakudo/Metamodel/Representations/P6hash.class \
@@ -62,31 +60,32 @@ ALL_BUILD_TARGETS = \
$(CLASSES)Rakudo/Metamodel/Representations/P6opaque.class \
$(CLASSES)Rakudo/Runtime/CodeObjectUtility.class \
$(CLASSES)Rakudo/Runtime/DefinednessConstraint.class \
+ $(CLASSES)Rakudo/Runtime/ExecutionDomain.class \
$(CLASSES)Rakudo/Runtime/SignatureBinder.class \
$(CLASSES)Rakudo/Metamodel/KnowHOW/KnowHOWREPR.class \
$(CLASSES)Rakudo/Metamodel/KnowHOW/KnowHOWBootstrapper.class \
$(CLASSES)Rakudo/Init.class
OTHER_DEPENDENT_TARGETS = \
- $(CLASSES)Rakudo/Runtime/CaptureHelper.class \
- $(CLASSES)Rakudo/Runtime/Exceptions/ExceptionDispatcher.class \
- $(CLASSES)Rakudo/Runtime/Exceptions/Handler.class \
- $(CLASSES)Rakudo/Runtime/Exceptions/LeaveStackUnwinderException.class \
- $(CLASSES)Rakudo/Runtime/Lexpad.class \
- $(CLASSES)Rakudo/Runtime/Parameter.class \
- $(CLASSES)Rakudo/Runtime/Signature.class \
+ $(CLASSES)Rakudo/Metamodel/ISpecialFindMethod.class \
$(CLASSES)Rakudo/Metamodel/Representation.class \
$(CLASSES)Rakudo/Metamodel/Representations/P6capture.class \
$(CLASSES)Rakudo/Metamodel/Representations/P6list.class \
$(CLASSES)Rakudo/Metamodel/Representations/P6mapping.class \
$(CLASSES)Rakudo/Metamodel/Representations/RakudoCodeRef.class \
+ $(CLASSES)Rakudo/Metamodel/SharedTable.class \
+ $(CLASSES)Rakudo/Runtime/CaptureHelper.class \
+ $(CLASSES)Rakudo/Runtime/Context.class \
+ $(CLASSES)Rakudo/Runtime/Exceptions/ExceptionDispatcher.class \
+ $(CLASSES)Rakudo/Runtime/Exceptions/Handler.class \
+ $(CLASSES)Rakudo/Runtime/Exceptions/LeaveStackUnwinderException.class \
+ $(CLASSES)Rakudo/Runtime/Lexpad.class \
$(CLASSES)Rakudo/Runtime/MultiDispatch/DispatchCache.class \
$(CLASSES)Rakudo/Runtime/MultiDispatch/MultiDispatcher.class \
$(CLASSES)Rakudo/Runtime/Ops.class \
- $(CLASSES)Rakudo/Runtime/ThreadContext.class \
- $(CLASSES)Rakudo/Metamodel/IFindMethod.class \
- $(CLASSES)Rakudo/Metamodel/ISpecialFindMethod.class \
- $(CLASSES)Rakudo/Metamodel/SharedTable.class
+ $(CLASSES)Rakudo/Runtime/Parameter.class \
+ $(CLASSES)Rakudo/Runtime/Signature.class \
+ $(CLASSES)Rakudo/Runtime/ThreadContext.class
INNER_CLASSES = \
$(CLASSES)Rakudo/Metamodel/Representations/RakudoCodeRef$$Instance.class
@@ -123,8 +122,7 @@ $(CLASSES)Rakudo/Runtime/Context.class: $(CLASSES)Rakudo/Metamodel/RakudoObject.
# Handle it by compiling all the interdependent files in a single step.
# Thanks jnthn++ for the suggestion.
$(CLASSES)Rakudo/Metamodel/RakudoObject.class: Rakudo/Metamodel/RakudoObject.java \
- $(CLASSES)Rakudo/Runtime/DefinednessConstraint.class \
- Rakudo/Serialization/SerializationContext.java \
+ Rakudo/Metamodel/ISpecialFindMethod.java \
Rakudo/Metamodel/Representation.java \
Rakudo/Metamodel/Representations/P6capture.java \
Rakudo/Metamodel/Representations/P6int.java \
@@ -133,24 +131,25 @@ $(CLASSES)Rakudo/Metamodel/RakudoObject.class: Rakudo/Metamodel/RakudoObject.jav
Rakudo/Metamodel/Representations/P6num.java \
Rakudo/Metamodel/Representations/P6str.java \
Rakudo/Metamodel/Representations/RakudoCodeRef.java \
- Rakudo/Runtime/CaptureHelper.java \
- Rakudo/Runtime/Lexpad.java \
- Rakudo/Runtime/Parameter.java \
- Rakudo/Runtime/Signature.java \
Rakudo/Metamodel/REPRRegistry.java \
+ Rakudo/Metamodel/SharedTable.java \
+ Rakudo/Runtime/CaptureHelper.java \
Rakudo/Runtime/Context.java \
- Rakudo/Runtime/ExecutionDomain.java \
+ $(CLASSES)Rakudo/Runtime/DefinednessConstraint.class \
Rakudo/Runtime/Exceptions/ExceptionDispatcher.java \
Rakudo/Runtime/Exceptions/Handler.java \
Rakudo/Runtime/Exceptions/LeaveStackUnwinderException.java \
+ Rakudo/Runtime/ExecutionDomain.java \
+ Rakudo/Runtime/Lexpad.java \
Rakudo/Runtime/MultiDispatch/DispatchCache.java \
Rakudo/Runtime/MultiDispatch/MultiDispatcher.java \
Rakudo/Runtime/Ops.java \
+ Rakudo/Runtime/Parameter.java \
+ Rakudo/Runtime/Signature.java \
Rakudo/Runtime/ThreadContext.java \
- Rakudo/Metamodel/IFindMethod.java \
- Rakudo/Metamodel/ISpecialFindMethod.java \
- Rakudo/Metamodel/SharedTable.java
+ Rakudo/Serialization/SerializationContext.java
$(JAVAC) \
+ Rakudo/Metamodel/ISpecialFindMethod.java \
Rakudo/Metamodel/RakudoObject.java \
Rakudo/Metamodel/Representation.java \
Rakudo/Metamodel/Representations/P6capture.java \
@@ -160,30 +159,27 @@ $(CLASSES)Rakudo/Metamodel/RakudoObject.class: Rakudo/Metamodel/RakudoObject.jav
Rakudo/Metamodel/Representations/P6num.java \
Rakudo/Metamodel/Representations/P6str.java \
Rakudo/Metamodel/Representations/RakudoCodeRef.java \
- Rakudo/Runtime/CaptureHelper.java \
- Rakudo/Runtime/Lexpad.java \
- Rakudo/Runtime/Parameter.java \
- Rakudo/Runtime/Signature.java \
Rakudo/Metamodel/REPRRegistry.java \
+ Rakudo/Metamodel/SharedTable.java \
+ Rakudo/Runtime/CaptureHelper.java \
Rakudo/Runtime/Context.java \
Rakudo/Runtime/ExecutionDomain.java \
Rakudo/Runtime/Exceptions/ExceptionDispatcher.java \
Rakudo/Runtime/Exceptions/Handler.java \
Rakudo/Runtime/Exceptions/LeaveStackUnwinderException.java \
+ Rakudo/Runtime/Lexpad.java \
Rakudo/Runtime/MultiDispatch/DispatchCache.java \
Rakudo/Runtime/MultiDispatch/MultiDispatcher.java \
Rakudo/Runtime/Ops.java \
- Rakudo/Runtime/ThreadContext.java \
- Rakudo/Metamodel/IFindMethod.java \
- Rakudo/Metamodel/ISpecialFindMethod.java \
- Rakudo/Metamodel/SharedTable.java
+ Rakudo/Runtime/Parameter.java \
+ Rakudo/Runtime/Signature.java \
+ Rakudo/Runtime/ThreadContext.java
$(CLASSES)Rakudo/Metamodel/KnowHOW/KnowHOWREPR.class: Rakudo/Metamodel/KnowHOW/KnowHOWREPR.java \
$(CLASSES)Rakudo/Metamodel/Hints.class
$(JAVAC) Rakudo/Metamodel/KnowHOW/KnowHOWREPR.java
$(CLASSES)Rakudo/Metamodel/KnowHOW/KnowHOWBootstrapper.class: Rakudo/Metamodel/KnowHOW/KnowHOWBootstrapper.java \
- $(CLASSES)Rakudo/Metamodel/IFindMethod.class \
$(CLASSES)Rakudo/Metamodel/KnowHOW/KnowHOWREPR.class \
$(CLASSES)Rakudo/Metamodel/RakudoObject.class \
$(CLASSES)Rakudo/Metamodel/Representation.class \
@@ -176,7 +176,7 @@ public static Context LoadSetting(String settingName, RakudoObject knowHOW, Raku
// Run it to get the context we want.
Context settingContext = null;
try {
- settingContext = (Context)methodLoadSetting.invoke( null );
+ settingContext = (Context)methodLoadSetting.invoke( null, new Object[] { });
}
catch (IllegalAccessException ex) {
System.err.println("Illegal access: " + ex.getMessage());
@@ -196,15 +196,14 @@ public static Context LoadSetting(String settingName, RakudoObject knowHOW, Raku
settingContext.LexPad.SetByName("KnowHOWAttribute", knowHOWAttribute);
settingContext.LexPad.SetByName("print",
CodeObjectUtility.WrapNativeMethod( new RakudoCodeRef.IFunc_Body()
- { // an anonymous class where C# has a => (lambda)
+ { // C# has a => (lambda)
public RakudoObject Invoke(ThreadContext tc, RakudoObject self, RakudoObject capture)
{
- int numPositionals = CaptureHelper.NumPositionals(capture);
- for (int i = 0; i < numPositionals; i++)
+ for (int i = 0; i < CaptureHelper.NumPositionals(capture); i++)
{
RakudoObject value = CaptureHelper.GetPositional(capture, i);
- RakudoObject strMeth = self.getSTable().FindMethod.FindMethod(tc, value, "Str", 0);
- RakudoObject strVal = strMeth.getSTable().Invoke.Invoke(tc, strMeth,
+ RakudoObject strMeth = self.getSTable().FindMethod(tc, value, "Str", 0);
+ RakudoObject strVal = strMeth.getSTable().Invoke(tc, strMeth,
CaptureHelper.FormWith( new RakudoObject[] { value } ));
System.out.print(Ops.unbox_str(null, strVal));
}
@@ -214,14 +213,13 @@ public RakudoObject Invoke(ThreadContext tc, RakudoObject self, RakudoObject cap
));
settingContext.LexPad.SetByName("say",
CodeObjectUtility.WrapNativeMethod( new RakudoCodeRef.IFunc_Body()
- { // an anonymous class where C# has a => (lambda)
+ { // C# has a => (lambda)
public RakudoObject Invoke(ThreadContext tc, RakudoObject self, RakudoObject capture)
{
- int numPositionals = CaptureHelper.NumPositionals(capture);
- for (int i = 0; i < numPositionals; i++) {
+ for (int i = 0; i < CaptureHelper.NumPositionals(capture); i++) {
RakudoObject value = CaptureHelper.GetPositional(capture, i);
- RakudoObject strMeth = self.getSTable().FindMethod.FindMethod(tc, value, "Str", 0);
- RakudoObject strVal = strMeth.getSTable().Invoke.Invoke(tc, strMeth,
+ RakudoObject strMeth = self.getSTable().FindMethod(tc, value, "Str", 0);
+ RakudoObject strVal = strMeth.getSTable().Invoke(tc, strMeth,
CaptureHelper.FormWith( new RakudoObject[] { value } ));
System.out.print(Ops.unbox_str(null, strVal));
}
@@ -3,7 +3,7 @@
import Rakudo.Metamodel.RakudoObject;
import Rakudo.Runtime.ThreadContext;
-public interface IFindMethod {
- public RakudoObject FindMethod(
+public interface ISpecialFindMethod {
+ public RakudoObject SpecialFindMethod(
ThreadContext tc, RakudoObject ro, String s, int i);
}
@@ -4,7 +4,7 @@
import java.util.HashMap;
import java.util.Iterator;
-import Rakudo.Metamodel.IFindMethod;
+import Rakudo.Metamodel.ISpecialFindMethod;
import Rakudo.Metamodel.KnowHOW.KnowHOWREPR;
import Rakudo.Metamodel.RakudoObject;
import Rakudo.Metamodel.Representation;
@@ -177,9 +177,9 @@ public RakudoObject Invoke(ThreadContext tc, RakudoObject ignored, RakudoObject
// And put a fake FindMethod in there that just looks in the
// dictionary.
- KnowHOWHOW.getSTable().FindMethod = new IFindMethod()
- { // an anonymous class
- public RakudoObject FindMethod(ThreadContext tc, RakudoObject obj, String name, int hint)
+ KnowHOWHOW.getSTable().SpecialFindMethod = new ISpecialFindMethod() // C# has a => (lambda)
+ {
+ public RakudoObject SpecialFindMethod(ThreadContext tc, RakudoObject obj, String name, int hint)
{
HashMap<String, RakudoObject> mTable = ((KnowHOWREPR.KnowHOWInstance)obj).Methods;
if (mTable.containsKey(name))
@@ -263,23 +263,23 @@ private void ComputeSlotAllocation(ThreadContext tc, RakudoObject WHAT)
{
// Get attributes and iterate over them.
RakudoObject HOW = currentClass.getSTable().HOW;
- RakudoObject attributesMeth = HOW.getSTable().FindMethod.FindMethod(tc, HOW, "attributes", Hints.NO_HINT);
+ RakudoObject attributesMeth = HOW.getSTable().FindMethod(tc, HOW, "attributes", Hints.NO_HINT);
HashMap<String, RakudoObject> localBoxInt1 = new HashMap<String, RakudoObject>();
localBoxInt1.put("local", Ops.box_int(tc, 1, tc.DefaultBoolBoxType));
- RakudoObject attributes = attributesMeth.getSTable().Invoke.Invoke(tc, attributesMeth, CaptureHelper.FormWith(
+ RakudoObject attributes = attributesMeth.getSTable().Invoke(tc, attributesMeth, CaptureHelper.FormWith(
new RakudoObject[] { HOW, currentClass },
localBoxInt1)); // new HashMap<String, RakudoObject>() { { "local", Ops.box_int(tc, 1, tc.DefaultBoolBoxType) } }));
- RakudoObject attributesElemsMeth = attributes.getSTable().FindMethod.FindMethod(tc, attributes, "elems", Hints.NO_HINT);
- int attributesElems = Ops.unbox_int(tc, attributesElemsMeth.getSTable().Invoke.Invoke(tc, attributesElemsMeth,
+ RakudoObject attributesElemsMeth = attributes.getSTable().FindMethod(tc, attributes, "elems", Hints.NO_HINT);
+ int attributesElems = Ops.unbox_int(tc, attributesElemsMeth.getSTable().Invoke(tc, attributesElemsMeth,
CaptureHelper.FormWith(new RakudoObject[] { attributes })));
- RakudoObject attrAtPosMeth = attributes.getSTable().FindMethod.FindMethod(tc, attributes, "at_pos", Hints.NO_HINT);
+ RakudoObject attrAtPosMeth = attributes.getSTable().FindMethod(tc, attributes, "at_pos", Hints.NO_HINT);
for (int i = 0; i < attributesElems; i++)
{
// Get the attribute, then get its name.
- RakudoObject attr = attrAtPosMeth.getSTable().Invoke.Invoke(tc, attrAtPosMeth, CaptureHelper.FormWith(
+ RakudoObject attr = attrAtPosMeth.getSTable().Invoke(tc, attrAtPosMeth, CaptureHelper.FormWith(
new RakudoObject[] { attributes, Ops.box_int(tc, i, tc.DefaultIntBoxType) }));
- RakudoObject nameMeth = attr.getSTable().FindMethod.FindMethod(tc, attr, "name", Hints.NO_HINT);
- String name = Ops.unbox_str(tc, attr.getSTable().Invoke.Invoke(tc, nameMeth, CaptureHelper.FormWith(
+ RakudoObject nameMeth = attr.getSTable().FindMethod(tc, attr, "name", Hints.NO_HINT);
+ String name = Ops.unbox_str(tc, attr.getSTable().Invoke(tc, nameMeth, CaptureHelper.FormWith(
new RakudoObject[] { attr })));
// Allocate a slot.
@@ -290,15 +290,15 @@ private void ComputeSlotAllocation(ThreadContext tc, RakudoObject WHAT)
}
// Find the next parent(s).
- RakudoObject parentsMeth = HOW.getSTable().FindMethod.FindMethod(tc, HOW, "parents", Hints.NO_HINT);
+ RakudoObject parentsMeth = HOW.getSTable().FindMethod(tc, HOW, "parents", Hints.NO_HINT);
HashMap<String,RakudoObject> localBoxInt2 = new HashMap<String,RakudoObject>();
localBoxInt2.put("local", Ops.box_int(tc, 1, tc.DefaultBoolBoxType));
- RakudoObject parents = parentsMeth.getSTable().Invoke.Invoke(tc, parentsMeth, CaptureHelper.FormWith(
+ RakudoObject parents = parentsMeth.getSTable().Invoke(tc, parentsMeth, CaptureHelper.FormWith(
new RakudoObject[] { HOW, currentClass },
localBoxInt2)); // new HashMap<String,RakudoObject>() { { "local", Ops.box_int(tc, 1, tc.DefaultBoolBoxType) } }));
// Check how many parents we have.
- RakudoObject parentElemsMeth = parents.getSTable().FindMethod.FindMethod(tc, parents, "elems", Hints.NO_HINT);
- int parentElems = Ops.unbox_int(tc, parentElemsMeth.getSTable().Invoke.Invoke(tc, parentElemsMeth,
+ RakudoObject parentElemsMeth = parents.getSTable().FindMethod(tc, parents, "elems", Hints.NO_HINT);
+ int parentElems = Ops.unbox_int(tc, parentElemsMeth.getSTable().Invoke(tc, parentElemsMeth,
CaptureHelper.FormWith(new RakudoObject[] { parents })));
if (parentElems == 0)
{
@@ -315,8 +315,8 @@ else if (parentElems > 1)
else
{
// Just one. Get next parent.
- RakudoObject atPosMeth = parents.getSTable().FindMethod.FindMethod(tc, parents, "at_pos", Hints.NO_HINT);
- currentClass = atPosMeth.getSTable().Invoke.Invoke(tc, atPosMeth, CaptureHelper.FormWith(
+ RakudoObject atPosMeth = parents.getSTable().FindMethod(tc, parents, "at_pos", Hints.NO_HINT);
+ currentClass = atPosMeth.getSTable().Invoke(tc, atPosMeth, CaptureHelper.FormWith(
new RakudoObject[] { parents, Ops.box_int(tc, 0, tc.DefaultIntBoxType) }));
}
}
@@ -106,7 +106,7 @@ public RakudoObject type_object_for(ThreadContext tc, RakudoObject metaPackage)
// Also twiddle the Shared Table's Invoke to invoke the contained
// function.
- sharedTable.Invoke = new IFunc_Body() { // C# has a lambda
+ sharedTable.SpecialInvoke = new IFunc_Body() { // C# has a lambda
public RakudoObject Invoke(ThreadContext tci, RakudoObject methObj, RakudoObject capture)
{
return ((RakudoCodeRef.Instance)methObj).Body.Invoke(tci, methObj, capture);
Oops, something went wrong.

0 comments on commit b3bdc96

Please sign in to comment.