use of st.gravel.support.compiler.ast.BlockNode in project gravel by gravel-st.
the class IntermediateNodeRewriter method produce_whileTrue_.
public WhileTrueNode produce_whileTrue_(final Expression _testExpr, final Expression _loopExpr) {
final BlockNode _testBlockNode;
final BlockNode _loopBlockNode;
if (!_testExpr.isBlockNode()) {
return null;
}
if (!_loopExpr.isBlockNode()) {
return null;
}
_testBlockNode = ((BlockNode) _testExpr);
_loopBlockNode = ((BlockNode) _loopExpr);
return WhileTrueNode.factory.testSequence_doSequence_(((SequenceNode) this.visit_(_testBlockNode.body())), ((SequenceNode) this.visit_(_loopBlockNode.body())));
}
use of st.gravel.support.compiler.ast.BlockNode in project gravel by gravel-st.
the class IntermediateNodeRewriter method produce_to_by_do_.
public ToDoNode produce_to_by_do_(final Expression _start, final Expression _stop, final Expression _step, final Expression _loopExpr) {
final BlockNode _loopBlockNode;
if (!_loopExpr.isBlockNode()) {
return null;
}
if (!_step.isIntegerLiteralNode()) {
return null;
}
_loopBlockNode = ((BlockNode) _loopExpr);
return ToDoNode.factory.start_stop_step_counterName_doSequence_(((Expression) this.visit_(_start)), ((Expression) this.visit_(_stop)), ((Expression) this.visit_(_step)), _loopBlockNode.arguments()[0].name(), ((SequenceNode) this.visit_(_loopBlockNode.body())));
}
use of st.gravel.support.compiler.ast.BlockNode in project gravel by gravel-st.
the class IntermediateNodeRewriter method produce_ifTrue_ifFalse_.
public IfTrueIfFalseNode produce_ifTrue_ifFalse_(final Node _receiver, final Expression _trueExpr, final Expression _falseExpr) {
final BlockNode _trueBlockNode;
final BlockNode _falseBlockNode;
if (!_trueExpr.isBlockNode()) {
return null;
}
if (!_falseExpr.isBlockNode()) {
return null;
}
_trueBlockNode = ((BlockNode) _trueExpr);
_falseBlockNode = ((BlockNode) _falseExpr);
return IfTrueIfFalseNode.factory.test_trueSequence_falseSequence_returnType_(((Expression) this.visit_(_receiver)), ((SequenceNode) this.visit_(_trueBlockNode.body())), ((SequenceNode) this.visit_(_falseBlockNode.body())), TypeOrNode.factory.left_right_(_trueBlockNode.returnType(), _falseBlockNode.returnType()));
}
use of st.gravel.support.compiler.ast.BlockNode in project gravel by gravel-st.
the class JVMMethodCompiler method produceBlockInlineMessageSend_.
public JVMMethodCompiler produceBlockInlineMessageSend_(final MessageNode _messageNode) {
final st.gravel.core.Symbol _selector;
final String[][] _blockSendConstants;
final int[] _passedNumArgs;
final JVMVariable[][] _argumentsToCopy;
_argumentsToCopy = new JVMVariable[1][];
_blockSendConstants = new String[1][];
_passedNumArgs = new int[1];
_blockSendConstants[0] = new String[] {};
_argumentsToCopy[0] = new JVMVariable[] {};
_passedNumArgs[0] = 0;
for (final Node _arg : _messageNode.arguments()) {
if (_arg.isBlockNode()) {
final BlockNode _blockNode;
final JVMVariable[] _nCopiedVariables;
_blockNode = ((BlockNode) _arg);
_nCopiedVariables = JVMMethodCompiler.this.copiedVariablesForBlockNode_(_blockNode);
for (final JVMVariable _each : _nCopiedVariables) {
if (!st.gravel.support.jvm.ArrayExtensions.includes_(_argumentsToCopy[0], _each)) {
_argumentsToCopy[0] = st.gravel.support.jvm.ArrayExtensions.copyWith_(_argumentsToCopy[0], _each);
}
}
_blockSendConstants[0] = st.gravel.support.jvm.ArrayExtensions.copyWith_(_blockSendConstants[0], JVMMethodCompiler.this.addASTConstant_(BlockSendArgument.factory.blockNode_copiedVariables_(_blockNode, _nCopiedVariables)));
} else {
_passedNumArgs[0] = ((_passedNumArgs[0]) + 1);
JVMMethodCompiler.this.visit_(_arg);
JVMMethodCompiler.this.ensureCast_(JVMDynamicObjectType.factory.basicNew());
_blockSendConstants[0] = st.gravel.support.jvm.ArrayExtensions.copyWith_(_blockSendConstants[0], null);
}
}
for (final JVMVariable _each : _argumentsToCopy[0]) {
JVMMethodCompiler.this.produceVarRead_(_each.varName());
JVMMethodCompiler.this.ensureCast_(_each.type());
}
_selector = st.gravel.core.Symbol.value(_messageNode.selector());
this.emit_(DynamicLiteralBlockMessageSend.factory.functionName_numArgs_blockSendConstants_constantOwner_copiedArguments_(_parent.selectorConverter().selectorAsFunctionName_(_selector), ((_passedNumArgs[0]) + _argumentsToCopy[0].length), _blockSendConstants[0], _parent.ownerType(), st.gravel.support.jvm.ArrayExtensions.collect_(_argumentsToCopy[0], ((st.gravel.support.jvm.Block1<String, JVMVariable>) (new st.gravel.support.jvm.Block1<String, JVMVariable>() {
@Override
public String value_(final JVMVariable _each) {
return (String) _each.varName();
}
})))));
return this;
}
use of st.gravel.support.compiler.ast.BlockNode in project gravel by gravel-st.
the class NonLocalReturnRewriter method visitBlockNode_.
@Override
public BlockNode visitBlockNode_(final BlockNode _anObject) {
final boolean _old;
final BlockNode _bn;
_old = _isInBlockNode;
_isInBlockNode = true;
_bn = super.visitBlockNode_(_anObject);
_isInBlockNode = _old;
return _bn;
}
Aggregations