Search in sources :

Example 6 with BlockSendArgument

use of st.gravel.support.compiler.jvm.BlockSendArgument 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);
}
Also used : BlockSendArgument(st.gravel.support.compiler.jvm.BlockSendArgument) ArrayList(java.util.ArrayList) KeywordMethodNode(st.gravel.support.compiler.ast.KeywordMethodNode) UnaryMethodNode(st.gravel.support.compiler.ast.UnaryMethodNode) MethodNode(st.gravel.support.compiler.ast.MethodNode) VariableDeclarationNode(st.gravel.support.compiler.ast.VariableDeclarationNode) BoundVariableDeclarationNode(st.gravel.support.compiler.ast.BoundVariableDeclarationNode) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

BlockSendArgument (st.gravel.support.compiler.jvm.BlockSendArgument)6 ArrayList (java.util.ArrayList)3 List (java.util.List)3 BoundVariableDeclarationNode (st.gravel.support.compiler.ast.BoundVariableDeclarationNode)3 VariableDeclarationNode (st.gravel.support.compiler.ast.VariableDeclarationNode)3 KeywordMethodNode (st.gravel.support.compiler.ast.KeywordMethodNode)2 MethodNode (st.gravel.support.compiler.ast.MethodNode)2 UnaryMethodNode (st.gravel.support.compiler.ast.UnaryMethodNode)2 JVMClass (st.gravel.support.compiler.jvm.JVMClass)1 JVMField (st.gravel.support.compiler.jvm.JVMField)1 JVMLocalDeclaration (st.gravel.support.compiler.jvm.JVMLocalDeclaration)1 JVMMethod (st.gravel.support.compiler.jvm.JVMMethod)1 JVMMethodCompiler (st.gravel.support.compiler.jvm.JVMMethodCompiler)1 JVMType (st.gravel.support.compiler.jvm.JVMType)1 JVMVariable (st.gravel.support.compiler.jvm.JVMVariable)1