public static void push_array(CodeEmitter e, Object[] array) { e.push(array.length); e.newarray(Type.getType(remapComponentType(array.getClass().getComponentType()))); for (int i = 0; i < array.length; i++) { e.dup(); e.push(i); push_object(e, array[i]); e.aastore(); } }
public static void push_array(CodeEmitter e, Object[] array) { e.push(array.length); e.newarray(Type.getType(remapComponentType(array.getClass().getComponentType()))); for (int i = 0; i < array.length; i++) { e.dup(); e.push(i); push_object(e, array[i]); e.aastore(); } }
/** * Allocates and fills an Object[] array with the arguments to the * current method. Primitive values are inserted as their boxed * (Object) equivalents. */ public void create_arg_array() { /* generates: Object[] args = new Object[]{ arg1, new Integer(arg2) }; */ push(state.argumentTypes.length); newarray(); for (int i = 0; i < state.argumentTypes.length; i++) { dup(); push(i); load_arg(i); box(state.argumentTypes[i]); aastore(); } }
/** * Allocates and fills an Object[] array with the arguments to the * current method. Primitive values are inserted as their boxed * (Object) equivalents. */ public void create_arg_array() { /* generates: Object[] args = new Object[]{ arg1, new Integer(arg2) }; */ push(state.argumentTypes.length); newarray(); for (int i = 0; i < state.argumentTypes.length; i++) { dup(); push(i); load_arg(i); box(state.argumentTypes[i]); aastore(); } }
private void initFieldProvider(String[] names) { CodeEmitter e = getStaticHook(); EmitUtils.push_object(e, names); e.putstatic(getClassType(), FIELD_NAMES, Constants.TYPE_STRING_ARRAY); e.push(names.length); e.newarray(Constants.TYPE_CLASS); e.dup(); for(int i = 0; i < names.length; i++ ){ e.dup(); e.push(i); Type type = (Type)fields.get(names[i]); EmitUtils.load_class(e, type); e.aastore(); } e.putstatic(getClassType(), FIELD_TYPES, Constants.TYPE_CLASS_ARRAY); }
private void initFieldProvider(String[] names) { CodeEmitter e = getStaticHook(); EmitUtils.push_object(e, names); e.putstatic(getClassType(), FIELD_NAMES, Constants.TYPE_STRING_ARRAY); e.push(names.length); e.newarray(Constants.TYPE_CLASS); e.dup(); for(int i = 0; i < names.length; i++ ){ e.dup(); e.push(i); Type type = (Type)fields.get(names[i]); EmitUtils.load_class(e, type); e.aastore(); } e.putstatic(getClassType(), FIELD_TYPES, Constants.TYPE_CLASS_ARRAY); }
private void emitNewInstanceCallback(ClassEmitter ce) { CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, SINGLE_NEW_INSTANCE, null); switch (callbackTypes.length) { case 0: // TODO: make sure Callback is null break; case 1: // for now just make a new array; TODO: optimize e.push(1); e.newarray(CALLBACK); e.dup(); e.push(0); e.load_arg(0); e.aastore(); e.invoke_static(getThisType(e), SET_THREAD_CALLBACKS); break; default: e.throw_exception(ILLEGAL_STATE_EXCEPTION, "More than one callback object required"); } emitCommonNewInstance(e); }
private void generateGet(final Class target, final Method[] getters) { CodeEmitter e = begin_method(Constants.ACC_PUBLIC, GET_PROPERTY_VALUES, null); if (getters.length > 0) { e.load_arg(0); e.checkcast(Type.getType(target)); Local bean = e.make_local(); e.store_local(bean); for (int i = 0; i < getters.length; i++) { if (getters[i] != null) { MethodInfo getter = ReflectUtils.getMethodInfo(getters[i]); e.load_arg(1); e.push(i); e.load_local(bean); e.invoke(getter); e.box(getter.getSignature().getReturnType()); e.aastore(); } } } e.return_value(); e.end_method(); }
private void emitNewInstanceCallback(ClassEmitter ce) { CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, SINGLE_NEW_INSTANCE, null); switch (callbackTypes.length) { case 0: // TODO: make sure Callback is null break; case 1: // for now just make a new array; TODO: optimize e.push(1); e.newarray(CALLBACK); e.dup(); e.push(0); e.load_arg(0); e.aastore(); e.invoke_static(getThisType(e), SET_THREAD_CALLBACKS); break; default: e.throw_exception(ILLEGAL_STATE_EXCEPTION, "More than one callback object required"); } emitCommonNewInstance(e); }
private void generateGet(final Class target, final Method[] getters) { CodeEmitter e = begin_method(Constants.ACC_PUBLIC, GET_PROPERTY_VALUES, null); if (getters.length > 0) { e.load_arg(0); e.checkcast(Type.getType(target)); Local bean = e.make_local(); e.store_local(bean); for (int i = 0; i < getters.length; i++) { if (getters[i] != null) { MethodInfo getter = ReflectUtils.getMethodInfo(getters[i]); e.load_arg(1); e.push(i); e.load_local(bean); e.invoke(getter); e.box(getter.getSignature().getReturnType()); e.aastore(); } } } e.return_value(); e.end_method(); }
private void emitGetCallbacks(ClassEmitter ce) { CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, GET_CALLBACKS, null); e.load_this(); e.invoke_static_this(BIND_CALLBACKS); e.load_this(); e.push(callbackTypes.length); e.newarray(CALLBACK); for (int i = 0; i < callbackTypes.length; i++) { e.dup(); e.push(i); e.load_this(); e.getfield(getCallbackField(i)); e.aastore(); } e.return_value(); e.end_method(); }
private void emitGetCallbacks(ClassEmitter ce) { CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, GET_CALLBACKS, null); e.load_this(); e.invoke_static_this(BIND_CALLBACKS); e.load_this(); e.push(callbackTypes.length); e.newarray(CALLBACK); for (int i = 0; i < callbackTypes.length; i++) { e.dup(); e.push(i); e.load_this(); e.getfield(getCallbackField(i)); e.aastore(); } e.return_value(); e.end_method(); }
public static void push_array(CodeEmitter e, Object[] array) { e.push(array.length); e.newarray(Type.getType(remapComponentType(array.getClass().getComponentType()))); for (int i = 0; i < array.length; i++) { e.dup(); e.push(i); push_object(e, array[i]); e.aastore(); } }
public static void push_array(CodeEmitter e, Object[] array) { e.push(array.length); e.newarray(Type.getType(remapComponentType(array.getClass().getComponentType()))); for (int i = 0; i < array.length; i++) { e.dup(); e.push(i); push_object(e, array[i]); e.aastore(); } }
public static void push_array(CodeEmitter e, Object[] array) { e.push(array.length); e.newarray(Type.getType(remapComponentType(array.getClass().getComponentType()))); for (int i = 0; i < array.length; i++) { e.dup(); e.push(i); push_object(e, array[i]); e.aastore(); } }
private void initFieldProvider(String[] names) { CodeEmitter e = getStaticHook(); EmitUtils.push_object(e, names); e.putstatic(getClassType(), FIELD_NAMES, Constants.TYPE_STRING_ARRAY); e.push(names.length); e.newarray(Constants.TYPE_CLASS); e.dup(); for(int i = 0; i < names.length; i++ ){ e.dup(); e.push(i); Type type = (Type)fields.get(names[i]); EmitUtils.load_class(e, type); e.aastore(); } e.putstatic(getClassType(), FIELD_TYPES, Constants.TYPE_CLASS_ARRAY); }
private void initFieldProvider(String[] names) { CodeEmitter e = getStaticHook(); EmitUtils.push_object(e, names); e.putstatic(getClassType(), FIELD_NAMES, Constants.TYPE_STRING_ARRAY); e.push(names.length); e.newarray(Constants.TYPE_CLASS); e.dup(); for(int i = 0; i < names.length; i++ ){ e.dup(); e.push(i); Type type = (Type)fields.get(names[i]); EmitUtils.load_class(e, type); e.aastore(); } e.putstatic(getClassType(), FIELD_TYPES, Constants.TYPE_CLASS_ARRAY); }
private void emitGetCallbacks(ClassEmitter ce) { CodeEmitter e = ce.begin_method(Constants.ACC_PUBLIC, GET_CALLBACKS, null); e.load_this(); e.invoke_static_this(BIND_CALLBACKS); e.load_this(); e.push(callbackTypes.length); e.newarray(CALLBACK); for (int i = 0; i < callbackTypes.length; i++) { e.dup(); e.push(i); e.load_this(); e.getfield(getCallbackField(i)); e.aastore(); } e.return_value(); e.end_method(); }