Skip to content

Instantly share code, notes, and snippets.

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());
@tuchida
tuchida / ParserException.md
Last active April 7, 2021 01:15
Rhinoで1=1がParserExceptionになる問題

調査中なので推測や誤解があるものとして読んでください。

事象

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
@tuchida
tuchida / benchmark-findPrototypeId.js
Last active March 20, 2021 05:06
Make findPrototypeId faster
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());
@tuchida
tuchida / delaunay.js
Created February 20, 2015 01:09
delaunay.js ES6Ver
// 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, {
@tuchida
tuchida / cjs.html
Created July 16, 2014 23:46
jsとcssを1ファイルに
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="test.cjs">
</head>
<body>
<script src="test.cjs"></script>
</body>
</html>
@tuchida
tuchida / searchtools.js.diff
Created May 16, 2014 06:53
Sphinxの全文検索を複合語に強くする
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 = [];
@tuchida
tuchida / E4X.java
Created March 26, 2014 23:31
E4X in Nashorn
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 {
@tuchida
tuchida / comment.js
Created February 23, 2014 03:06
heredoc macro
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})];
@tuchida
tuchida / app.js
Created January 10, 2014 06:40
Server-Sent Eventsテスト
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>');