JNI (Java Native Interface) allows implementing methods in C/C++, and use them in Java.
class JNIExample {
// Native method, no body.
# -------- | |
# Hardware | |
# -------- | |
# Opcode - operational code | |
# Assebly mnemonic - abbreviation for an operation | |
# Instruction Code Format (IA-32) | |
# - Optional instruction prefix | |
# - Operational code |
/** | |
* int16, and uint16 numbers in JS. | |
* | |
* by Dmitry Soshnikov <[email protected]> | |
*/ | |
const assert = require('assert'); | |
/** | |
* Converts a number to signed 16-bit integer. |
// agent-smith.js | |
/** | |
* Receive shared array buffer in this worker. | |
*/ | |
onmessage = (message) => { | |
// Worker's view of the shared data. | |
let heapArray = new Int32Array(message.data); | |
let indexToModify = 1; |
/** | |
* Event loop. | |
* | |
* Read details here: | |
* http://dmitrysoshnikov.com/ecmascript/javascript-the-core-2nd-edition/#job | |
* | |
* by Dmitry Soshnikov <[email protected]> | |
*/ | |
/** |
/** | |
* DFA minization. | |
* | |
* A DFA table is minimized using N-equivalence algorithm. | |
* | |
* by Dmitry Soshnikov <[email protected]> | |
*/ | |
/** | |
* Non-minizied DFA table for `/a|b/`. |
/** | |
* Classic RegExp implementation (NFA, DFA). | |
* | |
* by Dmitry Soshnikov <[email protected]> | |
* MIT License, 2017 | |
*/ | |
/** | |
* Epsilon. | |
*/ |
/** | |
* NFA (Non-deterministic finite automata) | |
* | |
* A formalism for regular grammars (to recognize strings based on regular | |
* expressions). | |
* | |
* Regexp parser to transform AST to NFA: | |
* https://www.npmjs.com/package/regexp-tree | |
* | |
* NFA/DFA fragment examples: |
/** | |
* JavaScript runtime-augmented scope example. | |
*/ | |
let x = 10; | |
let o = {x: 30}; | |
let storage = {}; | |
(function foo(flag) { |
/** | |
* JavaScript dynamic `this` value. | |
*/ | |
function produce() { | |
console.log(this.x); | |
} | |
const alpha = {produce, x: 1}; | |
const beta = {produce, x: 2}; |