Skip to content

Commit c428cdf

Browse files
committed
Use anonrest/anonkeyrest/anonblock argument types instead of rest/keyrest/block for desugared ... parameter
1 parent a0e6d65 commit c428cdf

File tree

9 files changed

+15
-29
lines changed

9 files changed

+15
-29
lines changed

spec/truffle/parsing/fixtures/def/argument_descriptors/with_forwarding_operator.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ast: |
1818
flags = 1
1919
isDefSingleton = false
2020
name = "foo"
21-
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
21+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = anonrest), ArgumentDescriptor(name = %forward_kwrest, type = anonkeyrest), ArgumentDescriptor(name = %forward_block, type = anonblock)])
2222
sourceCharIndex = 0
2323
sourceLength = 16
2424
call targets:
@@ -37,7 +37,7 @@ ast: |
3737
polyglotRef = org.truffleruby.RubyLanguage@...
3838
retryProfile = false
3939
returnID = org.truffleruby.language.control.ReturnID@...
40-
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
40+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = anonrest), ArgumentDescriptor(name = %forward_kwrest, type = anonkeyrest), ArgumentDescriptor(name = %forward_block, type = anonblock)])
4141
sourceSection = SourceSection(source=<parse_ast> [1:1 - 2:3], index=0, length=16, characters=def foo(...)\nend)
4242
split = HEURISTIC
4343
children:

spec/truffle/parsing/fixtures/def/arity/with_forwarding_operator.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ast: |
2222
flags = 1
2323
isDefSingleton = false
2424
name = "foo"
25-
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
25+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = anonrest), ArgumentDescriptor(name = %forward_kwrest, type = anonkeyrest), ArgumentDescriptor(name = %forward_block, type = anonblock)])
2626
sourceCharIndex = 0
2727
sourceLength = 16
2828
call targets:
@@ -41,7 +41,7 @@ ast: |
4141
polyglotRef = org.truffleruby.RubyLanguage@...
4242
retryProfile = false
4343
returnID = org.truffleruby.language.control.ReturnID@...
44-
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
44+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = anonrest), ArgumentDescriptor(name = %forward_kwrest, type = anonkeyrest), ArgumentDescriptor(name = %forward_block, type = anonblock)])
4545
sourceSection = SourceSection(source=<parse_ast> [1:1 - 2:3], index=0, length=16, characters=def foo(...)\nend)
4646
split = HEURISTIC
4747
children:

spec/truffle/parsing/fixtures/def/parameters_to_local_variables/with_forwarding_operator.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ast: |
1919
flags = 1
2020
isDefSingleton = false
2121
name = "foo"
22-
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
22+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = anonrest), ArgumentDescriptor(name = %forward_kwrest, type = anonkeyrest), ArgumentDescriptor(name = %forward_block, type = anonblock)])
2323
sourceCharIndex = 0
2424
sourceLength = 16
2525
call targets:
@@ -38,7 +38,7 @@ ast: |
3838
polyglotRef = org.truffleruby.RubyLanguage@...
3939
retryProfile = false
4040
returnID = org.truffleruby.language.control.ReturnID@...
41-
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
41+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = anonrest), ArgumentDescriptor(name = %forward_kwrest, type = anonkeyrest), ArgumentDescriptor(name = %forward_block, type = anonblock)])
4242
sourceSection = SourceSection(source=<parse_ast> [1:1 - 2:3], index=0, length=16, characters=def foo(...)\nend)
4343
split = HEURISTIC
4444
children:

spec/truffle/parsing/fixtures/method_calls/parameter_forwarding/forward_arguments.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ast: |
1414
flags = 1
1515
isDefSingleton = false
1616
name = "foo"
17-
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
17+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = anonrest), ArgumentDescriptor(name = %forward_kwrest, type = anonkeyrest), ArgumentDescriptor(name = %forward_block, type = anonblock)])
1818
sourceCharIndex = 0
1919
sourceLength = 27
2020
call targets:
@@ -33,7 +33,7 @@ ast: |
3333
polyglotRef = org.truffleruby.RubyLanguage@...
3434
retryProfile = false
3535
returnID = org.truffleruby.language.control.ReturnID@...
36-
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
36+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = anonrest), ArgumentDescriptor(name = %forward_kwrest, type = anonkeyrest), ArgumentDescriptor(name = %forward_block, type = anonblock)])
3737
sourceSection = SourceSection(source=<parse_ast> [1:1 - 3:3], index=0, length=27, characters=def foo(...)\n bar(...)\nend)
3838
split = HEURISTIC
3939
children:

spec/truffle/parsing/fixtures/method_calls/super/in_method_body_without_explicit_arguments_when_declared_forward_arguments_parameter.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ast: |
1414
flags = 1
1515
isDefSingleton = false
1616
name = "foo"
17-
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
17+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = anonrest), ArgumentDescriptor(name = %forward_kwrest, type = anonkeyrest), ArgumentDescriptor(name = %forward_block, type = anonblock)])
1818
sourceCharIndex = 0
1919
sourceLength = 24
2020
call targets:
@@ -33,7 +33,7 @@ ast: |
3333
polyglotRef = org.truffleruby.RubyLanguage@...
3434
retryProfile = false
3535
returnID = org.truffleruby.language.control.ReturnID@...
36-
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
36+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 0, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = %forward_rest, type = anonrest), ArgumentDescriptor(name = %forward_kwrest, type = anonkeyrest), ArgumentDescriptor(name = %forward_block, type = anonblock)])
3737
sourceSection = SourceSection(source=<parse_ast> [1:1 - 3:3], index=0, length=24, characters=def foo(...)\n super\nend)
3838
split = HEURISTIC
3939
children:

spec/truffle/parsing/fixtures/method_calls/super/in_method_body_without_explicit_arguments_when_declared_positional_and_forward_arguments_parameter.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ast: |
1414
flags = 1
1515
isDefSingleton = false
1616
name = "foo"
17-
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 1, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = a, type = req), ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
17+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 1, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = a, type = req), ArgumentDescriptor(name = %forward_rest, type = anonrest), ArgumentDescriptor(name = %forward_kwrest, type = anonkeyrest), ArgumentDescriptor(name = %forward_block, type = anonblock)])
1818
sourceCharIndex = 0
1919
sourceLength = 27
2020
call targets:
@@ -33,7 +33,7 @@ ast: |
3333
polyglotRef = org.truffleruby.RubyLanguage@...
3434
retryProfile = false
3535
returnID = org.truffleruby.language.control.ReturnID@...
36-
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 1, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = a, type = req), ArgumentDescriptor(name = %forward_rest, type = rest), ArgumentDescriptor(name = %forward_kwrest, type = keyrest), ArgumentDescriptor(name = %forward_block, type = block)])
36+
sharedMethodInfo = SharedMethodInfo(staticLexicalScope = :: Object, arity = Arity{preRequired = 1, optional = 0, hasRest = true, isImplicitRest = false, postRequired = 0, keywordArguments = [], requiredKeywordArgumentsCount = 0, hasKeywordsRest = true}, originName = foo, blockDepth = 0, parseName = Object#foo, notes = null, argumentDescriptors = [ArgumentDescriptor(name = a, type = req), ArgumentDescriptor(name = %forward_rest, type = anonrest), ArgumentDescriptor(name = %forward_kwrest, type = anonkeyrest), ArgumentDescriptor(name = %forward_block, type = anonblock)])
3737
sourceSection = SourceSection(source=<parse_ast> [1:1 - 3:3], index=0, length=27, characters=def foo(a, ...)\n super\nend)
3838
split = HEURISTIC
3939
children:

src/main/java/org/truffleruby/language/arguments/ArgumentDescriptorUtils.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121

2222
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
2323

24-
import static org.truffleruby.parser.TranslatorEnvironment.DEFAULT_BLOCK_NAME;
25-
import static org.truffleruby.parser.TranslatorEnvironment.FORWARDED_BLOCK_NAME;
26-
import static org.truffleruby.parser.TranslatorEnvironment.FORWARDED_KEYWORD_REST_NAME;
27-
import static org.truffleruby.parser.TranslatorEnvironment.FORWARDED_REST_NAME;
28-
2924
public final class ArgumentDescriptorUtils {
3025

3126
@TruffleBoundary
@@ -57,12 +52,6 @@ private static RubyArray toArray(RubyLanguage language, RubyContext context, Arg
5752
store = new Object[]{ typeSymbol, language.coreSymbols.POW };
5853
} else if (argType == ArgumentType.anonblock) {
5954
store = new Object[]{ typeSymbol, language.coreSymbols.AMPERSAND };
60-
} else if (argType == ArgumentType.rest && name.equals(FORWARDED_REST_NAME)) {
61-
store = new Object[]{ typeSymbol, language.coreSymbols.MULTIPLY };
62-
} else if (argType == ArgumentType.keyrest && name.equals(FORWARDED_KEYWORD_REST_NAME)) {
63-
store = new Object[]{ typeSymbol, language.coreSymbols.POW };
64-
} else if (argType == ArgumentType.block && name.equals(FORWARDED_BLOCK_NAME)) {
65-
store = new Object[]{ typeSymbol, language.coreSymbols.AMPERSAND };
6655
} else if (argType.anonymous || name == null) {
6756
store = new Object[]{ typeSymbol };
6857
} else {

src/main/java/org/truffleruby/parser/TranslatorEnvironment.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ public final class TranslatorEnvironment {
6363
/** local variable name for & parameter caused by desugaring ... parameter (forward-everything) */
6464
public static final String FORWARDED_BLOCK_NAME = Layouts.TEMP_PREFIX + "forward_block";
6565

66-
/** A prefix for duplicated '_' local variables to build unique names */
67-
public static final String UNDERSCORE_PREFIX = "_$";
68-
6966
private final ParseEnvironment parseEnvironment;
7067

7168
private EconomicMap<Object, Integer> nameToIndex = EconomicMap.create();

src/main/java/org/truffleruby/parser/YARPTranslator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3856,9 +3856,9 @@ private ArgumentDescriptor[] parametersNodeToArgumentDescriptors(Nodes.Parameter
38563856
}
38573857
} else if (parametersNode.keyword_rest instanceof Nodes.ForwardingParameterNode) {
38583858
// ... => *, **, &
3859-
descriptors.add(new ArgumentDescriptor(ArgumentType.rest, FORWARDED_REST_NAME));
3860-
descriptors.add(new ArgumentDescriptor(ArgumentType.keyrest, FORWARDED_KEYWORD_REST_NAME));
3861-
descriptors.add(new ArgumentDescriptor(ArgumentType.block, FORWARDED_BLOCK_NAME));
3859+
descriptors.add(new ArgumentDescriptor(ArgumentType.anonrest, FORWARDED_REST_NAME));
3860+
descriptors.add(new ArgumentDescriptor(ArgumentType.anonkeyrest, FORWARDED_KEYWORD_REST_NAME));
3861+
descriptors.add(new ArgumentDescriptor(ArgumentType.anonblock, FORWARDED_BLOCK_NAME));
38623862
} else if (parametersNode.keyword_rest instanceof Nodes.NoKeywordsParameterNode) {
38633863
final var descriptor = new ArgumentDescriptor(ArgumentType.nokey);
38643864
descriptors.add(descriptor);

0 commit comments

Comments
 (0)