feat(facade): add support for Date

Also refactors the dart transpilar to expose
the type mappings for future changes.
This commit is contained in:
Tobias Bosch
2015-02-17 14:29:40 -08:00
committed by Misko Hevery
parent 538b0879dc
commit 674848648a
4 changed files with 30 additions and 9 deletions

View File

@ -32,6 +32,7 @@ import {ParseTreeWriter as JavaScriptParseTreeWriter, ObjectLiteralExpression} f
import {ImportedBinding, BindingIdentifier} from 'traceur/src/syntax/trees/ParseTrees';
import {IdentifierToken} from 'traceur/src/syntax/IdentifierToken';
import {EXPORT_STAR, NAMED_EXPORT} from 'traceur/src/syntax/trees/ParseTreeType';
import {typeMapping} from '../type_mapping';
export class DartParseTreeWriter extends JavaScriptParseTreeWriter {
constructor(moduleName, outputPath) {
@ -221,14 +222,7 @@ export class DartParseTreeWriter extends JavaScriptParseTreeWriter {
}
normalizeType_(typeName) {
switch (typeName) {
case 'number': return 'num';
case 'boolean': return 'bool';
case 'string': return 'String';
case 'any': return 'dynamic';
case 'Promise': return 'Future';
default: return typeName;
}
return typeMapping[typeName] || typeName;
}
// FUNCTION/METHOD ARGUMENTS

View File

@ -0,0 +1,8 @@
export var typeMapping = {
'number': 'num',
'boolean': 'bool',
'string': 'String',
'any': 'dynamic',
'Promise': 'Future',
'Date': 'DateTime'
};