Utility to write out the opcode mapping from bytecode-table.js
as a PHP file.
Run it under node
with the CLI in bin/write-php-ops.js
define(['./bytecode-table'], function(bytecode_table) {
var bops = [];
while(true) {
var bc = bytecode_table.for_num(bops.length);
if (!bc) { break; }
bops.push(bc);
}
var comma = function(i) { return (i < (bops.length-1)) ? ',' : ''; };
var phpName = function(bc) {
var name = bc.name.toUpperCase();
if (name==='2DUP') { return 'DUP2'; }
return name;
};
console.log('<?php');
console.log('// generated by TurtleScript write-php-ops.js');
console.log('');
console.log('namespace Wikimedia\\PhpTurtle;');
console.log('');
console.log('class Op {');