use of com.github.anba.es6draft.ast.scope.ModuleScope in project es6draft by anba.
the class NodeSourceTextModuleRecord method ParseModule.
/**
* ParseModule ( sourceText )
*
* @param scriptLoader
* the script loader
* @param sourceCodeId
* the source code identifier
* @param source
* the module source code
* @return the parsed module record
* @throws IOException
* if there was any I/O error
* @throws ParserException
* if the module source contains any syntax errors
* @throws CompilationException
* if the parsed module source cannot be compiled
*/
public static NodeSourceTextModuleRecord ParseModule(ScriptLoader scriptLoader, SourceIdentifier sourceCodeId, ModuleSource source) throws IOException, ParserException, CompilationException {
// Add an implicit "require" binding to the lexical environment of the module.
com.github.anba.es6draft.ast.Module parsedBody = scriptLoader.parseModule(source.toSource(), source.sourceCode());
ModuleScope moduleScope = parsedBody.getScope();
if (!moduleScope.isDeclared(new Name("require"))) {
moduleScope.addImplicitBinding(new Name("require"));
}
SourceTextModuleRecord sourceText = SourceTextModuleRecord.ParseModule(scriptLoader, sourceCodeId, parsedBody);
return new NodeSourceTextModuleRecord(sourceText);
}
Aggregations