Skip to content

Commit 95ccbfe

Browse files
committed
update doc on StatementNode and ExpressionNode
1 parent aecff76 commit 95ccbfe

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/expression/ExpressionNode.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
import com.oracle.truffle.api.nodes.NodeCost;
5151
import com.oracle.truffle.api.nodes.UnexpectedResultException;
5252

53+
/**
54+
* Base class for all expressions. Expressions always return a value.
55+
*/
5356
@GenerateWrapper
5457
public abstract class ExpressionNode extends PNode {
5558

@@ -119,6 +122,10 @@ public NodeCost getCost() {
119122
}
120123
}
121124

125+
/**
126+
* If expressions appear in a block of statements, they are wrapped in a
127+
* {@link StatementNode} that simply drops the result.
128+
*/
122129
public final StatementNode asStatement() {
123130
return new ExpressionStatementNode(this);
124131
}
@@ -145,6 +152,11 @@ public boolean hasSideEffectAsAnExpression() {
145152
}
146153
}
147154

155+
/**
156+
* Some expressions can have hidden side-effects such as writing to a
157+
* temporary variable. These can be wrapped together with their side
158+
* effecting {@link StatementNode}.
159+
*/
148160
public final ExpressionNode withSideEffect(StatementNode sideEffect) {
149161
return new ExpressionWithSideEffects(this, sideEffect);
150162
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/statement/StatementNode.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
import com.oracle.truffle.api.instrumentation.Tag;
3535

3636
/**
37-
* Base class for most statements, except for FrameSlotNodes.
38-
*
37+
* Base class for all statements. Statements never return a value.
3938
*/
4039
@GenerateWrapper
4140
public abstract class StatementNode extends PNode {

0 commit comments

Comments
 (0)