Skip to content

Commit

Permalink
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
Original file line number Diff line number Diff line change
@@ -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());

1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/ir/persistence/IRWriter.java
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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);

@@ -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() {
10 changes: 10 additions & 0 deletions core/src/main/java/org/jruby/parser/StaticScopeFactory.java
Original file line number Diff line number Diff line change
@@ -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);
@@ -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;
}

0 comments on commit 50bb31d

Please sign in to comment.