feat(compiler): add basic support for in ivy/i18n code generation (#22654)

PR Close #22654
This commit is contained in:
Olivier Combe
2018-02-14 10:54:00 -08:00
committed by Matias Niemelä
parent e5e1b0da33
commit 204ba9d413
9 changed files with 496 additions and 85 deletions

View File

@ -237,7 +237,13 @@ class KeyVisitor implements o.ExpressionVisitor {
`EX:${ast.value.runtime.name}`;
}
visitReadVarExpr = invalid;
visitReadVarExpr(ast: o.ReadVarExpr): string {
if (!ast.name) {
invalid(ast);
}
return ast.name as string;
}
visitWriteVarExpr = invalid;
visitWriteKeyExpr = invalid;
visitWritePropExpr = invalid;
@ -257,9 +263,9 @@ class KeyVisitor implements o.ExpressionVisitor {
function invalid<T>(arg: o.Expression | o.Statement): never {
throw new Error(
`Invalid state: Visitor ${this.constructor.name} doesn't handle ${o.constructor.name}`);
`Invalid state: Visitor ${this.constructor.name} doesn't handle ${arg.constructor.name}`);
}
function isVariable(e: o.Expression): e is o.ReadVarExpr {
return e instanceof o.ReadVarExpr;
}
}