Map type aliases
TypeScript type aliases simply turn into MuIL classes with the base class being the aliased type. In theory, MuIL conversions will support the kind of conversions offered by aliases (or at least get sufficiently close). We will need to tackle this in part by marapongo/mu#46. In addition, while I was in there, I cleaned up the type token emission to emit "any" (rather than "TODO") and to use a single, central function for all ts.TypeNodes. This will also get cleaned up by marapongo/mu#46.
This commit is contained in:
parent
3c76092d46
commit
c28cd6305e
|
@ -216,6 +216,11 @@ export class Transformer {
|
|||
return this.withLocation(node, ident(node.text));
|
||||
}
|
||||
|
||||
private transformTypeNode(node: ts.TypeNode | undefined): symbols.TypeToken {
|
||||
// TODO[marapongo/mu#46]: emit strong typing information.
|
||||
return "any";
|
||||
}
|
||||
|
||||
/** Modules **/
|
||||
|
||||
// This transforms top-level TypeScript module elements into their corresponding nodes. This transformation
|
||||
|
@ -628,7 +633,7 @@ export class Transformer {
|
|||
name: name,
|
||||
parameters: parameters.map((p: VariableDeclaration<ast.LocalVariable>) => p.variable),
|
||||
body: body,
|
||||
returnType: "TODO",
|
||||
returnType: this.transformTypeNode(node.type),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -701,14 +706,21 @@ export class Transformer {
|
|||
variable: {
|
||||
kind: ast.localVariableKind,
|
||||
name: name,
|
||||
type: "TODO",
|
||||
type: this.transformTypeNode(node.type),
|
||||
},
|
||||
initializer: initializer,
|
||||
};
|
||||
}
|
||||
|
||||
// transformTypeAliasDeclaration emits a type whose base is the aliased type. The MuIL type system permits
|
||||
// conversions between such types in a way that is roughly compatible with TypeScript's notion of type aliases.
|
||||
private transformTypeAliasDeclaration(node: ts.TypeAliasDeclaration, access: symbols.Accessibility): ast.Class {
|
||||
return contract.fail("NYI");
|
||||
return this.withLocation(node, <ast.Class>{
|
||||
kind: ast.classKind,
|
||||
name: this.transformIdentifier(node.name),
|
||||
access: access,
|
||||
extends: this.transformTypeNode(node.type),
|
||||
});
|
||||
}
|
||||
|
||||
private makeVariableInitializer(decl: VariableDeclaration<ast.Variable>): ast.Statement {
|
||||
|
@ -812,7 +824,7 @@ export class Transformer {
|
|||
}
|
||||
return {
|
||||
name: name,
|
||||
type: "TODO",
|
||||
type: this.transformTypeNode(node.type),
|
||||
initializer: initializer,
|
||||
};
|
||||
}
|
||||
|
@ -911,7 +923,7 @@ export class Transformer {
|
|||
access: this.getClassAccessibility(node),
|
||||
readonly: !!(mods & ts.ModifierFlags.Readonly),
|
||||
static: !!(mods & ts.ModifierFlags.Static),
|
||||
type: "TODO",
|
||||
type: this.transformTypeNode(node.type),
|
||||
},
|
||||
false,
|
||||
initializer,
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"type": "TODO"
|
||||
"type": "any"
|
||||
},
|
||||
{
|
||||
"kind": "LocalVariable",
|
||||
|
@ -63,7 +63,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"type": "TODO"
|
||||
"type": "any"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
|
@ -81,7 +81,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"returnType": "TODO",
|
||||
"returnType": "any",
|
||||
"loc": {
|
||||
"file": "index.ts",
|
||||
"start": {
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"type": "TODO"
|
||||
"type": "any"
|
||||
},
|
||||
{
|
||||
"kind": "LocalVariable",
|
||||
|
@ -63,7 +63,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"type": "TODO"
|
||||
"type": "any"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
|
@ -81,7 +81,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"returnType": "TODO",
|
||||
"returnType": "any",
|
||||
"loc": {
|
||||
"file": "index.ts",
|
||||
"start": {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"type": "TODO"
|
||||
"type": "any"
|
||||
},
|
||||
{
|
||||
"kind": "LocalVariable",
|
||||
|
@ -52,7 +52,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"type": "TODO"
|
||||
"type": "any"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
|
@ -70,7 +70,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"returnType": "TODO",
|
||||
"returnType": "any",
|
||||
"loc": {
|
||||
"file": "index.ts",
|
||||
"start": {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
}
|
||||
},
|
||||
"access": "private",
|
||||
"type": "TODO"
|
||||
"type": "any"
|
||||
},
|
||||
".init": {
|
||||
"kind": "ModuleMethod",
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
}
|
||||
},
|
||||
"access": "public",
|
||||
"type": "TODO"
|
||||
"type": "any"
|
||||
},
|
||||
".init": {
|
||||
"kind": "ModuleMethod",
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"type": "TODO"
|
||||
"type": "any"
|
||||
},
|
||||
{
|
||||
"kind": "LocalVariable",
|
||||
|
@ -71,7 +71,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"type": "TODO"
|
||||
"type": "any"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
|
@ -272,7 +272,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"returnType": "TODO",
|
||||
"returnType": "any",
|
||||
"static": false,
|
||||
"abstract": false,
|
||||
"loc": {
|
||||
|
@ -323,7 +323,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"type": "TODO"
|
||||
"type": "any"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
|
@ -599,7 +599,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"returnType": "TODO",
|
||||
"returnType": "any",
|
||||
"static": false,
|
||||
"abstract": false,
|
||||
"loc": {
|
||||
|
@ -634,7 +634,7 @@
|
|||
"access": "public",
|
||||
"readonly": true,
|
||||
"static": false,
|
||||
"type": "TODO"
|
||||
"type": "any"
|
||||
},
|
||||
"y": {
|
||||
"kind": "ClassProperty",
|
||||
|
@ -656,7 +656,7 @@
|
|||
"access": "public",
|
||||
"readonly": true,
|
||||
"static": false,
|
||||
"type": "TODO"
|
||||
"type": "any"
|
||||
}
|
||||
},
|
||||
"abstract": false,
|
||||
|
|
Loading…
Reference in a new issue