feat(compiler): implement "enableIvy" compiler option (#21427)
The "enableIvy" compiler option is the initial implementation of the Render3 (or Ivy) code generation. This commit enables generation generating "Hello, World" (example in the test) but not much else. It is currenly only useful for internal Ivy testing as Ivy is in development. PR Close #21427
This commit is contained in:

committed by
Miško Hevery

parent
ce8b5877e2
commit
64d16dee02
@ -8,6 +8,7 @@
|
||||
|
||||
|
||||
import {ParseSourceSpan} from '../parse_util';
|
||||
import {error} from '../util';
|
||||
|
||||
//// Types
|
||||
export enum TypeModifier {
|
||||
@ -644,7 +645,8 @@ export const TYPED_NULL_EXPR = new LiteralExpr(null, INFERRED_TYPE, null);
|
||||
export enum StmtModifier {
|
||||
Final,
|
||||
Private,
|
||||
Exported
|
||||
Exported,
|
||||
Static,
|
||||
}
|
||||
|
||||
export abstract class Statement {
|
||||
@ -739,7 +741,9 @@ export class AbstractClassPart {
|
||||
}
|
||||
|
||||
export class ClassField extends AbstractClassPart {
|
||||
constructor(public name: string, type?: Type|null, modifiers: StmtModifier[]|null = null) {
|
||||
constructor(
|
||||
public name: string, type?: Type|null, modifiers: StmtModifier[]|null = null,
|
||||
public initializer?: Expression) {
|
||||
super(type, modifiers);
|
||||
}
|
||||
isEquivalent(f: ClassField) { return this.name === f.name; }
|
||||
@ -1370,6 +1374,10 @@ export function fn(
|
||||
return new FunctionExpr(params, body, type, sourceSpan);
|
||||
}
|
||||
|
||||
export function ifStmt(condition: Expression, thenClause: Statement[], elseClause?: Statement[]) {
|
||||
return new IfStmt(condition, thenClause, elseClause);
|
||||
}
|
||||
|
||||
export function literal(
|
||||
value: any, type?: Type | null, sourceSpan?: ParseSourceSpan | null): LiteralExpr {
|
||||
return new LiteralExpr(value, type, sourceSpan);
|
||||
|
@ -216,8 +216,15 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor
|
||||
// comment out as a workaround for #10967
|
||||
ctx.print(null, `/*private*/ `);
|
||||
}
|
||||
if (field.hasModifier(o.StmtModifier.Static)) {
|
||||
ctx.print(null, 'static ');
|
||||
}
|
||||
ctx.print(null, field.name);
|
||||
this._printColonType(field.type, ctx);
|
||||
if (field.initializer) {
|
||||
ctx.print(null, ' = ');
|
||||
field.initializer.visitExpression(this, ctx);
|
||||
}
|
||||
ctx.println(null, `;`);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user