use of st.gravel.support.compiler.ast.VariableDeclarationNode in project gravel by gravel-st.
the class SourcePrinter method printArguments_.
public boolean printArguments_(final VariableDeclarationNode[] _args) {
if (_args.length == 0) {
return false;
}
boolean _temp1 = true;
for (final VariableDeclarationNode _arg : _args) {
if (_temp1) {
_temp1 = false;
} else {
_stream.append(' ');
}
_stream.append(':');
SourcePrinter.this.visit_(_arg);
}
return true;
}
use of st.gravel.support.compiler.ast.VariableDeclarationNode in project gravel by gravel-st.
the class SequenceNode method sourceTemporariesOn_.
public SequenceNode sourceTemporariesOn_(final StringBuilder _aStream) {
if (_temporaries.length != 0) {
_aStream.append('|');
_aStream.append(' ');
for (final VariableDeclarationNode _arg : _temporaries) {
_arg.sourceOn_(_aStream);
_aStream.append(' ');
}
_aStream.append('|');
}
return this;
}
use of st.gravel.support.compiler.ast.VariableDeclarationNode in project gravel by gravel-st.
the class Parser method parseSequenceNode_.
public SequenceNode parseSequenceNode_(final st.gravel.support.jvm.Block1<Object, PragmaNode[]> _extraPragmaBlock) {
VariableDeclarationNode[] _temporaries;
Statement[] _statements;
Statement _statement;
final int _start;
final PragmaNode[] _pragmas;
_start = st.gravel.support.jvm.ReadStreamExtensions.position(_stream);
this.eatWhitespace();
_temporaries = new VariableDeclarationNode[] {};
if (st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, '|')) {
Parser.this.eatWhitespace();
boolean _temp1 = false;
while (!_temp1) {
_temp1 = st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, '|');
if (!_temp1) {
Parser.this.eatWhitespace();
_temporaries = st.gravel.support.jvm.ArrayExtensions.copyWith_(_temporaries, Parser.this.parseVariableDeclaration());
Parser.this.eatWhitespace();
}
}
}
_pragmas = this.readPragmas();
if (_pragmas.length != 0) {
_extraPragmaBlock.value_(_pragmas);
}
_statements = new Statement[] {};
_statement = this.parseStatement();
this.eatWhitespace();
boolean _temp2 = false;
while (!_temp2) {
_temp2 = _statement == null;
if (!_temp2) {
_statements = st.gravel.support.jvm.ArrayExtensions.copyWith_(_statements, _statement);
st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, '.');
_statement = Parser.this.parseStatement();
Parser.this.eatWhitespace();
}
}
return ((SequenceNode) this.setSourcePosition_node_(_start, SequenceNode.factory.temporaries_statements_(_temporaries, _statements)));
}
use of st.gravel.support.compiler.ast.VariableDeclarationNode in project gravel by gravel-st.
the class VariableToHolderRewriter method visitSequenceNode_.
@Override
public SequenceNode visitSequenceNode_(final SequenceNode _anObject) {
final List<VariableDeclarationNode>[] _found;
Statement[] _stmts;
final VariableDeclarationNode[] _temporaries;
_found = new List[1];
_found[0] = new java.util.ArrayList();
_stmts = st.gravel.support.jvm.ArrayExtensions.collect_(_anObject.statements(), ((st.gravel.support.jvm.Block1<Statement, Statement>) (new st.gravel.support.jvm.Block1<Statement, Statement>() {
@Override
public Statement value_(final Statement _each) {
return (Statement) VariableToHolderRewriter.this.visit_(_each);
}
})));
_temporaries = st.gravel.support.jvm.ArrayExtensions.collect_(_anObject.temporaries(), ((st.gravel.support.jvm.Block1<VariableDeclarationNode, VariableDeclarationNode>) (new st.gravel.support.jvm.Block1<VariableDeclarationNode, VariableDeclarationNode>() {
@Override
public VariableDeclarationNode value_(final VariableDeclarationNode _each) {
VariableDeclarationNode _newDecl;
if (st.gravel.support.jvm.StringExtensions.equals_(_each.name(), _varName)) {
_found[0].add(_each);
_newDecl = HolderDeclarationNode.factory.name_type_(_each.name(), ((TypeNode) VariableToHolderRewriter.this.visit_(_each.type())));
} else {
_newDecl = ((VariableDeclarationNode) VariableToHolderRewriter.this.visit_(_each));
}
return (VariableDeclarationNode) _newDecl;
}
})));
if (_found[0].size() != 0) {
_stmts = st.gravel.support.jvm.ArrayExtensions.copyWithFirst_(_stmts, AssignmentNode.factory.variable_value_(VariableNode.factory.name_(_varName), CreateHolderNode.factory.basicNew()));
}
return SequenceNode.factory.temporaries_statements_(_temporaries, _stmts);
}
use of st.gravel.support.compiler.ast.VariableDeclarationNode in project gravel by gravel-st.
the class VariableAccessToFieldAccessConverter method visitVariableNode_.
@Override
public Expression visitVariableNode_(final VariableNode _anObject) {
final VariableDeclarationNode _instVar;
if (st.gravel.support.jvm.StringExtensions.equals_(_anObject.name(), "self")) {
return SelfNode.factory.basicNew();
}
if (st.gravel.support.jvm.StringExtensions.equals_(_anObject.name(), "super")) {
return SuperNode.factory.reference_(_ownerReference);
}
if (this.includesLocalName_(_anObject.name())) {
return LocalReadNode.factory.name_(_anObject.name());
}
_instVar = this.instVarAt_(_anObject.name());
if (_instVar != null) {
return FieldReadNode.factory.owner_field_type_(_owner, _instVar.name(), _instVar.type());
}
return GlobalReadNode.factory.namespace_name_(_namespace, _anObject.name());
}
Aggregations