Search in sources :

Example 16 with VariableDeclarationNode

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

the class VariableAccessToFieldAccessConverter method visitAssignmentNode_.

@Override
public Expression visitAssignmentNode_(final AssignmentNode _anObject) {
    final VariableDeclarationNode _instVar;
    if (this.includesLocalName_(_anObject.variable().name())) {
        return LocalWriteNode.factory.name_value_(_anObject.variable().name(), ((Expression) VariableAccessToFieldAccessConverter.this.visit_(_anObject.value())));
    }
    _instVar = this.instVarAt_(_anObject.variable().name());
    if (_instVar != null) {
        return FieldWriteNode.factory.owner_field_type_value_(_owner, _instVar.name(), _instVar.type(), ((Expression) VariableAccessToFieldAccessConverter.this.visit_(_anObject.value())));
    }
    return GlobalWriteNode.factory.namespace_name_value_(_namespace, _anObject.variable().name(), ((Expression) this.visit_(_anObject.value())));
}
Also used : VariableDeclarationNode(st.gravel.support.compiler.ast.VariableDeclarationNode) Expression(st.gravel.support.compiler.ast.Expression)

Example 17 with VariableDeclarationNode

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

the class SourcePrinter method printTemporaries_.

public SourcePrinter printTemporaries_(final VariableDeclarationNode[] _aCollection) {
    _stream.append("| ");
    for (final VariableDeclarationNode _temp : _aCollection) {
        SourcePrinter.this.visit_(_temp);
        _stream.append(' ');
    }
    _stream.append('|');
    return this;
}
Also used : VariableDeclarationNode(st.gravel.support.compiler.ast.VariableDeclarationNode)

Example 18 with VariableDeclarationNode

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

the class Parser method parseBinaryMethod_.

public BinaryMethodNode parseBinaryMethod_(final String _aString) {
    final VariableDeclarationNode _argument;
    final SequenceNode _body;
    final TypeNode _returnType;
    final PragmaNode[][] _pragmas;
    _pragmas = new PragmaNode[1][];
    this.eatWhitespace();
    _argument = this.parseVariableDeclaration();
    _returnType = this.parseReturnType();
    _pragmas[0] = this.readPragmas();
    _body = this.parseSequenceNode_(new st.gravel.support.jvm.Block1<Object, PragmaNode[]>() {

        @Override
        public Object value_(final PragmaNode[] _extraPragmas) {
            return _pragmas[0] = st.gravel.support.jvm.ArrayExtensions.copyWithAll_(_pragmas[0], _extraPragmas);
        }
    });
    return BinaryMethodNode.factory.selector_argument_body_returnType_pragmas_protocol_(_aString, _argument, _body, _returnType, _pragmas[0], null);
}
Also used : TypeCast(st.gravel.support.compiler.ast.TypeCast) ArrayList(java.util.ArrayList) List(java.util.List) PragmaNode(st.gravel.support.compiler.ast.PragmaNode) VariableDeclarationNode(st.gravel.support.compiler.ast.VariableDeclarationNode) BlockTypeNode(st.gravel.support.compiler.ast.BlockTypeNode) SelfTypeNode(st.gravel.support.compiler.ast.SelfTypeNode) InstanceTypeNode(st.gravel.support.compiler.ast.InstanceTypeNode) TypeNode(st.gravel.support.compiler.ast.TypeNode) SequenceNode(st.gravel.support.compiler.ast.SequenceNode)

Example 19 with VariableDeclarationNode

use of st.gravel.support.compiler.ast.VariableDeclarationNode 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));
}
Also used : BlockNode(st.gravel.support.compiler.ast.BlockNode) PragmaNode(st.gravel.support.compiler.ast.PragmaNode) VariableDeclarationNode(st.gravel.support.compiler.ast.VariableDeclarationNode) BlockTypeNode(st.gravel.support.compiler.ast.BlockTypeNode) SelfTypeNode(st.gravel.support.compiler.ast.SelfTypeNode) InstanceTypeNode(st.gravel.support.compiler.ast.InstanceTypeNode) TypeNode(st.gravel.support.compiler.ast.TypeNode)

Example 20 with VariableDeclarationNode

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

the class Parser method parseKeywordMethod_.

public KeywordMethodNode parseKeywordMethod_(final String _aString) {
    String _res;
    final StringBuilder _str;
    final List<VariableDeclarationNode> _arguments;
    final SequenceNode _body;
    final TypeNode _returnType;
    final PragmaNode[][] _pragmas;
    _pragmas = new PragmaNode[1][];
    _str = st.gravel.support.jvm.WriteStreamFactory.on_(new String());
    _str.append(_aString);
    _str.append(':');
    _arguments = new java.util.ArrayList();
    this.eatWhitespace();
    _arguments.add(this.parseVariableDeclaration());
    this.eatWhitespace();
    _res = this.parseKeywordIdentifier();
    boolean _temp1 = false;
    while (!_temp1) {
        _temp1 = _res == null;
        if (!_temp1) {
            _str.append(_res);
            Parser.this.eatWhitespace();
            _arguments.add(Parser.this.parseVariableDeclaration());
            Parser.this.eatWhitespace();
            _res = Parser.this.parseKeywordIdentifier();
        }
    }
    _returnType = this.parseReturnType();
    _pragmas[0] = this.readPragmas();
    _body = this.parseSequenceNode_(new st.gravel.support.jvm.Block1<Object, PragmaNode[]>() {

        @Override
        public Object value_(final PragmaNode[] _extraPragmas) {
            return _pragmas[0] = st.gravel.support.jvm.ArrayExtensions.copyWithAll_(_pragmas[0], _extraPragmas);
        }
    });
    return KeywordMethodNode.factory.selector_arguments_body_returnType_pragmas_protocol_(_str.toString(), _arguments.toArray(new VariableDeclarationNode[_arguments.size()]), _body, _returnType, _pragmas[0], null);
}
Also used : TypeCast(st.gravel.support.compiler.ast.TypeCast) ArrayList(java.util.ArrayList) List(java.util.List) PragmaNode(st.gravel.support.compiler.ast.PragmaNode) SequenceNode(st.gravel.support.compiler.ast.SequenceNode) ArrayList(java.util.ArrayList) VariableDeclarationNode(st.gravel.support.compiler.ast.VariableDeclarationNode) BlockTypeNode(st.gravel.support.compiler.ast.BlockTypeNode) SelfTypeNode(st.gravel.support.compiler.ast.SelfTypeNode) InstanceTypeNode(st.gravel.support.compiler.ast.InstanceTypeNode) TypeNode(st.gravel.support.compiler.ast.TypeNode)

Aggregations

VariableDeclarationNode (st.gravel.support.compiler.ast.VariableDeclarationNode)24 ArrayList (java.util.ArrayList)6 List (java.util.List)6 MethodNode (st.gravel.support.compiler.ast.MethodNode)6 Statement (st.gravel.support.compiler.ast.Statement)5 HashMap (java.util.HashMap)4 BoundVariableDeclarationNode (st.gravel.support.compiler.ast.BoundVariableDeclarationNode)4 PragmaNode (st.gravel.support.compiler.ast.PragmaNode)4 SequenceNode (st.gravel.support.compiler.ast.SequenceNode)4 TypeNode (st.gravel.support.compiler.ast.TypeNode)4 Map (java.util.Map)3 BlockTypeNode (st.gravel.support.compiler.ast.BlockTypeNode)3 ClassNode (st.gravel.support.compiler.ast.ClassNode)3 InstanceTypeNode (st.gravel.support.compiler.ast.InstanceTypeNode)3 SelfTypeNode (st.gravel.support.compiler.ast.SelfTypeNode)3 BlockSendArgument (st.gravel.support.compiler.jvm.BlockSendArgument)3 Expression (st.gravel.support.compiler.ast.Expression)2 KeywordMethodNode (st.gravel.support.compiler.ast.KeywordMethodNode)2 SharedDeclarationNode (st.gravel.support.compiler.ast.SharedDeclarationNode)2 TypeCast (st.gravel.support.compiler.ast.TypeCast)2