split const integers into signed and unsigned

This commit is contained in:
Julius Rakow 2018-07-14 14:48:04 +02:00
parent 1e32e91877
commit 51b9eb81e8
No known key found for this signature in database
GPG Key ID: 9AABD9B859435A93
5 changed files with 14 additions and 10 deletions

View File

@ -189,7 +189,8 @@ pub struct Const {
pub enum ConstValue { pub enum ConstValue {
BooleanLiteral(bool), BooleanLiteral(bool),
FloatLiteral(f64), FloatLiteral(f64),
IntegerLiteral(i64), SignedIntegerLiteral(i64),
UnsignedIntegerLiteral(u64),
Null, Null,
} }

View File

@ -986,11 +986,15 @@ impl ToTokens for ast::Const {
FloatLiteral(f) => { FloatLiteral(f) => {
let f = Literal::f64_unsuffixed(f); let f = Literal::f64_unsuffixed(f);
quote!(#f) quote!(#f)
} },
IntegerLiteral(i) => { SignedIntegerLiteral(i) => {
let i = Literal::i64_unsuffixed(i); let i = Literal::i64_unsuffixed(i);
quote!(#i) quote!(#i)
} },
UnsignedIntegerLiteral(i) => {
let i = Literal::u64_unsuffixed(i);
quote!(#i)
},
Null => unimplemented!(), Null => unimplemented!(),
}; };

View File

@ -14,4 +14,4 @@ proc-macro2 = "0.4"
quote = '0.6' quote = '0.6'
syn = { version = '0.14', features = ['full'] } syn = { version = '0.14', features = ['full'] }
wasm-bindgen-backend = { version = "=0.2.11", path = "../backend" } wasm-bindgen-backend = { version = "=0.2.11", path = "../backend" }
webidl = "0.6.0" webidl = "0.7.0"

View File

@ -43,7 +43,8 @@ pub fn webidl_const_v_to_backend_const_v(v: &webidl::ast::ConstValue) -> backend
match *v { match *v {
webidl::ast::ConstValue::BooleanLiteral(b) => backend::ast::ConstValue::BooleanLiteral(b), webidl::ast::ConstValue::BooleanLiteral(b) => backend::ast::ConstValue::BooleanLiteral(b),
webidl::ast::ConstValue::FloatLiteral(f) => backend::ast::ConstValue::FloatLiteral(f), webidl::ast::ConstValue::FloatLiteral(f) => backend::ast::ConstValue::FloatLiteral(f),
webidl::ast::ConstValue::IntegerLiteral(i) => backend::ast::ConstValue::IntegerLiteral(i), webidl::ast::ConstValue::SignedIntegerLiteral(i) => backend::ast::ConstValue::SignedIntegerLiteral(i),
webidl::ast::ConstValue::UnsignedIntegerLiteral(u) => backend::ast::ConstValue::UnsignedIntegerLiteral(u),
webidl::ast::ConstValue::Null => backend::ast::ConstValue::Null, webidl::ast::ConstValue::Null => backend::ast::ConstValue::Null,
} }
} }

View File

@ -71,9 +71,7 @@ fn ints() {
const long long imin = -9223372036854775808; const long long imin = -9223372036854775808;
const long long imax = 9223372036854775807; const long long imax = 9223372036854775807;
const unsigned long long umin = 0; const unsigned long long umin = 0;
// bug in webidl const unsigned long long umax = 18446744073709551615;
// https://github.com/sgodwincs/webidl-rs/issues/15
//const unsigned long long umax = 18446744073709551615;
}; };
"#, "#,
) )
@ -121,7 +119,7 @@ fn ints() {
assert_eq!(foo::LongLong::IMIN, i64::min_value()); assert_eq!(foo::LongLong::IMIN, i64::min_value());
assert_eq!(foo::LongLong::IMAX, i64::max_value()); assert_eq!(foo::LongLong::IMAX, i64::max_value());
assert_eq!(foo::LongLong::UMIN, u64::min_value()); assert_eq!(foo::LongLong::UMIN, u64::min_value());
//assert_eq!(foo::LongLong::UMAX, u64::max_value()); assert_eq!(foo::LongLong::UMAX, u64::max_value());
} }
"#, "#,
) )