}
}
/** Emit an inlined script. */
private void fleshOutScriptBlock(ScriptBone bone) {
FilePosition unk = FilePosition.UNKNOWN;
FilePosition pos = bone.body.getFilePosition();
String sourcePath = mc.abbreviate(pos.source());
if (bone.source.fromCache) {
CajoledModule scriptFromCache = (CajoledModule) bone.body;
finishBlock();
this.js.add(new SafeJsChunk(bone.source, scriptFromCache));
} else {
Block scriptToWrapAndProcess = (Block) bone.body;
emitStatement(quasiStmt(
""
+ "try {"
+ " @scriptBody;"
+ "} catch (ex___) {"
+ " ___./*@synthetic*/ getNewModuleHandler()"
// getNewModuleHandler is appropriate since there can't be multiple
// module handlers in play while loadModule is being called, and all
// these exception handlers are only reachable while control is in
// loadModule.
+ " ./*@synthetic*/ handleUncaughtException("
+ " ex___, onerror, @sourceFile, @line);"
+ "}",
// TODO(ihab.awad): Will add UncajoledModule wrapper when we no longer
// "consolidate" all scripts in an HTML file into one Caja module.
"scriptBody", scriptToWrapAndProcess,
"sourceFile", StringLiteral.valueOf(unk, sourcePath),
"line", StringLiteral.valueOf(unk, String.valueOf(pos.startLineNo()))
),
false,
bone.source);
}
}