use of st.gravel.support.compiler.ast.MessageNode in project gravel by gravel-st.
the class DiskClassReader method readClass_packageName_file_namespace_.
public ClassNode readClass_packageName_file_namespace_(final String _aName, final st.gravel.core.Symbol _packageName, final java.io.File _aFilename, final String[] _anArray) {
final Parser _parser;
MessageNode _expr;
ClassNode _cn;
st.gravel.support.jvm.Block3<ClassNode, ClassNode, MessageNode, Parser> _directive;
final int _start;
_cn = ClassNode.factory.name_namespacePath_(st.gravel.core.Symbol.value(_aName), st.gravel.support.jvm.ArrayExtensions.collect_(_anArray, ((st.gravel.support.jvm.Block1<st.gravel.core.Symbol, String>) (new st.gravel.support.jvm.Block1<st.gravel.core.Symbol, String>() {
@Override
public st.gravel.core.Symbol value_(final String _each) {
return (st.gravel.core.Symbol) st.gravel.core.Symbol.value(_each);
}
}))));
_parser = Parser.factory.source_sourceFile_(st.gravel.support.jvm.FilenameExtensions.contentsOfEntireFile(_aFilename), SourceFile.factory.directory_name_packageName_(_aFilename.getParent(), _aFilename.getName(), _packageName));
_start = _parser.position();
boolean _temp1 = false;
while (!_temp1) {
_temp1 = _parser.atEnd();
if (!_temp1) {
_expr = ((MessageNode) _parser.parseExpression());
_directive = DiskClassReader.this.directiveAt_(_expr.selector());
_cn = _directive.value_value_value_(_cn, _expr, _parser);
if (!_parser.atEnd()) {
_parser.parseBang();
}
}
}
return ((ClassNode) _parser.setSourcePosition_node_(_start, _cn));
}
use of st.gravel.support.compiler.ast.MessageNode in project gravel by gravel-st.
the class JVMMethodCompiler method produceMessageSend_.
public JVMMethodCompiler produceMessageSend_(final MessageNode _messageNode) {
final st.gravel.core.Symbol _selector;
if (_parent.allowBlockInlining() && (st.gravel.support.jvm.ArrayExtensions.anySatisfy_(_messageNode.arguments(), new st.gravel.support.jvm.Predicate1<Expression>() {
@Override
public boolean value_(final Expression _e) {
return _e.isBlockNode();
}
}) && (!st.gravel.support.jvm.ArrayExtensions.anySatisfy_(_messageNode.arguments(), new st.gravel.support.jvm.Predicate1<Expression>() {
@Override
public boolean value_(final Expression _e) {
return _e.isBlockNode() && _e.allNodesContains_(((st.gravel.support.jvm.Block1<Boolean, Node>) (new st.gravel.support.jvm.Block1<Boolean, Node>() {
@Override
public Boolean value_(final Node _n) {
return (boolean) _n.isSuperNode();
}
})));
}
})))) {
return JVMMethodCompiler.this.produceBlockInlineMessageSend_(_messageNode);
}
for (final Expression _arg : _messageNode.arguments()) {
JVMMethodCompiler.this.visit_(_arg);
JVMMethodCompiler.this.ensureCast_(JVMDynamicObjectType.factory.basicNew());
}
_selector = st.gravel.core.Symbol.value(_messageNode.selector());
this.emit_(DynamicMessageSend.factory.functionName_numArgs_(_parent.selectorConverter().selectorAsFunctionName_(_selector), _selector.numArgs()));
return this;
}
use of st.gravel.support.compiler.ast.MessageNode 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.MessageNode in project gravel by gravel-st.
the class JVMMethodCompiler method visitCascadeNode_.
@Override
public JVMMethodCompiler visitCascadeNode_(final CascadeNode _cascadeNode) {
this.visit_(_cascadeNode.receiver());
for (final MessageNode _message : st.gravel.support.jvm.ArrayExtensions.copyWithoutLast(_cascadeNode.messages())) {
JVMMethodCompiler.this.emit_(Dup.factory.basicNew());
JVMMethodCompiler.this.produceMessageSend_(_message);
JVMMethodCompiler.this.emit_(Pop.factory.basicNew());
}
MessageNode[] _temp1 = _cascadeNode.messages();
this.produceMessageSend_(_temp1[_temp1.length - 1]);
return this;
}
use of st.gravel.support.compiler.ast.MessageNode in project gravel by gravel-st.
the class MessageSendRewriter method visitKeywordMessageNode_.
@Override
public Statement visitKeywordMessageNode_(final KeywordMessageNode _anObject) {
final st.gravel.core.Symbol _selector;
final st.gravel.support.jvm.Block1<Statement, MessageNode> _res;
_selector = st.gravel.core.Symbol.value(_anObject.selector());
st.gravel.support.jvm.Block1<Statement, MessageNode> _temp1 = _specialSelectors.get(_selector);
_res = ((st.gravel.support.jvm.Block1<Statement, MessageNode>) _temp1);
if (_res != null) {
final Statement _trans;
_trans = _res.value_(_anObject);
if (_trans != null) {
return _trans;
}
}
return super.visitKeywordMessageNode_(_anObject);
}
Aggregations