Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support for autogenerating information about YARV instructions

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@2793 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
commit 9467fd60d68deebb95a715fa54e05457ebb38dd0 1 parent 9fa4acd
@olabini olabini authored
View
277 src/org/jruby/ast/executable/YARVInstructions.java
@@ -12,6 +12,7 @@
* rights and limitations under the License.
*
* Copyright (C) 2006 Charles O Nutter <headius@headius.com>
+ * Copyright (C) 2007 Ola Bini <ola@ologix.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
@@ -27,10 +28,13 @@
***** END LICENSE BLOCK *****/
package org.jruby.ast.executable;
+import java.util.Map;
+import java.util.HashMap;
+
/**
- * This is based on the YARV instruction list available at http://www.atdot.net/yarv/insnstbl.html
+ * AUTOGENERATED. Change template, not generated file.
*/
-public interface YARVInstructions {
+public abstract class YARVInstructions {
public static final int NOP = 0;
public static final int GETLOCAL = 1;
public static final int SETLOCAL = 2;
@@ -135,12 +139,12 @@
public static final int SEND_OP__WC__1_QFALSE_0__WC_ = 101;
public static final int SEND_OP__WC__2_QFALSE_0__WC_ = 102;
public static final int SEND_OP__WC__3_QFALSE_0__WC_ = 103;
- public static final int SEND_OP__WC___WC__QFALSE_0x04__WC_ = 104;
- public static final int SEND_OP__WC__0_QFALSE_0x04__WC_ = 105;
- public static final int SEND_OP__WC__1_QFALSE_0x04__WC_ = 106;
- public static final int SEND_OP__WC__2_QFALSE_0x04__WC_ = 107;
- public static final int SEND_OP__WC__3_QFALSE_0x04__WC_ = 108;
- public static final int SEND_OP__WC__0_QFALSE_0x0c__WC_ = 109;
+ public static final int SEND_OP__WC___WC__QFALSE_0X04__WC_ = 104;
+ public static final int SEND_OP__WC__0_QFALSE_0X04__WC_ = 105;
+ public static final int SEND_OP__WC__1_QFALSE_0X04__WC_ = 106;
+ public static final int SEND_OP__WC__2_QFALSE_0X04__WC_ = 107;
+ public static final int SEND_OP__WC__3_QFALSE_0X04__WC_ = 108;
+ public static final int SEND_OP__WC__0_QFALSE_0X0C__WC_ = 109;
public static final int UNIFIED_PUTOBJECT_PUTOBJECT = 110;
public static final int UNIFIED_PUTOBJECT_PUTSTRING = 111;
public static final int UNIFIED_PUTOBJECT_SETLOCAL = 112;
@@ -152,7 +156,262 @@
public static final int UNIFIED_DUP_SETLOCAL = 118;
public static final int UNIFIED_GETLOCAL_GETLOCAL = 119;
public static final int UNIFIED_GETLOCAL_PUTOBJECT = 120;
-
+
+ public static final Map INSTS_TO_INDEX = new HashMap();
+ static {
+ INSTS_TO_INDEX.put("nop",new Integer(0));
+ INSTS_TO_INDEX.put("getlocal",new Integer(1));
+ INSTS_TO_INDEX.put("setlocal",new Integer(2));
+ INSTS_TO_INDEX.put("getspecial",new Integer(3));
+ INSTS_TO_INDEX.put("setspecial",new Integer(4));
+ INSTS_TO_INDEX.put("getdynamic",new Integer(5));
+ INSTS_TO_INDEX.put("setdynamic",new Integer(6));
+ INSTS_TO_INDEX.put("getinstancevariable",new Integer(7));
+ INSTS_TO_INDEX.put("setinstancevariable",new Integer(8));
+ INSTS_TO_INDEX.put("getclassvariable",new Integer(9));
+ INSTS_TO_INDEX.put("setclassvariable",new Integer(10));
+ INSTS_TO_INDEX.put("getconstant",new Integer(11));
+ INSTS_TO_INDEX.put("setconstant",new Integer(12));
+ INSTS_TO_INDEX.put("getglobal",new Integer(13));
+ INSTS_TO_INDEX.put("setglobal",new Integer(14));
+ INSTS_TO_INDEX.put("putnil",new Integer(15));
+ INSTS_TO_INDEX.put("putself",new Integer(16));
+ INSTS_TO_INDEX.put("putundef",new Integer(17));
+ INSTS_TO_INDEX.put("putobject",new Integer(18));
+ INSTS_TO_INDEX.put("putstring",new Integer(19));
+ INSTS_TO_INDEX.put("concatstrings",new Integer(20));
+ INSTS_TO_INDEX.put("tostring",new Integer(21));
+ INSTS_TO_INDEX.put("toregexp",new Integer(22));
+ INSTS_TO_INDEX.put("newarray",new Integer(23));
+ INSTS_TO_INDEX.put("duparray",new Integer(24));
+ INSTS_TO_INDEX.put("expandarray",new Integer(25));
+ INSTS_TO_INDEX.put("concatarray",new Integer(26));
+ INSTS_TO_INDEX.put("splatarray",new Integer(27));
+ INSTS_TO_INDEX.put("checkincludearray",new Integer(28));
+ INSTS_TO_INDEX.put("newhash",new Integer(29));
+ INSTS_TO_INDEX.put("newrange",new Integer(30));
+ INSTS_TO_INDEX.put("putnot",new Integer(31));
+ INSTS_TO_INDEX.put("pop",new Integer(32));
+ INSTS_TO_INDEX.put("dup",new Integer(33));
+ INSTS_TO_INDEX.put("dupn",new Integer(34));
+ INSTS_TO_INDEX.put("swap",new Integer(35));
+ INSTS_TO_INDEX.put("reput",new Integer(36));
+ INSTS_TO_INDEX.put("topn",new Integer(37));
+ INSTS_TO_INDEX.put("setn",new Integer(38));
+ INSTS_TO_INDEX.put("emptstack",new Integer(39));
+ INSTS_TO_INDEX.put("definemethod",new Integer(40));
+ INSTS_TO_INDEX.put("alias",new Integer(41));
+ INSTS_TO_INDEX.put("undef",new Integer(42));
+ INSTS_TO_INDEX.put("defined",new Integer(43));
+ INSTS_TO_INDEX.put("postexe",new Integer(44));
+ INSTS_TO_INDEX.put("trace",new Integer(45));
+ INSTS_TO_INDEX.put("defineclass",new Integer(46));
+ INSTS_TO_INDEX.put("send",new Integer(47));
+ INSTS_TO_INDEX.put("invokesuper",new Integer(48));
+ INSTS_TO_INDEX.put("invokeblock",new Integer(49));
+ INSTS_TO_INDEX.put("leave",new Integer(50));
+ INSTS_TO_INDEX.put("finish",new Integer(51));
+ INSTS_TO_INDEX.put("throw",new Integer(52));
+ INSTS_TO_INDEX.put("jump",new Integer(53));
+ INSTS_TO_INDEX.put("branchif",new Integer(54));
+ INSTS_TO_INDEX.put("branchunless",new Integer(55));
+ INSTS_TO_INDEX.put("getinlinecache",new Integer(56));
+ INSTS_TO_INDEX.put("onceinlinecache",new Integer(57));
+ INSTS_TO_INDEX.put("setinlinecache",new Integer(58));
+ INSTS_TO_INDEX.put("opt_case_dispatch",new Integer(59));
+ INSTS_TO_INDEX.put("opt_checkenv",new Integer(60));
+ INSTS_TO_INDEX.put("opt_plus",new Integer(61));
+ INSTS_TO_INDEX.put("opt_minus",new Integer(62));
+ INSTS_TO_INDEX.put("opt_mult",new Integer(63));
+ INSTS_TO_INDEX.put("opt_div",new Integer(64));
+ INSTS_TO_INDEX.put("opt_mod",new Integer(65));
+ INSTS_TO_INDEX.put("opt_eq",new Integer(66));
+ INSTS_TO_INDEX.put("opt_lt",new Integer(67));
+ INSTS_TO_INDEX.put("opt_le",new Integer(68));
+ INSTS_TO_INDEX.put("opt_ltlt",new Integer(69));
+ INSTS_TO_INDEX.put("opt_aref",new Integer(70));
+ INSTS_TO_INDEX.put("opt_aset",new Integer(71));
+ INSTS_TO_INDEX.put("opt_length",new Integer(72));
+ INSTS_TO_INDEX.put("opt_succ",new Integer(73));
+ INSTS_TO_INDEX.put("opt_regexpmatch1",new Integer(74));
+ INSTS_TO_INDEX.put("opt_regexpmatch2",new Integer(75));
+ INSTS_TO_INDEX.put("opt_call_native_compiled",new Integer(76));
+ INSTS_TO_INDEX.put("bitblt",new Integer(77));
+ INSTS_TO_INDEX.put("answer",new Integer(78));
+ INSTS_TO_INDEX.put("getlocal_op_2",new Integer(79));
+ INSTS_TO_INDEX.put("getlocal_op_3",new Integer(80));
+ INSTS_TO_INDEX.put("getlocal_op_4",new Integer(81));
+ INSTS_TO_INDEX.put("setlocal_op_2",new Integer(82));
+ INSTS_TO_INDEX.put("setlocal_op_3",new Integer(83));
+ INSTS_TO_INDEX.put("setlocal_op_4",new Integer(84));
+ INSTS_TO_INDEX.put("getdynamic_op__wc__0",new Integer(85));
+ INSTS_TO_INDEX.put("getdynamic_op_1_0",new Integer(86));
+ INSTS_TO_INDEX.put("getdynamic_op_2_0",new Integer(87));
+ INSTS_TO_INDEX.put("getdynamic_op_3_0",new Integer(88));
+ INSTS_TO_INDEX.put("getdynamic_op_4_0",new Integer(89));
+ INSTS_TO_INDEX.put("setdynamic_op__wc__0",new Integer(90));
+ INSTS_TO_INDEX.put("setdynamic_op_1_0",new Integer(91));
+ INSTS_TO_INDEX.put("setdynamic_op_2_0",new Integer(92));
+ INSTS_TO_INDEX.put("setdynamic_op_3_0",new Integer(93));
+ INSTS_TO_INDEX.put("setdynamic_op_4_0",new Integer(94));
+ INSTS_TO_INDEX.put("putobject_op_int2fix_0_0_c_",new Integer(95));
+ INSTS_TO_INDEX.put("putobject_op_int2fix_0_1_c_",new Integer(96));
+ INSTS_TO_INDEX.put("putobject_op_qtrue",new Integer(97));
+ INSTS_TO_INDEX.put("putobject_op_qfalse",new Integer(98));
+ INSTS_TO_INDEX.put("send_op__wc___wc__qfalse_0__wc_",new Integer(99));
+ INSTS_TO_INDEX.put("send_op__wc__0_qfalse_0__wc_",new Integer(100));
+ INSTS_TO_INDEX.put("send_op__wc__1_qfalse_0__wc_",new Integer(101));
+ INSTS_TO_INDEX.put("send_op__wc__2_qfalse_0__wc_",new Integer(102));
+ INSTS_TO_INDEX.put("send_op__wc__3_qfalse_0__wc_",new Integer(103));
+ INSTS_TO_INDEX.put("send_op__wc___wc__qfalse_0x04__wc_",new Integer(104));
+ INSTS_TO_INDEX.put("send_op__wc__0_qfalse_0x04__wc_",new Integer(105));
+ INSTS_TO_INDEX.put("send_op__wc__1_qfalse_0x04__wc_",new Integer(106));
+ INSTS_TO_INDEX.put("send_op__wc__2_qfalse_0x04__wc_",new Integer(107));
+ INSTS_TO_INDEX.put("send_op__wc__3_qfalse_0x04__wc_",new Integer(108));
+ INSTS_TO_INDEX.put("send_op__wc__0_qfalse_0x0c__wc_",new Integer(109));
+ INSTS_TO_INDEX.put("unified_putobject_putobject",new Integer(110));
+ INSTS_TO_INDEX.put("unified_putobject_putstring",new Integer(111));
+ INSTS_TO_INDEX.put("unified_putobject_setlocal",new Integer(112));
+ INSTS_TO_INDEX.put("unified_putobject_setdynamic",new Integer(113));
+ INSTS_TO_INDEX.put("unified_putstring_putstring",new Integer(114));
+ INSTS_TO_INDEX.put("unified_putstring_putobject",new Integer(115));
+ INSTS_TO_INDEX.put("unified_putstring_setlocal",new Integer(116));
+ INSTS_TO_INDEX.put("unified_putstring_setdynamic",new Integer(117));
+ INSTS_TO_INDEX.put("unified_dup_setlocal",new Integer(118));
+ INSTS_TO_INDEX.put("unified_getlocal_getlocal",new Integer(119));
+ INSTS_TO_INDEX.put("unified_getlocal_putobject",new Integer(120));
+ }
+ public static int instruction(String name) {
+ return ((Integer)INSTS_TO_INDEX.get(name)).intValue();
+ }
+
+ public static final String[] INDEX_TO_NAME = new String[] {
+ "nop",
+ "getlocal",
+ "setlocal",
+ "getspecial",
+ "setspecial",
+ "getdynamic",
+ "setdynamic",
+ "getinstancevariable",
+ "setinstancevariable",
+ "getclassvariable",
+ "setclassvariable",
+ "getconstant",
+ "setconstant",
+ "getglobal",
+ "setglobal",
+ "putnil",
+ "putself",
+ "putundef",
+ "putobject",
+ "putstring",
+ "concatstrings",
+ "tostring",
+ "toregexp",
+ "newarray",
+ "duparray",
+ "expandarray",
+ "concatarray",
+ "splatarray",
+ "checkincludearray",
+ "newhash",
+ "newrange",
+ "putnot",
+ "pop",
+ "dup",
+ "dupn",
+ "swap",
+ "reput",
+ "topn",
+ "setn",
+ "emptstack",
+ "definemethod",
+ "alias",
+ "undef",
+ "defined",
+ "postexe",
+ "trace",
+ "defineclass",
+ "send",
+ "invokesuper",
+ "invokeblock",
+ "leave",
+ "finish",
+ "throw",
+ "jump",
+ "branchif",
+ "branchunless",
+ "getinlinecache",
+ "onceinlinecache",
+ "setinlinecache",
+ "opt_case_dispatch",
+ "opt_checkenv",
+ "opt_plus",
+ "opt_minus",
+ "opt_mult",
+ "opt_div",
+ "opt_mod",
+ "opt_eq",
+ "opt_lt",
+ "opt_le",
+ "opt_ltlt",
+ "opt_aref",
+ "opt_aset",
+ "opt_length",
+ "opt_succ",
+ "opt_regexpmatch1",
+ "opt_regexpmatch2",
+ "opt_call_native_compiled",
+ "bitblt",
+ "answer",
+ "getlocal_op_2",
+ "getlocal_op_3",
+ "getlocal_op_4",
+ "setlocal_op_2",
+ "setlocal_op_3",
+ "setlocal_op_4",
+ "getdynamic_op__wc__0",
+ "getdynamic_op_1_0",
+ "getdynamic_op_2_0",
+ "getdynamic_op_3_0",
+ "getdynamic_op_4_0",
+ "setdynamic_op__wc__0",
+ "setdynamic_op_1_0",
+ "setdynamic_op_2_0",
+ "setdynamic_op_3_0",
+ "setdynamic_op_4_0",
+ "putobject_op_int2fix_0_0_c_",
+ "putobject_op_int2fix_0_1_c_",
+ "putobject_op_qtrue",
+ "putobject_op_qfalse",
+ "send_op__wc___wc__qfalse_0__wc_",
+ "send_op__wc__0_qfalse_0__wc_",
+ "send_op__wc__1_qfalse_0__wc_",
+ "send_op__wc__2_qfalse_0__wc_",
+ "send_op__wc__3_qfalse_0__wc_",
+ "send_op__wc___wc__qfalse_0x04__wc_",
+ "send_op__wc__0_qfalse_0x04__wc_",
+ "send_op__wc__1_qfalse_0x04__wc_",
+ "send_op__wc__2_qfalse_0x04__wc_",
+ "send_op__wc__3_qfalse_0x04__wc_",
+ "send_op__wc__0_qfalse_0x0c__wc_",
+ "unified_putobject_putobject",
+ "unified_putobject_putstring",
+ "unified_putobject_setlocal",
+ "unified_putobject_setdynamic",
+ "unified_putstring_putstring",
+ "unified_putstring_putobject",
+ "unified_putstring_setlocal",
+ "unified_putstring_setdynamic",
+ "unified_dup_setlocal",
+ "unified_getlocal_getlocal",
+ "unified_getlocal_putobject"};
+
+ public static String name(int index) {
+ return INDEX_TO_NAME[index];
+ }
+
public static final int ARGS_SPLAT_FLAG = 1;
public static final int ARGS_BLOCKARG_FLAG = 2;
public static final int FCALL_FLAG = 4;
View
62 src/org/jruby/ast/executable/YARVInstructions.java.template
@@ -0,0 +1,62 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Charles O Nutter <headius@headius.com>
+ * Copyright (C) 2007 Ola Bini <ola@ologix.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+package org.jruby.ast.executable;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * AUTOGENERATED. Change template, not generated file.
+ */
+public abstract class YARVInstructions {<% INSTRUCTIONS.each_with_index do |ins, ix| %>
+ public static final int <%= ins.name.upcase %> = <%= ix %>;<% end %>
+
+ public static final Map INSTS_TO_INDEX = new HashMap();
+ static {<% INSTRUCTIONS.each_with_index do |ins, ix| %>
+ INSTS_TO_INDEX.put("<%= ins.name %>",new Integer(<%=ix%>));<% end %>
+ }
+ public static int instruction(String name) {
+ return ((Integer)INSTS_TO_INDEX.get(name)).intValue();
+ }
+
+ public static final String[] INDEX_TO_NAME = new String[] { <% sep=''; INSTRUCTIONS.each do |ins| %><%=sep%>
+ "<%=ins.name%><% sep=', ' %>"<% end %>};
+
+ public static String name(int index) {
+ return INDEX_TO_NAME[index];
+ }
+
+ public static final int ARGS_SPLAT_FLAG = 1;
+ public static final int ARGS_BLOCKARG_FLAG = 2;
+ public static final int FCALL_FLAG = 4;
+ public static final int VCALL_FLAG = 8;
+ public static final int TAILCALL_FLAG = 16;
+ public static final int TAILRECURSION_FLAG = 32;
+ public static final int SUPER = 64;
+}
View
247 src/org/jruby/ast/executable/YARVMachine.java
@@ -21,91 +21,8 @@
public class YARVMachine {
private static final boolean TAILCALL_OPT = Boolean.getBoolean("jruby.tailcall.enabled");
- private static final Map INSTS = new HashMap();
- static {
- INSTS.put("nop",new Integer(0));
- INSTS.put("getlocal", new Integer(1));
- INSTS.put("setlocal", new Integer(2));
- INSTS.put("getspecial", new Integer(3));
- INSTS.put("setspecial", new Integer(4));
- INSTS.put("getdynamic", new Integer(5));
- INSTS.put("setdynamic", new Integer(6));
- INSTS.put("getinstancevariable", new Integer(7));
- INSTS.put("setinstancevariable", new Integer(8));
- INSTS.put("getclassvariable", new Integer(9));
- INSTS.put("setclassvariable", new Integer(10));
- INSTS.put("getconstant", new Integer(11));
- INSTS.put("setconstant", new Integer(12));
- INSTS.put("getglobal", new Integer(13));
- INSTS.put("setglobal", new Integer(14));
- INSTS.put("putnil", new Integer(15));
- INSTS.put("putself", new Integer(16));
- INSTS.put("putundef", new Integer(17));
- INSTS.put("putobject", new Integer(18));
- INSTS.put("putstring", new Integer(19));
- INSTS.put("concatstrings", new Integer(20));
- INSTS.put("tostring", new Integer(21));
- INSTS.put("toregexp", new Integer(22));
- INSTS.put("newarray", new Integer(23));
- INSTS.put("duparray", new Integer(24));
- INSTS.put("expandarray", new Integer(25));
- INSTS.put("concatarray", new Integer(26));
- INSTS.put("splatarray", new Integer(27));
- INSTS.put("checkincludearray", new Integer(28));
- INSTS.put("newhash", new Integer(29));
- INSTS.put("newrange", new Integer(30));
- INSTS.put("putnot", new Integer(31));
- INSTS.put("pop", new Integer(32));
- INSTS.put("dup", new Integer(33));
- INSTS.put("dupn", new Integer(34));
- INSTS.put("swap", new Integer(35));
- INSTS.put("reput", new Integer(36));
- INSTS.put("topn", new Integer(37));
- INSTS.put("setn", new Integer(38));
- INSTS.put("emptstack", new Integer(39));
- INSTS.put("definemethod", new Integer(40));
- INSTS.put("alias", new Integer(41));
- INSTS.put("undef", new Integer(42));
- INSTS.put("defined", new Integer(43));
- INSTS.put("postexe", new Integer(44));
- INSTS.put("trace", new Integer(45));
- INSTS.put("defineclass", new Integer(46));
- INSTS.put("send", new Integer(47));
- INSTS.put("invokesuper", new Integer(48));
- INSTS.put("invokeblock", new Integer(49));
- INSTS.put("leave", new Integer(50));
- INSTS.put("finish", new Integer(51));
- INSTS.put("throw", new Integer(52));
- INSTS.put("jump", new Integer(53));
- INSTS.put("branchif", new Integer(54));
- INSTS.put("branchunless", new Integer(55));
- INSTS.put("getinlinecache", new Integer(56));
- INSTS.put("onceinlinecache", new Integer(57));
- INSTS.put("setinlinecache", new Integer(58));
- INSTS.put("opt_case_dispatch", new Integer(59));
- INSTS.put("opt_checkenv", new Integer(60));
- INSTS.put("opt_plus", new Integer(61));
- INSTS.put("opt_minus", new Integer(62));
- INSTS.put("opt_mult", new Integer(63));
- INSTS.put("opt_div", new Integer(64));
- INSTS.put("opt_mod", new Integer(65));
- INSTS.put("opt_eq", new Integer(66));
- INSTS.put("opt_lt", new Integer(67));
- INSTS.put("opt_le", new Integer(68));
- INSTS.put("opt_ltlt", new Integer(69));
- INSTS.put("opt_aref", new Integer(70));
- INSTS.put("opt_aset", new Integer(71));
- INSTS.put("opt_length", new Integer(72));
- INSTS.put("opt_succ", new Integer(73));
- INSTS.put("opt_regexpmatch1", new Integer(74));
- INSTS.put("opt_regexpmatch2", new Integer(75));
- INSTS.put("opt_call_native_compiled", new Integer(76));
- INSTS.put("bitblt", new Integer(77));
- INSTS.put("answer", new Integer(78));
- }
-
public static int instruction(String name) {
- return ((Integer)INSTS.get(name)).intValue();
+ return YARVInstructions.instruction(name);
}
public static class InstructionSequence {
@@ -203,16 +120,16 @@ public IRubyObject exec(ThreadContext context, IRubyObject self, DynamicScope sc
context.getCurrentScope().getValues()[(int)bytecodes[ip].l_op0] = stack[stackTop--];
break;
case YARVInstructions.GETSPECIAL:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." + YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SETSPECIAL:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." + YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.GETDYNAMIC:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." + YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SETDYNAMIC:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.GETINSTANCEVARIABLE:
stack[++stackTop] = self.getInstanceVariable(bytecodes[ip].s_op0);
@@ -259,10 +176,10 @@ public IRubyObject exec(ThreadContext context, IRubyObject self, DynamicScope sc
module.setConstant(bytecodes[ip].s_op0,stack[stackTop--]);
break;
case YARVInstructions.GETGLOBAL:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SETGLOBAL:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.PUTNIL:
stack[++stackTop] = context.getRuntime().getNil();
@@ -272,7 +189,7 @@ public IRubyObject exec(ThreadContext context, IRubyObject self, DynamicScope sc
break;
case YARVInstructions.PUTUNDEF:
// ko1 said this is going away
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.PUTOBJECT:
stack[++stackTop] = bytecodes[ip].o_op0;
@@ -294,7 +211,7 @@ public IRubyObject exec(ThreadContext context, IRubyObject self, DynamicScope sc
}
break;
case YARVInstructions.TOREGEXP:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.NEWARRAY: {
int size = (int)bytecodes[ip].l_op0;
@@ -306,26 +223,26 @@ public IRubyObject exec(ThreadContext context, IRubyObject self, DynamicScope sc
break;
}
case YARVInstructions.DUPARRAY:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.EXPANDARRAY:
// masgn array to values
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.CONCATARRAY:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SPLATARRAY:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.CHECKINCLUDEARRAY:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.NEWHASH:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.NEWRANGE:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.PUTNOT:
stack[stackTop+1] = stack[stackTop].isTrue() ? runtime.getFalse() : runtime.getTrue();
@@ -351,7 +268,7 @@ public IRubyObject exec(ThreadContext context, IRubyObject self, DynamicScope sc
stack[stackTop] = stack[stackTop - 1];
stack[stackTop - 1] = stack[stackTop + 1];
case YARVInstructions.REPUT:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.TOPN: {
int n = (int)bytecodes[ip].l_op0;
@@ -417,22 +334,22 @@ public IRubyObject exec(ThreadContext context, IRubyObject self, DynamicScope sc
stack[++stackTop] = runtime.getNil();
break;
case YARVInstructions.ALIAS:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.UNDEF:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.DEFINED:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.POSTEXE:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.TRACE:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.DEFINECLASS:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SEND: {
context.beginCallArgs();
@@ -477,18 +394,18 @@ public IRubyObject exec(ThreadContext context, IRubyObject self, DynamicScope sc
break;
}
case YARVInstructions.INVOKESUPER:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.INVOKEBLOCK:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.LEAVE:
break yarvloop;
case YARVInstructions.FINISH:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.THROW:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.JUMP:
ip = (int)bytecodes[ip].l_op0;
@@ -508,19 +425,19 @@ public IRubyObject exec(ThreadContext context, IRubyObject self, DynamicScope sc
}
continue yarvloop;
case YARVInstructions.GETINLINECACHE:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.ONCEINLINECACHE:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SETINLINECACHE:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.OPT_CASE_DISPATCH:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.OPT_CHECKENV:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.OPT_PLUS:
other = stack[stackTop--];
@@ -596,139 +513,139 @@ public IRubyObject exec(ThreadContext context, IRubyObject self, DynamicScope sc
stack[++stackTop] = recv.callMethod(context,"=~",other);
break;
case YARVInstructions.OPT_CALL_NATIVE_COMPILED:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.BITBLT:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.ANSWER:
stack[++stackTop] = runtime.newFixnum(42);
break;
case YARVInstructions.GETLOCAL_OP_2:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.GETLOCAL_OP_3:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.GETLOCAL_OP_4:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SETLOCAL_OP_2:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SETLOCAL_OP_3:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SETLOCAL_OP_4:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.GETDYNAMIC_OP__WC__0:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.GETDYNAMIC_OP_1_0:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.GETDYNAMIC_OP_2_0:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.GETDYNAMIC_OP_3_0:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.GETDYNAMIC_OP_4_0:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SETDYNAMIC_OP__WC__0:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SETDYNAMIC_OP_1_0:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SETDYNAMIC_OP_2_0:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SETDYNAMIC_OP_3_0:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SETDYNAMIC_OP_4_0:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.PUTOBJECT_OP_INT2FIX_0_0_C_:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.PUTOBJECT_OP_INT2FIX_0_1_C_:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.PUTOBJECT_OP_QTRUE:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.PUTOBJECT_OP_QFALSE:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SEND_OP__WC___WC__QFALSE_0__WC_:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SEND_OP__WC__0_QFALSE_0__WC_:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SEND_OP__WC__1_QFALSE_0__WC_:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SEND_OP__WC__2_QFALSE_0__WC_:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.SEND_OP__WC__3_QFALSE_0__WC_:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
- case YARVInstructions.SEND_OP__WC___WC__QFALSE_0x04__WC_:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ case YARVInstructions.SEND_OP__WC___WC__QFALSE_0X04__WC_:
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
- case YARVInstructions.SEND_OP__WC__0_QFALSE_0x04__WC_:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ case YARVInstructions.SEND_OP__WC__0_QFALSE_0X04__WC_:
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
- case YARVInstructions.SEND_OP__WC__1_QFALSE_0x04__WC_:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ case YARVInstructions.SEND_OP__WC__1_QFALSE_0X04__WC_:
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
- case YARVInstructions.SEND_OP__WC__2_QFALSE_0x04__WC_:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ case YARVInstructions.SEND_OP__WC__2_QFALSE_0X04__WC_:
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
- case YARVInstructions.SEND_OP__WC__3_QFALSE_0x04__WC_:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ case YARVInstructions.SEND_OP__WC__3_QFALSE_0X04__WC_:
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
- case YARVInstructions.SEND_OP__WC__0_QFALSE_0x0c__WC_:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ case YARVInstructions.SEND_OP__WC__0_QFALSE_0X0C__WC_:
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.UNIFIED_PUTOBJECT_PUTOBJECT:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.UNIFIED_PUTOBJECT_PUTSTRING:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.UNIFIED_PUTOBJECT_SETLOCAL:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.UNIFIED_PUTOBJECT_SETDYNAMIC:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.UNIFIED_PUTSTRING_PUTSTRING:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.UNIFIED_PUTSTRING_PUTOBJECT:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.UNIFIED_PUTSTRING_SETLOCAL:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.UNIFIED_PUTSTRING_SETDYNAMIC:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.UNIFIED_DUP_SETLOCAL:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.UNIFIED_GETLOCAL_GETLOCAL:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
case YARVInstructions.UNIFIED_GETLOCAL_PUTOBJECT:
- System.err.println("Not implemented, YARVMachine." + bytecodes[ip].bytecode);
+ System.err.println("Not implemented, YARVMachine." +YARVInstructions.name(bytecodes[ip].bytecode));
break;
}
ip++;
View
128 tool/yarvinsns.rb
@@ -0,0 +1,128 @@
+
+# Run this file to regenerate all files automatically created
+# from instruction information.
+#
+# The parameters provided points to Ruby trunk defs files
+#
+# ex:
+# ruby yarvinsns.rb ~/src/ruby-trunk/insns.def ~/src/ruby-trunk/opt_insn_unif.def ~/src/ruby-trunk/opt_operand.def
+
+insnsFile = ARGV[0]
+uniFile = ARGV[1]
+operandFile = ARGV[2]
+
+defs = []
+in_def = false
+cur_def = ""
+open(insnsFile) do |f|
+ f.each_line do |l|
+ if !in_def && /^DEFINE_INSN$/ =~ l
+ in_def = true
+ else
+ if in_def && /^\{$/ =~ l
+ in_def = false
+ defs << cur_def
+ cur_def = ""
+ end
+ if in_def
+ cur_def << l
+ end
+ end
+ end
+end
+
+$typeMappings = {
+ 'ISEQ' => 'YARVMachine.InstructionSequence',
+ 'dindex_t' => 'long',
+ 'lindex_t' => 'long',
+ 'num_t' => 'long',
+ 'OFFSET' => 'long',
+ 'CDHASH' => 'CDHASH???',
+ 'IC' => 'IC???',
+ 'GENTRY' => 'GENTRY???',
+ 'ID' => 'ID???',
+ 'VALUE' => 'IRubyObject',
+ '...' => :any,
+}
+
+class Value
+ attr_accessor :type, :name
+ def initialize(type, name='any')
+ @type, @name = $typeMappings[type], name
+ end
+end
+
+class Instruction
+ attr_accessor :name, :ops, :pops, :rets
+end
+
+
+instructions = []
+
+def get_instruction(str)
+ i = Instruction.new
+ sarr = str.split(/\n/)
+ i.name = sarr[0]
+ i.ops = sarr[1][/\(.*?\)/][1..-2].split(/,/).map {|v| Value.new *v.strip.split(/ +/)}
+ i.pops = sarr[2][/\(.*?\)/][1..-2].split(/,/).map {|v| Value.new *v.strip.split(/ +/)}
+ i.rets = sarr[3][/\(.*?\)/][1..-2].split(/,/).map {|v| Value.new *v.strip.split(/ +/)}
+ i
+end
+
+for idef in defs
+ instructions << get_instruction(idef)
+end
+
+def reformat(v)
+ if "*" == v
+ '_wc_'
+ elsif /^int2fix\((.*)\)$/ =~ v
+ "int2fix_0_#{$1}_c_"
+ else
+ v
+ end
+end
+
+open(operandFile) do |f|
+ f.each do |l|
+ if /^#|__END__|^$/ =~ l.strip
+ next
+ end
+ i = Instruction.new
+ nm = l[/^[^ ]+/]
+ rest = l[nm.length+1..-1].strip
+ i.name = nm + "_op_" + rest.split(/, /).map {|n| reformat(n.downcase) }.join('_')
+ i.ops = []
+ i.pops = []
+ i.rets = []
+ instructions << i
+ end
+end
+
+open(uniFile) do |f|
+ f.each do |l|
+ if /^#|__END__|^$/ =~ l.strip
+ next
+ end
+ i = Instruction.new
+ i.name = "unified_#{l.strip.split(/ +/).join('_')}"
+ i.ops = []
+ i.pops = []
+ i.rets = []
+ instructions << i
+ end
+end
+
+INSTRUCTIONS = instructions
+
+b = binding
+
+require 'erb'
+
+Dir["**/*.template"].each do |file|
+ $stderr.puts "Processing #{file}"
+ f = ERB.new(File.read(file))
+ File.open(file[0..-10],"w") do |of|
+ of.write(f.result(b))
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.