Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "traceur", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Experimental ES6 to ES5 compiler", | ||
@@ -40,4 +40,5 @@ "keywords": [ | ||
"mocha": ">=1.9", | ||
"chai": ">=1.5" | ||
"chai": ">=1.5", | ||
"node-uuid": ">=1.4" | ||
} | ||
} |
@@ -24,53 +24,8 @@ // Copyright 2012 Traceur Authors. | ||
var InternalLoader = traceur.modules.internals.InternalLoader; | ||
var ModuleAnalyzer = traceur.semantics.ModuleAnalyzer; | ||
var ModuleRequireVisitor = traceur.codegeneration.module.ModuleRequireVisitor; | ||
var ModuleSymbol = traceur.semantics.symbols.ModuleSymbol; | ||
var ModuleTransformer = traceur.codegeneration.ModuleTransformer; | ||
var ParseTreeFactory = traceur.codegeneration.ParseTreeFactory; | ||
var ParseTreeTransformer = traceur.codegeneration.ParseTreeTransformer; | ||
var Parser = traceur.syntax.Parser; | ||
var Script = traceur.syntax.trees.Script; | ||
var ModuleSpecifier = traceur.syntax.trees.ModuleSpecifier; | ||
var ProgramTransformer = traceur.codegeneration.ProgramTransformer; | ||
var Project = traceur.semantics.symbols.Project; | ||
var SourceFile = traceur.syntax.SourceFile | ||
var SourceMapGenerator = traceur.outputgeneration.SourceMapGenerator; | ||
var TreeWriter = traceur.outputgeneration.TreeWriter; | ||
var IDENTIFIER = traceur.syntax.TokenType.IDENTIFIER; | ||
var createIdentifierExpression = ParseTreeFactory.createIdentifierExpression; | ||
var createIdentifierToken = ParseTreeFactory.createIdentifierToken; | ||
var createStringLiteralToken = ParseTreeFactory.createStringLiteralToken; | ||
/** | ||
* This resolves imported URLs for Script trees. | ||
* | ||
* import * from "url" | ||
* | ||
* with | ||
* | ||
* import * from "resolved_url" | ||
* | ||
* @param {string} url The base URL that all the modules should be relative to. | ||
*/ | ||
function ResolveImportUrlTransformer(url) { | ||
ParseTreeTransformer.call(this); | ||
this.url = url; | ||
} | ||
ResolveImportUrlTransformer.prototype = { | ||
__proto__: ParseTreeTransformer.prototype, | ||
transformModuleSpecifier: function(tree) { | ||
var url = tree.token.processedValue; | ||
// Don't handle builtin modules. | ||
if (url.charAt(0) === '@') | ||
return tree; | ||
url = System.normalResolve(url, this.url); | ||
return new ModuleSpecifier(tree.location, createStringLiteralToken(url)); | ||
} | ||
}; | ||
/** | ||
* @param {ErrorReporter} reporter | ||
@@ -106,8 +61,2 @@ * @param {Project} project | ||
if (codeUnit.type === 'script') { | ||
var transformer = new ResolveImportUrlTransformer(codeUnit.url); | ||
var tree = transformer.transformAny(codeUnit.tree); | ||
this.project.setParseTree(codeUnit.file, tree); | ||
} | ||
return InternalLoader.prototype.transformCodeUnit.call(this, codeUnit); | ||
@@ -114,0 +63,0 @@ } |
@@ -523,2 +523,15 @@ // Copyright 2012 Traceur Authors. | ||
// System.get/set and @traceur/module gets overridden in @traceur/modules to | ||
// be more correct. | ||
function PendingModule(func, self) { | ||
this.func = func; | ||
this.self = self; | ||
} | ||
PendingModule.prototype = { | ||
toModule: function() { | ||
return this.func.call(this.self); | ||
} | ||
}; | ||
var modules = { | ||
@@ -530,9 +543,17 @@ get '@name'() { | ||
return IterModule; | ||
}, | ||
'@traceur/module': { | ||
PendingModule: PendingModule, | ||
registerModule: function(url, func, self) { | ||
modules[url] = new PendingModule(func, self); | ||
} | ||
} | ||
}; | ||
// This gets overridden in @traceur/modules to be more correct. | ||
var System = { | ||
get: function(name) { | ||
return modules[name] || null; | ||
var module = modules[name]; | ||
if (module instanceof PendingModule) | ||
return modules[name] = module.toModule(); | ||
return module || null; | ||
}, | ||
@@ -539,0 +560,0 @@ set: function(name, object) { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
878650
4
22144