Skip to content

Commit 1a12f84

Browse files
committed
Make 'PyFrameObject.f_lineno' writeable.
1 parent 491db14 commit 1a12f84

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/DynamicObjectNativeWrapper.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
137137
import com.oracle.graal.python.nodes.truffle.PythonArithmeticTypes;
138138
import com.oracle.graal.python.nodes.truffle.PythonTypes;
139+
import com.oracle.graal.python.nodes.util.CastToJavaIntNode;
139140
import com.oracle.graal.python.nodes.util.CoerceToIntegerNode;
140141
import com.oracle.graal.python.runtime.PythonContext;
141142
import com.oracle.graal.python.runtime.PythonOptions;
@@ -1164,6 +1165,18 @@ static Object doMemoryview(PMemoryView object, @SuppressWarnings("unused") Pytho
11641165
throw new IllegalStateException("delegate of memoryview object is not native");
11651166
}
11661167

1168+
@Specialization(guards = "eq(F_LINENO, key)")
1169+
static int doFLineno(PFrame object, @SuppressWarnings("unused") PythonNativeWrapper nativeWrapper, @SuppressWarnings("unused") String key, Object value,
1170+
@Cached(value = "createLossy()", uncached = "getLossyUncached()") CastToJavaIntNode castToJavaIntNode) {
1171+
try {
1172+
int lineno = castToJavaIntNode.execute(value);
1173+
object.setLine(lineno);
1174+
return lineno;
1175+
} catch(PException e) {
1176+
return -1;
1177+
}
1178+
}
1179+
11671180
@Specialization(guards = "isGenericCase(object, key)", limit = "1")
11681181
static Object doGeneric(@SuppressWarnings("unused") Object object, DynamicObjectNativeWrapper nativeWrapper, String key, Object value,
11691182
@CachedLibrary("nativeWrapper.createNativeMemberStore()") HashingStorageLibrary lib) throws UnknownIdentifierException {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/frame/PFrame.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ public void setBackref(PFrame.Reference backref) {
214214
this.backref = backref;
215215
}
216216

217+
public void setLine(int line) {
218+
this.line = line;
219+
}
220+
217221
@TruffleBoundary
218222
public int getLine() {
219223
if (line == -2) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/util/CastToJavaIntNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public static CastToJavaIntNode getUncached() {
9393
return CastToJavaIntExactNodeGen.getUncached();
9494
}
9595

96-
public static CastToJavaIntNode createLossyUncached() {
96+
public static CastToJavaIntNode getLossyUncached() {
9797
return CastToJavaIntLossyNodeGen.getUncached();
9898
}
9999

0 commit comments

Comments
 (0)