1 9 10 package org.jruby.runtime; 11 12 16 public class MethodIndex { 17 public static final byte NO_INDEX = 0; 18 public static final byte OP_PLUS = 1; 19 public static final byte OP_MINUS = 2; 20 public static final byte OP_LT = 3; 21 public static final byte AREF = 4; 22 public static final byte ASET = 5; 23 public static final byte POP = 6; 24 public static final byte PUSH = 7; 25 public static final byte NIL_P = 8; 26 public static final byte EQUALEQUAL = 9; 27 public static final byte UNSHIFT = 10; 28 public static final byte OP_GE = 11; 29 public static final byte OP_LSHIFT = 12; 30 public static final byte EMPTY_P = 13; 31 public static final byte MAX_METHODS = 14; 32 33 34 public MethodIndex() { 35 } 36 37 public static byte getIndex(String methodName) { 38 if (methodName.length() == 1) { 39 switch (methodName.charAt(0)) { 40 case '+': return OP_PLUS; 41 case '-': return OP_MINUS; 42 case '<': return OP_LT; 43 default: return NO_INDEX; 44 } 45 } 46 if (methodName == "[]") return AREF; 47 if (methodName == "[]=") return ASET; 48 if (methodName == "pop") return POP; 49 if (methodName == "push") return PUSH; 50 if (methodName == "nil?") return NIL_P; 51 if (methodName == "==") return EQUALEQUAL; 52 if (methodName == "unshift") return UNSHIFT; 53 if (methodName == ">=") return OP_GE; 54 if (methodName == "<<") return OP_LSHIFT; 55 if (methodName == "empty?") return EMPTY_P; 56 return NO_INDEX; 57 } 58 } 59 | Popular Tags |