Skip to content

Commit

Permalink
Fallout from #4186. JRuby AOT and IR persistence needs to persist the…
Browse files Browse the repository at this point in the history
… new

fistKeywordIndex field in StaticScope.
  • Loading branch information
enebo committed Sep 28, 2016
1 parent 18800ed commit 50bb31d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/persistence/IRReader.java
Expand Up @@ -141,7 +141,7 @@ private static Map<String, Integer> decodeScopeLabelIndices(IRReaderDecoder deco
}

private static StaticScope decodeStaticScope(IRReaderDecoder decoder, StaticScope parentScope) {
StaticScope scope = StaticScopeFactory.newStaticScope(parentScope, decoder.decodeStaticScopeType(), decoder.decodeStringArray());
StaticScope scope = StaticScopeFactory.newStaticScope(parentScope, decoder.decodeStaticScopeType(), decoder.decodeStringArray(), decoder.decodeInt());

scope.setSignature(decoder.decodeSignature());

Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/ir/persistence/IRWriter.java
Expand Up @@ -123,6 +123,7 @@ private static void persistScopeLabelIndices(IRScope scope, IRWriterEncoder file
private static void persistStaticScope(IRWriterEncoder file, StaticScope staticScope) {
file.encode(staticScope.getType());
file.encode(staticScope.getVariables());
file.encode(staticScope.getFirstKeywordIndex());
file.encode(staticScope.getSignature());
}
}
12 changes: 11 additions & 1 deletion core/src/main/java/org/jruby/parser/StaticScope.java
Expand Up @@ -142,7 +142,7 @@ protected StaticScope(Type type, StaticScope enclosingScope) {
* @param enclosingScope the lexically containing scope.
* @param names The list of interned String variable names.
*/
protected StaticScope(Type type, StaticScope enclosingScope, String[] names) {
protected StaticScope(Type type, StaticScope enclosingScope, String[] names, int firstKeywordIndex) {
assert names != null : "names is not null";
assert namesAreInterned(names);

Expand All @@ -152,6 +152,16 @@ protected StaticScope(Type type, StaticScope enclosingScope, String[] names) {
this.irScope = null;
this.isBlockOrEval = (type != Type.LOCAL);
this.isArgumentScope = !isBlockOrEval;
this.firstKeywordIndex = firstKeywordIndex;
}

@Deprecated
protected StaticScope(Type type, StaticScope enclosingScope, String[] names) {
this(type, enclosingScope, names, -1);
}

public int getFirstKeywordIndex() {
return firstKeywordIndex;
}

public IRScope getIRScope() {
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/java/org/jruby/parser/StaticScopeFactory.java
Expand Up @@ -51,6 +51,7 @@ public static StaticScope newIRBlockScope(StaticScope parent) {
return new StaticScope(StaticScope.Type.BLOCK, parent);
}

@Deprecated
public static StaticScope newStaticScope(StaticScope parent, StaticScope.Type type, String[] names) {
if(names == null) {
return new StaticScope(type, parent);
Expand All @@ -59,6 +60,15 @@ public static StaticScope newStaticScope(StaticScope parent, StaticScope.Type ty
}
}

public static StaticScope newStaticScope(StaticScope parent, StaticScope.Type type, String[] names, int keywordArgIndex) {
if(names == null) {
return new StaticScope(type, parent);
} else {
return new StaticScope(type, parent, names, keywordArgIndex);
}
}


public StaticScope getDummyScope() {
return dummyScope;
}
Expand Down

0 comments on commit 50bb31d

Please sign in to comment.