Skip to content

Commit b051ece

Browse files
committed
Cloning of container lexicals (state to come).
1 parent bb9f52a commit b051ece

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

src/vm/jvm/runtime/org/perl6/nqp/runtime/CallFrame.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,20 @@ public CallFrame(ThreadContext tc, CodeRef cr) {
110110
}
111111

112112
// Set up lexical storage.
113-
if (sci.oLexicalNames != null)
114-
this.oLex = sci.oLexStatic.clone();
113+
if (sci.oLexicalNames != null) {
114+
int numoLex = sci.oLexStatic.length;
115+
this.oLex = new SixModelObject[numoLex];
116+
for (int i = 0; i < numoLex; i++) {
117+
switch (sci.oLexStaticFlags[i]) {
118+
case 0:
119+
this.oLex[i] = sci.oLexStatic[i];
120+
break;
121+
default:
122+
this.oLex[i] = sci.oLexStatic[i].clone(tc);
123+
break;
124+
}
125+
}
126+
}
115127
if (sci.iLexicalNames != null)
116128
this.iLex = new long[sci.iLexicalNames.length];
117129
if (sci.nLexicalNames != null)

src/vm/jvm/runtime/org/perl6/nqp/runtime/CompilationUnit.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void setLexValues(ThreadContext tc, String uniqueId, String toParse) {
143143
if (idx == null)
144144
new RuntimeException("Invalid lexical name '" + lexName + "' in static lexical installation");
145145
cr.staticInfo.oLexStatic[idx] = tc.gc.scs.get(handle).root_objects.get(scIdx);
146-
/* XXX Process flags. */
146+
cr.staticInfo.oLexStaticFlags[idx] = (byte)flags;
147147
}
148148
}
149149

src/vm/jvm/runtime/org/perl6/nqp/runtime/StaticCodeInfo.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public class StaticCodeInfo implements Cloneable {
4141
*/
4242
public SixModelObject[] oLexStatic;
4343

44+
/**
45+
* Flags for each static lexical usage.
46+
*/
47+
public byte[] oLexStaticFlags;
48+
4449
/**
4550
* Names of the lexicals we have of each of the base types.
4651
*/
@@ -130,15 +135,19 @@ public StaticCodeInfo(CompilationUnit compUnit, MethodHandle mh,
130135
this.sLexicalNames = sLexicalNames;
131136
this.handlers = handlers;
132137
this.staticCode = staticCode;
133-
if (oLexicalNames != null)
138+
if (oLexicalNames != null) {
134139
this.oLexStatic = new SixModelObject[oLexicalNames.length];
140+
this.oLexStaticFlags = new byte[oLexicalNames.length];
141+
}
135142
}
136143

137144
public StaticCodeInfo clone() {
138145
try {
139146
StaticCodeInfo result = (StaticCodeInfo)super.clone();
140-
if (result.oLexStatic != null)
147+
if (result.oLexStatic != null) {
141148
result.oLexStatic = result.oLexStatic.clone();
149+
result.oLexStaticFlags = result.oLexStaticFlags.clone();
150+
}
142151
return result;
143152
}
144153
catch (Exception e) {

0 commit comments

Comments
 (0)