use of it.unica.tcs.bitcoinTM.NumberLiteral in project balzac by balzac-lang.
the class ASTUtils method objectToExpression.
public Expression objectToExpression(Object value) {
if (value instanceof Long) {
NumberLiteral res = BitcoinTMFactory.eINSTANCE.createNumberLiteral();
res.setValue((Long) value);
return res;
} else if (value instanceof String) {
StringLiteral res = BitcoinTMFactory.eINSTANCE.createStringLiteral();
res.setValue((String) value);
return res;
} else if (value instanceof Boolean) {
BooleanLiteral res = BitcoinTMFactory.eINSTANCE.createBooleanLiteral();
res.setTrue((Boolean) value);
return res;
} else if (value instanceof Hash) {
HashLiteral res = BitcoinTMFactory.eINSTANCE.createHashLiteral();
res.setValue(((Hash) value).getBytes());
return res;
} else if (value instanceof DumpedPrivateKey) {
KeyLiteral res = BitcoinTMFactory.eINSTANCE.createKeyLiteral();
res.setValue(((DumpedPrivateKey) value).toBase58());
return res;
} else if (value instanceof TransactionSignature) {
SignatureLiteral res = BitcoinTMFactory.eINSTANCE.createSignatureLiteral();
res.setValue(BitcoinUtils.encode(((TransactionSignature) value).encodeToBitcoin()));
return res;
} else {
throw new IllegalStateException("Unexpected type " + value.getClass());
}
}
Aggregations