pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/jruby/jruby/pull/9220.patch

hort) opt, (short) post, rest, (short) kwargs, (short) requiredKwargs, keyRest, keywordArguments); + } + public int getRequiredKeywordForArityCount() { return requiredKwargs > 0 ? 1 : 0; } @@ -210,7 +231,19 @@ public static Signature from(Arity arity) { } public static Signature from(int pre, int opt, int post, int kwargs, int requiredKwargs, Rest rest, int keyRest) { - if (opt == 0 && post == 0 && kwargs == 0 && keyRest == -1) { + return from(pre, opt, rest, post, kwargs, requiredKwargs, keyRest, KeywordArgument.EMPTY_ARRAY); + } + + public static Signature from(int pre, int opt, Rest rest, int post, int kwargs, int requiredKwargs, int keyRest, KeywordArgument[] keywordArguments) { + if (kwargs == 0 && keyRest == -1) { + return positionalOnly(pre, opt, rest, post, kwargs, requiredKwargs, keyRest); + } + + return new Signature(pre, opt, post, rest, kwargs, requiredKwargs, keyRest, keywordArguments); + } + + private static Signature positionalOnly(int pre, int opt, Rest rest, int post, int kwargs, int requiredKwargs, int keyRest) { + if (opt == 0 && post == 0) { switch (pre) { case 0: switch (rest) { @@ -253,9 +286,10 @@ public static Signature from(int pre, int opt, int post, int kwargs, int require } break; } - } else if (opt == 1 && pre == 0 && rest == Rest.NONE && post == 0 && kwargs == 0 && keyRest == -1) { + } else if (opt == 1 && pre == 0 && rest == Rest.NONE && post == 0) { return Signature.ONE_OPT_ARGUMENT; } + return new Signature(pre, opt, post, rest, kwargs, requiredKwargs, keyRest); } @@ -263,8 +297,18 @@ public static Signature from(ArgsNode args) { ArgumentNode restArg = args.getRestArgNode(); Rest rest = restArg != null ? restFromArg(restArg) : Rest.NONE; - return Signature.from(args.getPreCount(), args.getOptionalArgsCount(), args.getPostCount(), - args.getKeywordCount(), args.getRequiredKeywordCount(),rest,args.hasKeyRest() ? args.getKeyRest().getIndex() : -1); + int keywordCount = args.getKeywordCount(); + KeywordArgument[] keywordArguments = keywordArgumentsFromArgs(args); + + return Signature.from( + args.getPreCount(), + args.getOptionalArgsCount(), + rest, + args.getPostCount(), + keywordCount, + args.getRequiredKeywordCount(), + args.hasKeyRest() ? args.getKeyRest().getIndex() : -1, + keywordArguments); } public static Signature from(IterNode iter) { @@ -276,20 +320,48 @@ public static Signature from(IterNode iter) { } private static Rest restFromArg(Node restArg) { - Rest rest; - if (restArg instanceof UnnamedRestArgNode) { - UnnamedRestArgNode anonRest = (UnnamedRestArgNode) restArg; + if (restArg == null) return Rest.NONE; + + if (restArg instanceof UnnamedRestArgNode anonRest) { if (anonRest.isStar()) { - rest = Rest.STAR; + return Rest.STAR; } else { - rest = Rest.ANON; + return Rest.ANON; } } else if (restArg instanceof StarNode) { - rest = Rest.STAR; + return Rest.STAR; } else { - rest = Rest.NORM; + return Rest.NORM; + } + } + + private static KeywordArgument[] keywordArgumentsFromArgs(ArgsNode args) { + int kwargs = args.getKeywordCount(); + if (kwargs == 0) return KeywordArgument.EMPTY_ARRAY; + + var keywordArguments = new ArrayList(); + for (Node keywordArg : args.getKeywords()) { + if (keywordArg instanceof KeywordArgNode kwargNode) { + AssignableNode assignable = kwargNode.getAssignable(); + RubySymbol name; + if (!(assignable instanceof INameNode namedAssign)) { + throw new RuntimeException("unexpected unnamed assignable"); + } + name = namedAssign.getName(); + + if (assignable.getValueNode() != null) { + keywordArguments.add(new KeywordArgument(name.idString(), KeywordArgument.Type.OPTIONAL)); + } else { + keywordArguments.add(new KeywordArgument(name.idString(), KeywordArgument.Type.REQUIRED)); + } + } } - return rest; + + if (args.getKeyRest() instanceof KeywordRestArgNode kwrestArg) { + keywordArguments.add(new KeywordArgument(kwrestArg.getName().idString(), KeywordArgument.Type.REST)); + } + + return keywordArguments.toArray(KeywordArgument[]::new); } public static Signature from(ForNode iter) { pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy