Skip to content

Commit bdf78bd

Browse files
author
Adam Hrbac
committed
Add final to PGenerator methods
1 parent 00f35be commit bdf78bd

File tree

1 file changed

+23
-17
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator

1 file changed

+23
-17
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/generator/PGenerator.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public class PGenerator extends PythonBuiltinObject {
6464
// running means it is currently on the stack, not just started
6565
private boolean running;
6666
private final boolean isCoroutine;
67+
private final boolean isAsyncGen;
6768

6869
// An explicit isIterableCoroutine argument is needed for iterable coroutines (generally created
6970
// via types.coroutine)
@@ -91,9 +92,10 @@ protected PGenerator(PythonLanguage lang, TruffleString name, TruffleString qual
9192
this.bytecodeRootNode = rootNode;
9293
this.frameInfo = (FrameInfo) rootNode.getFrameDescriptor().getInfo();
9394
this.isCoroutine = isIterableCoroutine || cls == PythonBuiltinClassType.PCoroutine;
95+
this.isAsyncGen = cls == PythonBuiltinClassType.PAsyncGenerator;
9496
}
9597

96-
public void handleResult(PythonLanguage language, GeneratorYieldResult result) {
98+
public final void handleResult(PythonLanguage language, GeneratorYieldResult result) {
9799
currentCallTarget = result.resumeBci;
98100
if (callTargets[currentCallTarget] == null) {
99101
CompilerDirectives.transferToInterpreterAndInvalidate();
@@ -107,11 +109,11 @@ public void handleResult(PythonLanguage language, GeneratorYieldResult result) {
107109
* a generator call target returns through a yield, the generator should be updated with the
108110
* next yield index to use via {@link #handleResult}
109111
*/
110-
public RootCallTarget getCurrentCallTarget() {
112+
public final RootCallTarget getCurrentCallTarget() {
111113
return callTargets[currentCallTarget];
112114
}
113115

114-
public Object getYieldFrom() {
116+
public final Object getYieldFrom() {
115117
if (running || finished) {
116118
return null;
117119
}
@@ -122,11 +124,11 @@ private PBytecodeGeneratorRootNode getCurrentRootNode() {
122124
return (PBytecodeGeneratorRootNode) getCurrentCallTarget().getRootNode();
123125
}
124126

125-
public boolean isStarted() {
127+
public final boolean isStarted() {
126128
return currentCallTarget != 0 && !running;
127129
}
128130

129-
public int getBci() {
131+
public final int getBci() {
130132
if (!isStarted()) {
131133
return -1;
132134
} else if (finished) {
@@ -136,24 +138,24 @@ public int getBci() {
136138
}
137139
}
138140

139-
public Object[] getArguments() {
141+
public final Object[] getArguments() {
140142
return arguments;
141143
}
142144

143-
public boolean isFinished() {
145+
public final boolean isFinished() {
144146
return finished;
145147
}
146148

147-
public void markAsFinished() {
149+
public final void markAsFinished() {
148150
finished = true;
149151
}
150152

151153
@Override
152-
public String toString() {
154+
public final String toString() {
153155
return "<generator object " + name + " at " + hashCode() + ">";
154156
}
155157

156-
public PCode getOrCreateCode(Node inliningTarget, InlinedConditionProfile hasCodeProfile, PythonObjectFactory factory) {
158+
public final PCode getOrCreateCode(Node inliningTarget, InlinedConditionProfile hasCodeProfile, PythonObjectFactory factory) {
157159
if (hasCodeProfile.profile(inliningTarget, code == null)) {
158160
RootCallTarget callTarget;
159161
callTarget = bytecodeRootNode.getCallTarget();
@@ -162,32 +164,36 @@ public PCode getOrCreateCode(Node inliningTarget, InlinedConditionProfile hasCod
162164
return code;
163165
}
164166

165-
public boolean isRunning() {
167+
public final boolean isRunning() {
166168
return running;
167169
}
168170

169-
public void setRunning(boolean running) {
171+
public final void setRunning(boolean running) {
170172
assert !running || !this.running : "Attempted to set an already running generator as running";
171173
this.running = running;
172174
}
173175

174-
public TruffleString getName() {
176+
public final TruffleString getName() {
175177
return name;
176178
}
177179

178-
public void setName(TruffleString name) {
180+
public final void setName(TruffleString name) {
179181
this.name = name;
180182
}
181183

182-
public TruffleString getQualname() {
184+
public final TruffleString getQualname() {
183185
return qualname;
184186
}
185187

186-
public void setQualname(TruffleString qualname) {
188+
public final void setQualname(TruffleString qualname) {
187189
this.qualname = qualname;
188190
}
189191

190-
public boolean isCoroutine() {
192+
public final boolean isCoroutine() {
191193
return isCoroutine;
192194
}
195+
196+
public final boolean isAsyncGen() {
197+
return isAsyncGen;
198+
}
193199
}

0 commit comments

Comments
 (0)