調査中なので推測や誤解があるものとして読んでください。
Rhinoで 1=1
を評価すると ParserException
が発生する
$ java -jar buildGradle/libs/rhino-1.7.14-SNAPSHOT.jar -version 200
Rhino 1.7.14-SNAPSHOT 2021 04 04
js> 1 = 1
diff --git a/src/org/mozilla/javascript/optimizer/Codegen.java b/src/org/mozilla/javascript/optimizer/Codegen.java | |
index 7e518cc3..99901b1f 100644 | |
--- a/src/org/mozilla/javascript/optimizer/Codegen.java | |
+++ b/src/org/mozilla/javascript/optimizer/Codegen.java | |
@@ -301,6 +301,11 @@ public class Codegen implements Evaluator { | |
emitTemplateLiteralInit(cfw); | |
emitConstantDudeInitializers(cfw); | |
+ try { | |
+ java.nio.file.Files.write(java.nio.file.Paths.get("try.class"), cfw.toByteArray()); |
var props = [ | |
"constructor", | |
"toString", | |
"toSource", | |
"valueOf", | |
"charAt", | |
"charCodeAt", | |
"indexOf", | |
"lastIndexOf", | |
"split", |
class MyClass { | |
constructor(a, b, c) { | |
this.sum_ = a + b + c; | |
} | |
sum() { | |
return this.sum_; | |
} | |
} | |
console.log(new MyClass(2, 3, 4).sum()); |
// ref. http://qiita.com/edo_m18/items/7b3c70ed97bac52b2203 | |
(require => { | |
require("babel/polyfill"); | |
function Point(x, y) { | |
this.x = x; | |
this.y = y; | |
} | |
Object.assign(Point.prototype, { |
<!DOCTYPE html> | |
<html> | |
<head> | |
<link rel="stylesheet" href="test.cjs"> | |
</head> | |
<body> | |
<script src="test.cjs"></script> | |
</body> | |
</html> |
diff --git a/_build/html/_static/searchtools.js b/_build/html/_static/searchtools.js | |
index 3499624..6843d3b 100644 | |
--- a/_build/html/_static/searchtools.js | |
+++ b/_build/html/_static/searchtools.js | |
@@ -81,7 +81,22 @@ var Search = { | |
}, | |
setIndex : function(index) { | |
+ function objToSortArray(terms) { | |
+ var res = []; |
import javax.script.ScriptEngine; | |
import javax.script.ScriptEngineManager; | |
public class E4X { | |
public static void main(String[] args) { | |
System.out.println("E4X: " + System.getProperty("nashorn.lexer.xmlliterals")); | |
ScriptEngineManager manager = new ScriptEngineManager(); | |
ScriptEngine engine = manager.getEngineByName("js"); | |
try { |
macro <<EOS { | |
case { $_ } => { | |
var comments = #{$_}[0].token.leadingComments; | |
var text = ''; | |
if (comments) { | |
text = comments.map(function(c) { | |
return c.type === 'Block' ? c.value.replace(/^(\r\n|\n|\r)/, '').replace(/(\r\n|\n|\r)$/, '') : c.value; | |
}).join('\r\n'); | |
} | |
return [makeValue(text, #{here})]; |
var express = require('express'); | |
var app = express(); | |
app.get('/', function(req, res) { | |
res.type('text/html'); | |
res.send('<script>' + | |
'new EventSource(\'/event/a\').addEventListener(\'message\',function(event) {' + | |
'document.body.appendChild(document.createElement(\'div\')).textContent = event.data;' + | |
'});' + | |
'</script>'); |