Search in sources :

Example 6 with MessageNode

use of st.gravel.support.compiler.ast.MessageNode in project gravel by gravel-st.

the class Parser method parseMessageChain_.

public Expression parseMessageChain_(final Expression _receiver) {
    final Expression _exp;
    List<MessageNode> _messages;
    _exp = this.parseNoCascadeMessageChain_(_receiver);
    this.eatWhitespace();
    if (st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, ';')) {
        final MessageNode _baseMsg;
        _messages = new java.util.ArrayList();
        _baseMsg = ((MessageNode) _exp);
        _messages.add(_baseMsg);
        boolean _temp1 = true;
        while (_temp1) {
            final MessageNode _msg;
            _msg = ((MessageNode) Parser.this.parseNoCascadeMessageChain_(_baseMsg.receiver()));
            _messages.add(_msg);
            _temp1 = st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, ';');
        }
        return CascadeNode.factory.messages_(_messages.toArray(new MessageNode[_messages.size()]));
    }
    return _exp;
}
Also used : Expression(st.gravel.support.compiler.ast.Expression) MessageNode(st.gravel.support.compiler.ast.MessageNode) UnaryMessageNode(st.gravel.support.compiler.ast.UnaryMessageNode) KeywordMessageNode(st.gravel.support.compiler.ast.KeywordMessageNode) BinaryMessageNode(st.gravel.support.compiler.ast.BinaryMessageNode) ArrayList(java.util.ArrayList)

Example 7 with MessageNode

use of st.gravel.support.compiler.ast.MessageNode in project gravel by gravel-st.

the class SourcePrinter method visitPragmaNode_.

@Override
public SourcePrinter visitPragmaNode_(final PragmaNode _aPragmaNode) {
    final MessageNode _aNode;
    _stream.append('<');
    _aNode = _aPragmaNode.expression();
    if (st.gravel.support.jvm.IntegerExtensions.equals_(_aNode.arguments().length, 0)) {
        _stream.append(_aNode.selector());
    } else {
        st.gravel.support.jvm.ArrayExtensions.with_do_separatedBy_(_aNode.keywords(), _aNode.arguments(), new st.gravel.support.jvm.Block2<Object, String, Expression>() {

            @Override
            public Object value_value_(final String _key, final Expression _value) {
                _stream.append(_key);
                _stream.append(' ');
                return SourcePrinter.this.visit_(_value);
            }
        }, new st.gravel.support.jvm.Block0<Object>() {

            @Override
            public Object value() {
                return _stream.append(' ');
            }
        });
    }
    _stream.append('>');
    return this;
}
Also used : MessageNode(st.gravel.support.compiler.ast.MessageNode) Expression(st.gravel.support.compiler.ast.Expression)

Example 8 with MessageNode

use of st.gravel.support.compiler.ast.MessageNode in project gravel by gravel-st.

the class JVMMethodCompiler method produceSuperSend_.

public JVMMethodCompiler produceSuperSend_(final MessageNode _messageNode) {
    final st.gravel.core.Symbol _selector;
    final SuperNode _superNode;
    final String _functionName;
    String _superFN;
    _superNode = ((SuperNode) _messageNode.receiver());
    this.produceVarRead_("self");
    for (final Node _arg : _messageNode.arguments()) {
        JVMMethodCompiler.this.visit_(_arg);
    }
    _selector = st.gravel.core.Symbol.value(_messageNode.selector());
    _functionName = _parent.selectorConverter().selectorAsFunctionName_(_selector);
    if (_isBlock) {
        final JVMMethodType _superSig;
        JVMMethodCompiler.this.ensureCast_(_parent.selfType());
        _superFN = "access$" + _functionName;
        _superSig = JVMMethodType.factory.dynamic_(_messageNode.numArgs()).copyWithFirst_(_parent.selfType());
        JVMMethodCompiler.this.emit_(InvokeStatic.factory.ownerType_name_signature_(_parent.ownerType(), _superFN, _superSig));
        _parent.addInvokeSuper_functionName_numArgs_superReference_superSig_(_superFN, _functionName, _selector.numArgs(), _superNode.reference().toString(), _superSig);
    } else {
        JVMMethodCompiler.this.emit_(DynamicSuperSend.factory.functionName_numArgs_superReference_(_functionName, _selector.numArgs(), _superNode.reference().toString()));
    }
    return this;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) TypeCast(st.gravel.support.compiler.ast.TypeCast) SuperNode(st.gravel.support.compiler.ast.SuperNode) MessageNode(st.gravel.support.compiler.ast.MessageNode) LocalReadNode(st.gravel.support.compiler.ast.LocalReadNode) ArrayAtPutNode(st.gravel.support.compiler.ast.ArrayAtPutNode) FieldReadNode(st.gravel.support.compiler.ast.FieldReadNode) ReturnNode(st.gravel.support.compiler.ast.ReturnNode) IfTrueIfFalseNode(st.gravel.support.compiler.ast.IfTrueIfFalseNode) HolderDeclarationNode(st.gravel.support.compiler.ast.HolderDeclarationNode) ByteArrayLiteralNode(st.gravel.support.compiler.ast.ByteArrayLiteralNode) DoubleLiteralNode(st.gravel.support.compiler.ast.DoubleLiteralNode) BlockNode(st.gravel.support.compiler.ast.BlockNode) StringLiteralNode(st.gravel.support.compiler.ast.StringLiteralNode) MethodNode(st.gravel.support.compiler.ast.MethodNode) LocalWriteNode(st.gravel.support.compiler.ast.LocalWriteNode) NilLiteralNode(st.gravel.support.compiler.ast.NilLiteralNode) GlobalReadNode(st.gravel.support.compiler.ast.GlobalReadNode) Node(st.gravel.support.compiler.ast.Node) ReferenceLiteralNode(st.gravel.support.compiler.ast.ReferenceLiteralNode) ArraySizeNode(st.gravel.support.compiler.ast.ArraySizeNode) ToDoNode(st.gravel.support.compiler.ast.ToDoNode) FloatLiteralNode(st.gravel.support.compiler.ast.FloatLiteralNode) VariableDeclarationNode(st.gravel.support.compiler.ast.VariableDeclarationNode) SelfNode(st.gravel.support.compiler.ast.SelfNode) CharacterLiteralNode(st.gravel.support.compiler.ast.CharacterLiteralNode) InstanceCreationNode(st.gravel.support.compiler.ast.InstanceCreationNode) CascadeNode(st.gravel.support.compiler.ast.CascadeNode) ArrayAtNode(st.gravel.support.compiler.ast.ArrayAtNode) WhileFalseNode(st.gravel.support.compiler.ast.WhileFalseNode) SymbolLiteralNode(st.gravel.support.compiler.ast.SymbolLiteralNode) WriteHolderNode(st.gravel.support.compiler.ast.WriteHolderNode) BinaryMessageNode(st.gravel.support.compiler.ast.BinaryMessageNode) FieldWriteNode(st.gravel.support.compiler.ast.FieldWriteNode) ReadHolderNode(st.gravel.support.compiler.ast.ReadHolderNode) SuperNode(st.gravel.support.compiler.ast.SuperNode) CreateHolderNode(st.gravel.support.compiler.ast.CreateHolderNode) IsNilNode(st.gravel.support.compiler.ast.IsNilNode) NamespacedVariableNode(st.gravel.support.compiler.ast.NamespacedVariableNode) BooleanAndNode(st.gravel.support.compiler.ast.BooleanAndNode) BooleanOrNode(st.gravel.support.compiler.ast.BooleanOrNode) SequenceNode(st.gravel.support.compiler.ast.SequenceNode) GlobalWriteNode(st.gravel.support.compiler.ast.GlobalWriteNode) IntegerLiteralNode(st.gravel.support.compiler.ast.IntegerLiteralNode) ArrayLiteralNode(st.gravel.support.compiler.ast.ArrayLiteralNode) BooleanLiteralNode(st.gravel.support.compiler.ast.BooleanLiteralNode) IdentityComparisonNode(st.gravel.support.compiler.ast.IdentityComparisonNode) WhileTrueNode(st.gravel.support.compiler.ast.WhileTrueNode) FixedPointLiteralNode(st.gravel.support.compiler.ast.FixedPointLiteralNode) NonLocalReturnNode(st.gravel.support.compiler.ast.NonLocalReturnNode) PushString(st.gravel.support.compiler.jvm.PushString) JVMMethodType(st.gravel.support.compiler.jvm.JVMMethodType)

Example 9 with MessageNode

use of st.gravel.support.compiler.ast.MessageNode in project gravel by gravel-st.

the class CascadeNode method innerSourceOn_.

@Override
public CascadeNode innerSourceOn_(final StringBuilder _aStream) {
    this.receiver().sourceOn_(_aStream);
    boolean _temp1 = true;
    for (final MessageNode _msg : _messages) {
        if (_temp1) {
            _temp1 = false;
        } else {
            _aStream.append(';');
            _aStream.append(' ');
        }
        _msg.sourceSendOn_(_aStream);
    }
    return this;
}
Also used : MessageNode(st.gravel.support.compiler.ast.MessageNode)

Example 10 with MessageNode

use of st.gravel.support.compiler.ast.MessageNode in project gravel by gravel-st.

the class MessageSendRewriter method visitBinaryMessageNode_.

@Override
public Statement visitBinaryMessageNode_(final BinaryMessageNode _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.visitBinaryMessageNode_(_anObject);
}
Also used : BinaryMessageNode(st.gravel.support.compiler.ast.BinaryMessageNode) MessageNode(st.gravel.support.compiler.ast.MessageNode) UnaryMessageNode(st.gravel.support.compiler.ast.UnaryMessageNode) KeywordMessageNode(st.gravel.support.compiler.ast.KeywordMessageNode) Statement(st.gravel.support.compiler.ast.Statement)

Aggregations

MessageNode (st.gravel.support.compiler.ast.MessageNode)11 BinaryMessageNode (st.gravel.support.compiler.ast.BinaryMessageNode)8 ArrayList (java.util.ArrayList)5 List (java.util.List)4 KeywordMessageNode (st.gravel.support.compiler.ast.KeywordMessageNode)4 ArrayAtNode (st.gravel.support.compiler.ast.ArrayAtNode)3 ArrayAtPutNode (st.gravel.support.compiler.ast.ArrayAtPutNode)3 ArrayLiteralNode (st.gravel.support.compiler.ast.ArrayLiteralNode)3 ArraySizeNode (st.gravel.support.compiler.ast.ArraySizeNode)3 BlockNode (st.gravel.support.compiler.ast.BlockNode)3 BooleanAndNode (st.gravel.support.compiler.ast.BooleanAndNode)3 BooleanLiteralNode (st.gravel.support.compiler.ast.BooleanLiteralNode)3 BooleanOrNode (st.gravel.support.compiler.ast.BooleanOrNode)3 ByteArrayLiteralNode (st.gravel.support.compiler.ast.ByteArrayLiteralNode)3 CascadeNode (st.gravel.support.compiler.ast.CascadeNode)3 CharacterLiteralNode (st.gravel.support.compiler.ast.CharacterLiteralNode)3 CreateHolderNode (st.gravel.support.compiler.ast.CreateHolderNode)3 DoubleLiteralNode (st.gravel.support.compiler.ast.DoubleLiteralNode)3 Expression (st.gravel.support.compiler.ast.Expression)3 FieldReadNode (st.gravel.support.compiler.ast.FieldReadNode)3