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())));
}
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;
}
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);
}
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));
}
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);
}
Aggregations