use of st.gravel.support.compiler.ast.MethodNode in project gravel by gravel-st.
the class ClassDescriptionMirror method getMethodMirror.
public MethodMirror getMethodMirror(Object selObject) {
if (!(selObject instanceof Symbol))
return null;
Symbol selector = (Symbol) selObject;
MethodNode method = getMethodNode(selector);
if (method == null) {
return null;
}
return new MethodMirror(method, this);
}
use of st.gravel.support.compiler.ast.MethodNode in project gravel by gravel-st.
the class BlockInliner method buildOptimized.
public java.lang.invoke.MethodHandle buildOptimized() {
final MethodNode[] _node;
MethodNode _inlined;
final VariableDeclarationNode[] _arguments;
final String _selector;
_node = new MethodNode[1];
this.log_text_("methodNode: ", _methodNode.sourceString());
_node[0] = this.link_(_methodNode);
this.log_text_("linked methodNode: ", _node[0].sourceString());
for (final String _each : _copiedArgumentNames) {
final String _newTempName;
_newTempName = BlockInliner.this.newTempName_for_(_each, _node[0]);
_copiedArgRenames.put(_each, _newTempName);
}
_arguments = this.buildMethodNodeArguments_(_node[0]);
_selector = _systemMapping.selectorConverter().selectorForNumArgs_(_arguments.length);
this.log_text_("selector: ", _selector);
_node[0] = this.newMethodNode_arguments_body_(_selector, _arguments, _node[0].body()).withNlrMarker_(_node[0].nlrMarker());
this.log_text_("node: ", _node[0].sourceString());
st.gravel.support.jvm.ArrayExtensions.with_do_(_astConstants, _methodNode.arguments(), new st.gravel.support.jvm.Block2<Object, BlockSendArgument, VariableDeclarationNode>() {
@Override
public Object value_value_(final BlockSendArgument _astConstant, final VariableDeclarationNode _arg) {
if (_astConstant != null) {
BlockInliner.this.log_text_("block " + _arg.name() + ": ", _astConstant.blockNode().sourceString());
return _node[0] = ((MethodNode) VariableNodeReplacer.factory.in_replace_with_(_node[0], _arg.name(), BlockInliner.this.renamedBlockNodeFor_(_astConstant)));
}
return BlockInliner.this;
}
});
_inlined = LiteralSendInliner.factory.inline_(_node[0]);
_inlined = this.link_(_inlined);
this.log_text_("inlined: ", _inlined.sourceString());
return this.compileMethodNode_(_inlined);
}
use of st.gravel.support.compiler.ast.MethodNode in project gravel by gravel-st.
the class BlockInliner method buildNonOptimized.
public java.lang.invoke.MethodHandle buildNonOptimized() {
final MethodNode _node;
final VariableDeclarationNode[] _arguments;
final List<Expression>[] _sendArgs;
_sendArgs = new List[1];
for (final String _each : _copiedArgumentNames) {
final String _newTempName;
_newTempName = BlockInliner.this.newTempName_for_(_each, _methodNode);
_copiedArgRenames.put(_each, _newTempName);
}
_arguments = this.buildMethodNodeArguments_(_methodNode);
_sendArgs[0] = new java.util.ArrayList();
st.gravel.support.jvm.ArrayExtensions.with_do_(_astConstants, _methodNode.arguments(), new st.gravel.support.jvm.Block2<Object, BlockSendArgument, VariableDeclarationNode>() {
@Override
public Object value_value_(final BlockSendArgument _astConstant, final VariableDeclarationNode _arg) {
if (_astConstant == null) {
return _sendArgs[0].add(_arg.asVariableNode());
} else {
return _sendArgs[0].add(BlockInliner.this.renamedBlockNodeFor_(_astConstant));
}
}
});
_node = this.newMethodNode_arguments_body_(_systemMapping.selectorConverter().selectorForNumArgs_(_arguments.length), _arguments, SequenceNode.factory.return_(SelfNode.factory.basicNew().send_withAll_(_methodNode.selector(), _sendArgs[0].toArray(new Expression[_sendArgs[0].size()]))));
this.log_text_("nonOptimized: ", _node.sourceString());
return this.compileMethodNode_allowBlockInlining_(this.link_(_node), false);
}
use of st.gravel.support.compiler.ast.MethodNode in project gravel by gravel-st.
the class MetaclassNode method allMethodsIn_do_.
@Override
public MetaclassNode allMethodsIn_do_(final SystemNode _aSystemNode, final st.gravel.support.jvm.Block1<Object, MethodNode> _aBlock) {
final ClassDescriptionNode _scn;
for (final MethodNode _temp1 : _methods) {
_aBlock.value_(_temp1);
}
_scn = this.superclassNodeIn_(_aSystemNode);
if (_scn == null) {
return MetaclassNode.this;
}
_scn.allMethodsIn_do_(_aSystemNode, _aBlock);
return this;
}
use of st.gravel.support.compiler.ast.MethodNode in project gravel by gravel-st.
the class ClassDescriptionNode method withMethodNode_.
public ClassDescriptionNode withMethodNode_(final MethodNode _aMethodNode) {
final MethodNode _current;
_current = this.methodOrNilAt_(_aMethodNode.selector());
if (_current != null) {
throw new RuntimeException("Duplicate selector: " + _aMethodNode.selector());
}
return this.copy().pvtSetMethods_(st.gravel.support.jvm.ArrayExtensions.copyWith_(_methods, _aMethodNode));
}
Aggregations