From 149e7e01606cdd6fd0de28fe678a53230d00ad4e Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Thu, 20 Oct 2016 15:15:04 +0200 Subject: [PATCH 1/3] Code indentation --- .../runtime/Rakudo/Metamodel/SharedTable.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/java/runtime/Rakudo/Metamodel/SharedTable.java b/java/runtime/Rakudo/Metamodel/SharedTable.java index f22b9e6..2c6db69 100644 --- a/java/runtime/Rakudo/Metamodel/SharedTable.java +++ b/java/runtime/Rakudo/Metamodel/SharedTable.java @@ -27,7 +27,7 @@ public final class SharedTable // C# has public sealed public RakudoObject HOW; /// - /// The type-object. If we do $obj.WHAT then it will refer to a + /// The type-object. If we do $obj.WHAT then it will refer to a /// getting of this field. /// public RakudoObject WHAT; @@ -71,7 +71,10 @@ public RakudoObject FindMethod(ThreadContext tc, RakudoObject obj, String name, // Otherwise, try method cache. else if (MethodCache != null && MethodCache.containsKey(name)) - { cachedMethod = MethodCache.get(name); return cachedMethod; } + { + cachedMethod = MethodCache.get(name); + return cachedMethod; + } // Otherwise, go ask the meta-object. else @@ -84,7 +87,11 @@ else if (MethodCache != null && MethodCache.containsKey(name)) tc, HOW, "find_method", Hints.NO_HINT); // Call it. - RakudoObject capture = CaptureHelper.FormWith(new RakudoObject[] { HOW, obj, Ops.box_str(tc, name, tc.DefaultStrBoxType) }); + RakudoObject capture = CaptureHelper.FormWith(new RakudoObject[] { + HOW, + obj, + Ops.box_str(tc, name, tc.DefaultStrBoxType) + } ); return method.getSTable().Invoke(tc, method, capture); } } @@ -111,7 +118,12 @@ public RakudoObject Invoke(ThreadContext threadContext, RakudoObject method, Rak if (SpecialInvoke != null) return SpecialInvoke.Invoke(threadContext, method, capture); SharedTable sharedTable = method.getSTable(); - RakudoObject invokable = sharedTable.CachedInvoke; if (invokable == null) { invokable = sharedTable.CachedInvoke = method.getSTable().FindMethod(threadContext, method, "postcircumfix:<( )>", Hints.NO_HINT); } + RakudoObject invokable = sharedTable.CachedInvoke; + if (invokable == null) + { invokable + = sharedTable.CachedInvoke + = method.getSTable().FindMethod(threadContext, method, "postcircumfix:<( )>", Hints.NO_HINT); + } return invokable.getSTable().Invoke(threadContext, method, capture); } @@ -184,4 +196,3 @@ public long getTypeCacheID () { private static long TypeCacheIDSource = 4; } - From fa0596eaa94c7e757016918782c6d4a7b87a2273 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Thu, 20 Oct 2016 15:41:38 +0200 Subject: [PATCH 2/3] GetPositional cannot get a negative positional index. --- java/runtime/Rakudo/Runtime/CaptureHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/runtime/Rakudo/Runtime/CaptureHelper.java b/java/runtime/Rakudo/Runtime/CaptureHelper.java index 2bef22d..076cdf5 100644 --- a/java/runtime/Rakudo/Runtime/CaptureHelper.java +++ b/java/runtime/Rakudo/Runtime/CaptureHelper.java @@ -97,7 +97,7 @@ public static RakudoObject GetPositional(RakudoObject capture, int pos) if (nativeCapture != null) { RakudoObject[] possies = nativeCapture.Positionals; - if (possies != null && pos < possies.length) + if (possies != null && pos < possies.length && pos >= 0) return possies[pos]; else return null; From d2345bad83d0f26694082fbe582518b6259e6f14 Mon Sep 17 00:00:00 2001 From: Luca Ferrari Date: Thu, 20 Oct 2016 15:48:04 +0200 Subject: [PATCH 3/3] Code style. Align braces. --- .../MultiDispatch/LexicalCandidateFinder.java | 6 +++--- .../Runtime/MultiDispatch/MultiDispatcher.java | 10 +++++----- java/runtime/Rakudo/Runtime/Ops.java | 16 +++++++++------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/java/runtime/Rakudo/Runtime/MultiDispatch/LexicalCandidateFinder.java b/java/runtime/Rakudo/Runtime/MultiDispatch/LexicalCandidateFinder.java index 54f5022..d308894 100644 --- a/java/runtime/Rakudo/Runtime/MultiDispatch/LexicalCandidateFinder.java +++ b/java/runtime/Rakudo/Runtime/MultiDispatch/LexicalCandidateFinder.java @@ -31,12 +31,12 @@ public static ArrayList FindCandidates(Context callerSco break; // Any candidates here? - if (curScope.LexPad.SlotMapping != null && curScope.LexPad.SlotMapping.containsKey(candidateHolderName)) { + if (curScope.LexPad.SlotMapping != null && curScope.LexPad.SlotMapping.containsKey(candidateHolderName)) + { Integer index = curScope.LexPad.SlotMapping.get(candidateHolderName); P6list.Instance p6listInstance = (P6list.Instance)curScope.LexPad.Storage[index]; - for (RakudoObject candidate : p6listInstance.Storage) { + for (RakudoObject candidate : p6listInstance.Storage) result.add((RakudoCodeRef.Instance)candidate); - } } } while (curScope != protoScope); return result; diff --git a/java/runtime/Rakudo/Runtime/MultiDispatch/MultiDispatcher.java b/java/runtime/Rakudo/Runtime/MultiDispatch/MultiDispatcher.java index f61559b..e114438 100644 --- a/java/runtime/Rakudo/Runtime/MultiDispatch/MultiDispatcher.java +++ b/java/runtime/Rakudo/Runtime/MultiDispatch/MultiDispatcher.java @@ -93,7 +93,7 @@ else if (possiblesList.size() > 1) continue; } } - + /* Check if it's admissible by arity. */ int numArgs = nativeCapture.Positionals.length; if (numArgs < candidate.Sig.NumRequiredPositionals || @@ -142,9 +142,9 @@ else if (possiblesList.size() > 1) private static ArrayList candidateSort(RakudoObject[] unsorted) { ArrayList sorted = new ArrayList(); - for (RakudoObject obj : unsorted) { + for (RakudoObject obj : unsorted) sorted.add(obj); - } + sorted.add(null); // XXX does this actually sort? return sorted; } @@ -171,7 +171,8 @@ else if (a.Sig.NumRequiredPositionals == b.Sig.NumRequiredPositionals) return 0; /* Analyse each parameter in the two candidates. */ - for (i = 0; i < TypesToCheck; i++) { + for (i = 0; i < TypesToCheck; i++) + { RakudoObject TypeObjA = a.Sig.Parameters[i].Type; RakudoObject TypeObjB = b.Sig.Parameters[i].Type; if (TypeObjA == TypeObjB) @@ -216,4 +217,3 @@ public static boolean IsNarrowerType(RakudoObject A, RakudoObject B) return true; } } - diff --git a/java/runtime/Rakudo/Runtime/Ops.java b/java/runtime/Rakudo/Runtime/Ops.java index 5007b69..a1a1152 100644 --- a/java/runtime/Rakudo/Runtime/Ops.java +++ b/java/runtime/Rakudo/Runtime/Ops.java @@ -1116,13 +1116,13 @@ public static RakudoObject load_module(ThreadContext tc, RakudoObject path) // Load the assembly and grab the first type in it. //var assembly = AppDomain.CurrentDomain.Load(Ops.unbox_str(tc, path)); //var class = Assembly.GetTypes()[0]; - + // Call the Load method, passing along the current thread context // and the setting to use with it. What's returned is what the main // body of the compilation unit evaluates to. //var method = class.GetMethod("Load", BindingFlags.NonPublic | BindingFlags.Static); if (true) // sneak by the "unreachable code" monster - throw new UnsupportedOperationException("load_module NYI"); + throw new UnsupportedOperationException("load_module NYI"); return (RakudoObject)null; //return (RakudoObject)method.Invoke.Invoke(null, new Object[] { tc, tc.Domain.Setting }); } @@ -1136,7 +1136,8 @@ public static RakudoObject get_lex(ThreadContext tc, String name) { Context curContext = tc.CurrentContext; while (curContext != null) { - if (curContext.LexPad.SlotMapping.containsKey(name)) { + if (curContext.LexPad.SlotMapping.containsKey(name)) + { int index = curContext.LexPad.SlotMapping.get(name); return curContext.LexPad.Storage[index]; } @@ -1157,7 +1158,8 @@ public static RakudoObject get_lex_skip_current(ThreadContext tc, String name) Context curContext = tc.CurrentContext.Outer; while (curContext != null) { - if (curContext.LexPad.SlotMapping.containsKey(name)) { + if (curContext.LexPad.SlotMapping.containsKey(name)) + { int index = curContext.LexPad.SlotMapping.get(name); return curContext.LexPad.Storage[index]; } @@ -1179,7 +1181,7 @@ public static RakudoObject bind_lex(ThreadContext tc, String name, RakudoObject { if (curContext.LexPad.SlotMapping.containsKey(name)) { - int index = curContext.LexPad.SlotMapping.get(name); + int index = curContext.LexPad.SlotMapping.get(name); curContext.LexPad.Storage[index] = value; return value; } @@ -1198,7 +1200,8 @@ public static RakudoObject get_dynamic(ThreadContext tc, String name) { Context curContext = tc.CurrentContext; while (curContext != null) { - if (curContext.LexPad.SlotMapping.containsKey(name)) { + if (curContext.LexPad.SlotMapping.containsKey(name)) + { int index = curContext.LexPad.SlotMapping.get(name); return curContext.LexPad.Storage[index]; } @@ -1230,4 +1233,3 @@ public static RakudoObject bind_dynamic(ThreadContext tc, String name, RakudoObj } } -