|
45 | 45 | import java.util.List; |
46 | 46 | import java.util.Set; |
47 | 47 |
|
48 | | -import com.oracle.graal.python.PythonLanguage; |
49 | 48 | import com.oracle.graal.python.builtins.objects.function.Arity; |
50 | 49 | import com.oracle.graal.python.builtins.objects.object.PythonBuiltinObject; |
51 | 50 | import com.oracle.graal.python.builtins.objects.type.LazyPythonClass; |
|
54 | 53 | import com.oracle.graal.python.nodes.argument.ReadKeywordNode; |
55 | 54 | import com.oracle.graal.python.nodes.argument.ReadVarArgsNode; |
56 | 55 | import com.oracle.graal.python.nodes.argument.ReadVarKeywordsNode; |
57 | | -import com.oracle.graal.python.nodes.control.TopLevelExceptionHandler; |
58 | 56 | import com.oracle.graal.python.nodes.frame.FrameSlotIDs; |
59 | 57 | import com.oracle.graal.python.nodes.frame.WriteIdentifierNode; |
60 | 58 | import com.oracle.graal.python.nodes.function.FunctionRootNode; |
61 | 59 | import com.oracle.graal.python.nodes.generator.GeneratorFunctionRootNode; |
62 | | -import com.oracle.graal.python.runtime.PythonContext; |
63 | 60 | import com.oracle.graal.python.runtime.PythonCore; |
64 | | -import com.oracle.graal.python.runtime.PythonParser; |
65 | | -import com.oracle.graal.python.runtime.exception.PException; |
66 | 61 | import com.oracle.truffle.api.CompilerDirectives; |
67 | 62 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; |
68 | 63 | import com.oracle.truffle.api.RootCallTarget; |
69 | 64 | import com.oracle.truffle.api.Truffle; |
70 | 65 | import com.oracle.truffle.api.nodes.Node; |
71 | 66 | import com.oracle.truffle.api.nodes.NodeUtil; |
72 | 67 | import com.oracle.truffle.api.nodes.RootNode; |
73 | | -import com.oracle.truffle.api.source.Source; |
74 | 68 | import com.oracle.truffle.api.source.SourceSection; |
75 | | -import org.graalvm.polyglot.io.ByteSequence; |
76 | 69 |
|
77 | 70 | public final class PCode extends PythonBuiltinObject { |
78 | 71 | private final long FLAG_POS_GENERATOR = 5; |
@@ -314,15 +307,16 @@ private void extractArgStats() { |
314 | 307 | } |
315 | 308 |
|
316 | 309 | @TruffleBoundary |
317 | | - public void extractCodeString(RootNode rootNode) { |
| 310 | + private static byte[] extractCodeString(RootNode rootNode) { |
318 | 311 | RootNode funcRootNode = rootNode; |
319 | 312 | if (rootNode instanceof GeneratorFunctionRootNode) { |
320 | 313 | funcRootNode = ((GeneratorFunctionRootNode) rootNode).getFunctionRootNode(); |
321 | 314 | } |
322 | 315 | SourceSection sourceSection = funcRootNode.getSourceSection(); |
323 | 316 | if (sourceSection != null) { |
324 | | - this.codestring = sourceSection.getCharacters().toString().getBytes(); |
| 317 | + return sourceSection.getCharacters().toString().getBytes(); |
325 | 318 | } |
| 319 | + return null; |
326 | 320 | } |
327 | 321 |
|
328 | 322 | public RootNode getRootNode() { |
@@ -416,7 +410,7 @@ public Object[] getVarnames() { |
416 | 410 |
|
417 | 411 | public byte[] getCodestring() { |
418 | 412 | if (codestring == null && hasRootNode()) { |
419 | | - extractCodeString(getRootNode()); |
| 413 | + this.codestring = extractCodeString(getRootNode()); |
420 | 414 | } |
421 | 415 | return codestring; |
422 | 416 | } |
|
0 commit comments