@Override @SuppressWarnings("unchecked") public <V extends BValue> V getEmptyValue() { return (V) new BByte((byte) 0); }
@Override @SuppressWarnings("unchecked") public <V extends BValue> V getZeroValue() { return (V) new BByte((byte) 0); }
private static BValue getValue(ResultSet resultSet, BType bType) throws SQLException { int type = bType.getTag(); switch (type) { case TypeTags.INT_TAG: return new BInteger(resultSet.getLong(2)); case TypeTags.STRING_TAG: return new BString(resultSet.getString(2)); case TypeTags.BYTE_TAG: return new BByte(resultSet.getByte(2)); case TypeTags.FLOAT_TAG: return new BFloat(resultSet.getDouble(2)); case TypeTags.BOOLEAN_TAG: return new BBoolean(resultSet.getBoolean(2)); case TypeTags.XML_TAG: return XMLUtils.parse(resultSet.getString(2)); case TypeTags.JSON_TAG: return JsonParser.parse(resultSet.getString(2)); default: throw new BallerinaException("unsupported data type " + type + ", for channel data"); } }
private static BRefType extractValue(StackFrame data, BType type, int reg) { BRefType result; switch (type.getTag()) { case TypeTags.INT_TAG: result = new BInteger(data.longRegs[reg]); break; case TypeTags.BYTE_TAG: result = new BByte((byte) data.intRegs[reg]); break; case TypeTags.FLOAT_TAG: result = new BFloat(data.doubleRegs[reg]); break; case TypeTags.STRING_TAG: result = new BString(data.stringRegs[reg]); break; case TypeTags.BOOLEAN_TAG: result = new BBoolean(data.intRegs[reg] > 0); break; default: result = data.refRegs[reg]; } return result; }
break; case TypeTags.BYTE_TAG: returnValues[i] = new BByte((byte) data.intRegs[retRegs[i]]); break; case TypeTags.FLOAT_TAG:
private static void convertValueTypes(Strand strand, StackFrame sf, int resultRegIndex, TypeRefCPEntry typeRefCPEntry, BRefType bRefTypeValue, int targetTag) { switch (targetTag) { case TypeTags.INT_TAG: sf.refRegs[resultRegIndex] = new BInteger(((BValueType) bRefTypeValue).intValue()); break; case TypeTags.FLOAT_TAG: sf.refRegs[resultRegIndex] = new BFloat(((BValueType) bRefTypeValue).floatValue()); break; case TypeTags.DECIMAL_TAG: sf.refRegs[resultRegIndex] = new BDecimal(((BValueType) bRefTypeValue).decimalValue()); break; case TypeTags.STRING_TAG: sf.refRegs[resultRegIndex] = new BString(bRefTypeValue.toString()); break; case TypeTags.BOOLEAN_TAG: sf.refRegs[resultRegIndex] = new BBoolean(((BValueType) bRefTypeValue).booleanValue()); break; case TypeTags.BYTE_TAG: sf.refRegs[resultRegIndex] = new BByte(((BValueType) bRefTypeValue).byteValue()); break; default: handleTypeConversionError(strand, sf, resultRegIndex, bRefTypeValue.getType(), typeRefCPEntry.getType()); } }
refValues[i] = new BByte(byteValues[i]);
private static BValue getDefaultValue(BType type, DefaultValue value) { switch (type.getTag()) { case TypeTags.INT_TAG: return new BInteger(value.getIntValue()); case TypeTags.STRING_TAG: return new BString(value.getStringValue()); case TypeTags.FLOAT_TAG: return new BFloat(value.getFloatValue()); case TypeTags.DECIMAL_TAG: return new BDecimal(value.getDecimalValue()); case TypeTags.BOOLEAN_TAG: return new BBoolean(value.getBooleanValue()); case TypeTags.BYTE_TAG: return new BByte(value.getByteValue()); default: //shouldn't reach here throw new BLangUsageException("unsupported type specified as defaultable param: " + type); } }
public static BRefType<?> execListGetOperation(BNewArray array, long index) { if (array.getType().getTag() != TypeTags.ARRAY_TAG) { BValueArray bRefValueArray = (BValueArray) array; return bRefValueArray.getRefValue(index); } switch (((BArrayType) array.getType()).getElementType().getTag()) { case TypeTags.BOOLEAN_TAG: BValueArray bBooleanArray = (BValueArray) array; int i = bBooleanArray.getBoolean(index); return i == 0 ? new BBoolean(false) : new BBoolean(true); case TypeTags.BYTE_TAG: BValueArray bByteArray = (BValueArray) array; return new BByte(bByteArray.getByte(index)); case TypeTags.FLOAT_TAG: BValueArray bFloatArray = (BValueArray) array; return new BFloat(bFloatArray.getFloat(index)); case TypeTags.DECIMAL_TAG: BValueArray bDecimalArray = (BValueArray) array; return new BDecimal(new BigDecimal(bDecimalArray.getRefValue(index).stringValue())); case TypeTags.INT_TAG: BValueArray bIntArray = (BValueArray) array; return new BInteger(bIntArray.getInt(index)); case TypeTags.STRING_TAG: BValueArray bStringArray = (BValueArray) array; return new BString(bStringArray.getString(index)); default: BValueArray bRefValueArray = (BValueArray) array; return bRefValueArray.getRefValue(index); } }
private static BValue populateReturnData(StrandCallback strandCallback, CallableUnitInfo callableUnitInfo) { BValue returnValue; BType retType = callableUnitInfo.getRetParamTypes()[0]; //TODO this should have single type instead of an array switch (retType.getTag()) { case TypeTags.INT_TAG: returnValue = new BInteger(strandCallback.getIntRetVal()); break; case TypeTags.BYTE_TAG: returnValue = new BByte((byte) strandCallback.getByteRetVal()); break; case TypeTags.FLOAT_TAG: returnValue = new BFloat(strandCallback.getFloatRetVal()); break; case TypeTags.STRING_TAG: returnValue = new BString(strandCallback.getStringRetVal()); break; case TypeTags.BOOLEAN_TAG: boolean boolValue = strandCallback.getBooleanRetVal() == 1; returnValue = new BBoolean(boolValue); break; default: returnValue = strandCallback.getRefRetVal(); break; } return returnValue; }
fp.addClosureVar(new BClosure(new BByte((byte) sf.intRegs[index]), BTypes.typeByte), TypeTags.BYTE_TAG); break;
return new BBoolean(getBooleanValue(value)); case TypeTags.BYTE_TAG: return new BByte(getByteValue(value)); case TypeTags.XML_TAG: try {
@Override public BValue getBValue(long index) { if (elementType != null) { if (elementType.getTag() == TypeTags.INT_TAG) { return new BInteger(getInt(index)); } else if (elementType.getTag() == TypeTags.BOOLEAN_TAG) { return new BBoolean(getBoolean(index) == 1); } else if (elementType.getTag() == TypeTags.BYTE_TAG) { return new BByte(getByte(index)); } else if (elementType.getTag() == TypeTags.FLOAT_TAG) { return new BFloat(getFloat(index)); } else if (elementType.getTag() == TypeTags.STRING_TAG) { return new BString(getString(index)); } else { return getRefValue(index); } } return getRefValue(index); }
case TypeSignature.SIG_BYTE: byte byteValue = defaultValue.getByteValue(); value = new BByte(byteValue); break; case TypeSignature.SIG_FLOAT:
private static void copyReturnsInWaitMultiple(StackFrame sf, SafeStrandCallback strandCallback, int retReg, int keyReg) { String keyValue = ((UTF8CPEntry) sf.constPool[keyReg]).getValue(); switch (strandCallback.retType.getTag()) { case TypeTags.INT_TAG: ((BMap) sf.refRegs[retReg]).put(keyValue, new BInteger (strandCallback.getIntRetVal())); break; case TypeTags.BYTE_TAG: ((BMap) sf.refRegs[retReg]).put(keyValue, new BByte((byte) strandCallback.getByteRetVal())); break; case TypeTags.FLOAT_TAG: ((BMap) sf.refRegs[retReg]).put(keyValue, new BFloat(strandCallback.getFloatRetVal())); break; case TypeTags.STRING_TAG: ((BMap) sf.refRegs[retReg]).put(keyValue, new BString(strandCallback.getStringRetVal())); break; case TypeTags.BOOLEAN_TAG: ((BMap) sf.refRegs[retReg]).put(keyValue, new BBoolean(strandCallback.getBooleanRetVal() == 1)); break; default: ((BMap) sf.refRegs[retReg]).put(keyValue, strandCallback.getRefRetVal()); break; } }
break; case TypeTags.BYTE_TAG: variableDTO.setBValue(new BByte((byte) sf.intRegs[variableInfo.getVariableIndex()])); break; case TypeTags.FLOAT_TAG:
break; case TypeTags.BYTE_TAG: sf.refRegs[retReg] = new BByte((byte) strandCallback.getByteRetVal()); break; case TypeTags.FLOAT_TAG:
break; case TypeTags.BYTE_TAG: variableDTO.setBValue(new BByte((byte) (ctx.programFile.globalMemArea.getBooleanField(pkgIndex, packVarInfo.getGlobalMemIndex())))); break;
continue; case TypeTags.BYTE_TAG: bStruct.put(key, new BByte(defaultValAttrInfo.getDefaultValue().getByteValue())); continue; case TypeTags.FLOAT_TAG: