use of boa.compiler.SymbolTable in project compiler by boalang.
the class VisitorMergingTransformer method preProcessProgram.
protected void preProcessProgram(final Program p) {
stopTransform.start(p);
// FIXME rdyer need to figure out how to avoid this, but anything
// new in the transformations needs added to the environment
typeChecker.start(p, new SymbolTable());
varRename.start(p, p.jobName);
}
use of boa.compiler.SymbolTable in project compiler by boalang.
the class TypeCheckingVisitor method visit.
/** {@inheritDoc} */
@Override
public void visit(final DoStatement n, final SymbolTable env) {
SymbolTable st;
try {
st = env.cloneNonLocals();
} catch (final IOException e) {
throw new RuntimeException(e.getClass().getSimpleName() + " caught", e);
}
n.env = st;
n.getCondition().accept(this, st);
n.getBody().accept(this, st);
}
use of boa.compiler.SymbolTable in project compiler by boalang.
the class TypeCheckingVisitor method visit.
/** {@inheritDoc} */
@Override
public void visit(final VisitStatement n, final SymbolTable env) {
SymbolTable st;
try {
st = env.cloneNonLocals();
} catch (final IOException e) {
throw new RuntimeException(e.getClass().getSimpleName() + " caught", e);
}
n.env = st;
if (n.hasComponent()) {
st.setShadowing(true);
n.getComponent().accept(this, st);
if (n.getComponent().type instanceof BoaName)
n.getComponent().type = n.getComponent().getType().type;
st.setShadowing(false);
} else if (!n.hasWildcard())
for (final Identifier id : n.getIdList()) {
if (SymbolTable.getType(id.getToken()) == null)
throw new TypeCheckException(id, "Invalid type '" + id.getToken() + "'");
id.accept(this, st);
}
st.setIsVisitor(true);
n.getBody().accept(this, st);
st.unsetIsVisitor();
}
use of boa.compiler.SymbolTable in project compiler by boalang.
the class TypeCheckingVisitor method visit.
/** {@inheritDoc} */
@Override
public void visit(final Block n, final SymbolTable env) {
SymbolTable st;
try {
st = env.cloneNonLocals();
} catch (final IOException e) {
throw new RuntimeException(e.getClass().getSimpleName() + " caught", e);
}
n.env = st;
for (final Node s : n.getStatements()) s.accept(this, st);
}
use of boa.compiler.SymbolTable in project compiler by boalang.
the class TypeCheckingVisitor method checkQuantifier.
protected Expression checkQuantifier(final Node n, final Component c, Expression e, final Block b, final String kind, final SymbolTable env) {
SymbolTable st;
try {
st = env.cloneNonLocals();
} catch (final IOException ex) {
throw new RuntimeException(e.getClass().getSimpleName() + " caught", ex);
}
n.env = st;
c.accept(this, st);
e.accept(this, st);
if (!(e.type instanceof BoaBool)) {
e = new Expression(new Conjunction(new Comparison(new SimpleExpr(new Term(new Factor(new Identifier("def")).addOp(new Call().addArg(e.clone())))))));
e.accept(this, st);
}
if (n instanceof IfAllStatement)
b.accept(this, env);
else
b.accept(this, st);
return e;
}
Aggregations