public void loadLocal(LocalVariable local) { mAssembler.loadLocal(local); }
public void loadLocal(LocalVariable local) { mAssembler.loadLocal(local); }
private static enum Mode { KEY, DATA, SERIAL }
private static enum Mode { KEY, DATA, SERIAL }
/** * Push decoding instanceVar to stack in preparation to calling * storePropertyValue. * * @param ordinal zero-based property ordinal, used only if instanceVar * refers to an object array. * @param instanceVar local variable referencing Storable instance, * defaults to "this" if null. If variable type is an Object array, then * property values are written to the runtime value of this array instead * of a Storable instance. * @see #storePropertyValue storePropertyValue */ protected void pushDecodingInstanceVar(CodeAssembler a, int ordinal, LocalVariable instanceVar) { if (instanceVar == null) { // Push this to stack in preparation for storing a property. a.loadThis(); } else if (instanceVar.getType() != TypeDesc.forClass(Object[].class)) { // Push reference to stack in preparation for storing a property. a.loadLocal(instanceVar); } else { // Push array and index to stack in preparation for storing a property. a.loadLocal(instanceVar); a.loadConstant(ordinal); } }
/** * Push decoding instanceVar to stack in preparation to calling * storePropertyValue. * * @param ordinal zero-based property ordinal, used only if instanceVar * refers to an object array. * @param instanceVar local variable referencing Storable instance, * defaults to "this" if null. If variable type is an Object array, then * property values are written to the runtime value of this array instead * of a Storable instance. * @see #storePropertyValue storePropertyValue */ protected void pushDecodingInstanceVar(CodeAssembler a, int ordinal, LocalVariable instanceVar) { if (instanceVar == null) { // Push this to stack in preparation for storing a property. a.loadThis(); } else if (instanceVar.getType() != TypeDesc.forClass(Object[].class)) { // Push reference to stack in preparation for storing a property. a.loadLocal(instanceVar); } else { // Push array and index to stack in preparation for storing a property. a.loadLocal(instanceVar); a.loadConstant(ordinal); } }
@Override protected void extraDataEncoding(CodeAssembler a, LocalVariable dataVar, int prefix, int suffix) { switch (mCompressionType) { case GZIP: TypeDesc byteArrayType = TypeDesc.forClass(byte[].class); a.loadLocal(dataVar); a.loadConstant(prefix); a.invokeStatic(GzipCompressor.class.getName(), "compress", byteArrayType, new TypeDesc[] {byteArrayType, TypeDesc.INT}); a.storeLocal(dataVar); break; } }
@Override protected void extraDataDecoding(CodeAssembler a, LocalVariable dataVar, int prefix, int suffix) { switch (mCompressionType) { case GZIP: TypeDesc byteArrayType = TypeDesc.forClass(byte[].class); a.loadLocal(dataVar); a.loadConstant(prefix); a.invokeStatic(GzipCompressor.class.getName(), "decompress", byteArrayType, new TypeDesc[] {byteArrayType, TypeDesc.INT}); a.storeLocal(dataVar); break; } }
@Override protected void extraDataEncoding(CodeAssembler a, LocalVariable dataVar, int prefix, int suffix) { switch (mCompressionType) { case GZIP: TypeDesc byteArrayType = TypeDesc.forClass(byte[].class); a.loadLocal(dataVar); a.loadConstant(prefix); a.invokeStatic(GzipCompressor.class.getName(), "compress", byteArrayType, new TypeDesc[] {byteArrayType, TypeDesc.INT}); a.storeLocal(dataVar); break; } }
@Override protected void extraDataDecoding(CodeAssembler a, LocalVariable dataVar, int prefix, int suffix) { switch (mCompressionType) { case GZIP: TypeDesc byteArrayType = TypeDesc.forClass(byte[].class); a.loadLocal(dataVar); a.loadConstant(prefix); a.invokeStatic(GzipCompressor.class.getName(), "decompress", byteArrayType, new TypeDesc[] {byteArrayType, TypeDesc.INT}); a.storeLocal(dataVar); break; } }
a.loadLocal(encodedVar); a.loadConstant(offset); a.loadFromArray(TypeDesc.BYTE); a.storeLocal(actualGeneration); a.loadLocal(actualGeneration); Label compareGeneration = a.createLabel(); a.ifZeroComparisonBranch(compareGeneration, ">="); a.loadLocal(actualGeneration); a.loadConstant(24); a.math(Opcode.ISHL); a.math(Opcode.IAND); for (int i=1; i<4; i++) { a.loadLocal(encodedVar); a.loadConstant(offset + i); a.loadFromArray(TypeDesc.BYTE); a.loadLocal(actualGeneration); Label generationMatches = a.createLabel(); a.ifComparisonBranch(generationMatches, "=="); a.loadLocal(actualGeneration); a.branch(altGenerationHandler); } else { a.loadLocal(actualGeneration); // actual generation a.invokeConstructor(corruptEncodingEx, new TypeDesc[] {TypeDesc.INT, TypeDesc.INT}); a.throwObject();
a.loadLocal(encodedVar); a.loadConstant(offset); a.loadFromArray(TypeDesc.BYTE); a.storeLocal(actualGeneration); a.loadLocal(actualGeneration); Label compareGeneration = a.createLabel(); a.ifZeroComparisonBranch(compareGeneration, ">="); a.loadLocal(actualGeneration); a.loadConstant(24); a.math(Opcode.ISHL); a.math(Opcode.IAND); for (int i=1; i<4; i++) { a.loadLocal(encodedVar); a.loadConstant(offset + i); a.loadFromArray(TypeDesc.BYTE); a.loadLocal(actualGeneration); Label generationMatches = a.createLabel(); a.ifComparisonBranch(generationMatches, "=="); a.loadLocal(actualGeneration); a.branch(altGenerationHandler); } else { a.loadLocal(actualGeneration); // actual generation a.invokeConstructor(corruptEncodingEx, new TypeDesc[] {TypeDesc.INT, TypeDesc.INT}); a.throwObject();
/** * Generates code to push RawSupport instance to the stack. RawSupport is * available only in Storable instances. If instanceVar is an Object[], a * SupportException is thrown. * * @param instanceVar Storable instance or array of property values. Null * is storable instance of "this". */ protected void pushRawSupport(CodeAssembler a, LocalVariable instanceVar) throws SupportException { boolean isObjectArrayInstanceVar = instanceVar != null && instanceVar.getType() == TypeDesc.forClass(Object[].class); if (isObjectArrayInstanceVar) { throw new SupportException("Lob properties not supported"); } if (instanceVar == null) { a.loadThis(); } else { a.loadLocal(instanceVar); } a.loadField(SUPPORT_FIELD_NAME, TypeDesc.forClass(TriggerSupport.class)); a.checkCast(TypeDesc.forClass(RawSupport.class)); }
/** * Generates code to push RawSupport instance to the stack. RawSupport is * available only in Storable instances. If instanceVar is an Object[], a * SupportException is thrown. * * @param instanceVar Storable instance or array of property values. Null * is storable instance of "this". */ protected void pushRawSupport(CodeAssembler a, LocalVariable instanceVar) throws SupportException { boolean isObjectArrayInstanceVar = instanceVar != null && instanceVar.getType() == TypeDesc.forClass(Object[].class); if (isObjectArrayInstanceVar) { throw new SupportException("Lob properties not supported"); } if (instanceVar == null) { a.loadThis(); } else { a.loadLocal(instanceVar); } a.loadField(SUPPORT_FIELD_NAME, TypeDesc.forClass(TriggerSupport.class)); a.checkCast(TypeDesc.forClass(RawSupport.class)); }
/** * @param partialStartVar must not be null */ private Label[] jumpToPartialEntryPoints(CodeAssembler a, LocalVariable partialStartVar, int propertyCount) { // Create all the entry points for offset var, whose locations will be // set later. int[] cases = new int[propertyCount]; Label[] entryPoints = new Label[propertyCount]; for (int i=0; i<propertyCount; i++) { cases[i] = i; entryPoints[i] = a.createLabel(); } // Now jump in! Label errorLoc = a.createLabel(); a.loadLocal(partialStartVar); a.switchBranch(cases, entryPoints, errorLoc); errorLoc.setLocation(); TypeDesc errorType = TypeDesc.forClass(IllegalArgumentException.class); a.newObject(errorType); a.dup(); a.loadConstant("Illegal partial start offset"); a.invokeConstructor(errorType, new TypeDesc[] {TypeDesc.STRING}); a.throwObject(); return entryPoints; }
/** * @param partialStartVar must not be null */ private Label[] jumpToPartialEntryPoints(CodeAssembler a, LocalVariable partialStartVar, int propertyCount) { // Create all the entry points for offset var, whose locations will be // set later. int[] cases = new int[propertyCount]; Label[] entryPoints = new Label[propertyCount]; for (int i=0; i<propertyCount; i++) { cases[i] = i; entryPoints[i] = a.createLabel(); } // Now jump in! Label errorLoc = a.createLabel(); a.loadLocal(partialStartVar); a.switchBranch(cases, entryPoints, errorLoc); errorLoc.setLocation(); TypeDesc errorType = TypeDesc.forClass(IllegalArgumentException.class); a.newObject(errorType); a.dup(); a.loadConstant("Illegal partial start offset"); a.invokeConstructor(errorType, new TypeDesc[] {TypeDesc.STRING}); a.throwObject(); return entryPoints; }