- Local variable declarations.
This commit is contained in:
Jonathan Protzenko 2015-05-26 11:58:02 -07:00
Родитель d796133399
Коммит 1294872ef5
2 изменённых файлов: 12 добавлений и 5 удалений

Просмотреть файл

@ -75,8 +75,11 @@ module TDev {
return env.indent + this.visit(env, expr)+";";
}
public visitExprHolder(env: EmitterEnv, expr: J.JExprHolder) {
return this.visit(env, expr);
public visitExprHolder(env: EmitterEnv, locals: J.JLocalDef[], expr: J.JExprHolder) {
var decls = locals.map(d => this.visit(env, d));
return decls.join("\n"+env.indent) +
(decls.length ? "\n" + env.indent : "") +
this.visit(env, expr);
}
public visitLocalRef(env: EmitterEnv, name: string, id: string) {
@ -91,7 +94,7 @@ module TDev {
}
public visitLocalDef(env: EmitterEnv, name: string, id: string, type: J.JTypeRef) {
return H.mkType(this.libraryMap, type)+" "+H.mangle(name, id);
return H.mkType(this.libraryMap, type)+" "+H.mangle(name, id)+";";
}
public visitStringLiteral(env: EmitterEnv, s: string) {

Просмотреть файл

@ -35,7 +35,8 @@ module TDev {
var n11 = <J.JLocalRef> n;
return this.visitLocalRef(env, n11.name, <any> n11.localId);
case "exprHolder":
return this.visitExprHolder(env, (<J.JExprHolder> n).tree);
var n16 = <J.JExprHolder> n;
return this.visitExprHolder(env, n16.locals, n16.tree);
case "exprStmt":
var ex = <J.JExprStmt> n
var tr = ex.expr.tree
@ -111,7 +112,10 @@ module TDev {
id: string,
type: J.JTypeRef): U { throw new Error("Not implemented"); }
public visitLocalRef(env: T, name: string, id: string): U { throw new Error("Not implemented"); }
public visitExprHolder(env: T, expr: J.JExpr): U { throw new Error("Not implemented"); }
public visitExprHolder(
env: T,
locals: J.JLocalDef[],
expr: J.JExpr): U { throw new Error("Not implemented"); }
public visitExprStmt(env: T, expr: J.JExpr): U { throw new Error("Not implemented"); }
public visitReturn(env: T, expr: J.JExpr): U { throw new Error("Not implemented"); }
public visitShow(env: T, expr: J.JExpr): U { throw new Error("Not implemented"); }