use of st.gravel.support.compiler.ast.BlockNode in project gravel by gravel-st.
the class SystemMapping method compileExpression_reference_.
public JVMClass[] compileExpression_reference_(final Node _anExpression, final Reference _aReference) {
final JVMDefinedObjectType _ownerType;
final BlockNode _fieldAccessed;
final BlockInnerClass _aBlockInnerClass;
final BlockNode _intermediate;
final BlockNode _holderized;
final JVMClassCompiler _jvmClassCompiler;
final JVMClass _blockClass;
_intermediate = ((BlockNode) IntermediateNodeRewriter.factory.visit_(BlockNode.factory.expression_(_anExpression)));
_holderized = ((BlockNode) NonLocalTempWritesToHolderConverter.factory.visit_(_intermediate));
_fieldAccessed = ((BlockNode) VariableAccessToFieldAccessConverter.factory.instVars_owner_ownerReference_(new VariableDeclarationNode[] {}, NilLiteralNode.factory.basicNew(), _aReference).visit_(_holderized));
_ownerType = JVMDefinedObjectType.factory.dottedClassName_("Expression$" + _compilerTools.nextExtensionPostfix());
_aBlockInnerClass = BlockInnerClass.factory.ownerType_blockNode_copiedVariables_(_ownerType, _fieldAccessed, new JVMVariable[] {});
_jvmClassCompiler = JVMClassCompiler.factory.classDescriptionNode_systemNode_systemMappingUpdater_isStatic_(null, _systemNode, this.newSystemMappingUpdater(), false);
_jvmClassCompiler.ownerType_(JVMDefinedObjectType.factory.dottedClassName_("ExpressionContainer$" + _compilerTools.nextExtensionPostfix()));
_blockClass = _jvmClassCompiler.compileBlockNoAdd_(_aBlockInnerClass);
return _jvmClassCompiler.withContainerAndExtraClasses_(_blockClass);
}
use of st.gravel.support.compiler.ast.BlockNode in project gravel by gravel-st.
the class Parser method parseBlock.
public BlockNode parseBlock() {
VariableDeclarationNode[] _arguments;
final BlockNode _bn;
TypeNode _returnType;
final int _start;
_start = st.gravel.support.jvm.ReadStreamExtensions.position(_stream);
st.gravel.support.jvm.ReadStreamExtensions.next(_stream);
this.eatWhitespace();
_arguments = new VariableDeclarationNode[] {};
if (st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, ':')) {
boolean _temp1 = true;
while (_temp1) {
Parser.this.eatWhitespace();
_arguments = st.gravel.support.jvm.ArrayExtensions.copyWith_(_arguments, Parser.this.parseVariableDeclaration());
Parser.this.eatWhitespace();
_temp1 = st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, ':');
}
_returnType = Parser.this.parseReturnType();
Parser.this.eatWhitespace();
if (st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, ']')) {
return BlockNode.factory.arguments_body_returnType_(_arguments, SequenceNode.factory.empty(), _returnType);
}
st.gravel.support.jvm.ObjectExtensions.assert_(Parser.this, st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, '|'));
} else {
_returnType = Parser.this.parseReturnType();
if (_returnType != null) {
Parser.this.eatWhitespace();
st.gravel.support.jvm.ObjectExtensions.assert_(Parser.this, st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, '|'));
}
}
_bn = BlockNode.factory.arguments_body_returnType_(_arguments, this.parseSequenceNode_(new st.gravel.support.jvm.Block1<Object, PragmaNode[]>() {
@Override
public Object value_(final PragmaNode[] _extraPragmas) {
throw new RuntimeException("Extra pragmas not allowed");
}
}), _returnType);
st.gravel.support.jvm.ObjectExtensions.assert_(this, st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, ']'));
return ((BlockNode) this.setSourcePosition_node_(_start, _bn));
}
use of st.gravel.support.compiler.ast.BlockNode in project gravel by gravel-st.
the class BlockInliner method renamedBlockNodeFor_.
public BlockNode renamedBlockNodeFor_(final BlockSendArgument _astConstant) {
final BlockNode[] _blockNode;
_blockNode = new BlockNode[1];
_blockNode[0] = _astConstant.blockNode();
for (final JVMVariable _cv : _astConstant.copiedVariables()) {
_blockNode[0] = ((BlockNode) BlockInliner.this.renameVariable_from_to_(_blockNode[0], _cv.varName(), _copiedArgRenames.get(_cv.varName())));
}
this.log_text_("renamedBlockNode: ", _blockNode[0].sourceString());
return _blockNode[0];
}
use of st.gravel.support.compiler.ast.BlockNode in project gravel by gravel-st.
the class IntermediateNodeRewriter method produce$underscore$whileFalse_.
public WhileFalseNode produce$underscore$whileFalse_(final Expression _testExpr) {
final BlockNode _testBlockNode;
if (!_testExpr.isBlockNode()) {
return null;
}
_testBlockNode = ((BlockNode) _testExpr);
return WhileFalseNode.factory.testSequence_doSequence_(((SequenceNode) this.visit_(_testBlockNode.body())), null);
}
use of st.gravel.support.compiler.ast.BlockNode in project gravel by gravel-st.
the class IntermediateNodeRewriter method produce_or_.
public BooleanOrNode produce_or_(final Node _receiver, final Expression _testExpr) {
final BlockNode _testBlockNode;
if (!_testExpr.isBlockNode()) {
return null;
}
_testBlockNode = ((BlockNode) _testExpr);
return BooleanOrNode.factory.left_right_(((Expression) this.visit_(_receiver)), ((SequenceNode) this.visit_(_testBlockNode.body())));
}
Aggregations