Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split const integers into signed and unsigned #476

Merged
merged 1 commit into from Jul 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/backend/src/ast.rs
Expand Up @@ -189,7 +189,8 @@ pub struct Const {
pub enum ConstValue {
BooleanLiteral(bool),
FloatLiteral(f64),
IntegerLiteral(i64),
SignedIntegerLiteral(i64),
UnsignedIntegerLiteral(u64),
Null,
}

Expand Down
10 changes: 7 additions & 3 deletions crates/backend/src/codegen.rs
Expand Up @@ -986,11 +986,15 @@ impl ToTokens for ast::Const {
FloatLiteral(f) => {
let f = Literal::f64_unsuffixed(f);
quote!(#f)
}
IntegerLiteral(i) => {
},
SignedIntegerLiteral(i) => {
let i = Literal::i64_unsuffixed(i);
quote!(#i)
}
},
UnsignedIntegerLiteral(i) => {
let i = Literal::u64_unsuffixed(i);
quote!(#i)
},
Null => unimplemented!(),
};

Expand Down
2 changes: 1 addition & 1 deletion crates/webidl/Cargo.toml
Expand Up @@ -14,4 +14,4 @@ proc-macro2 = "0.4"
quote = '0.6'
syn = { version = '0.14', features = ['full'] }
wasm-bindgen-backend = { version = "=0.2.11", path = "../backend" }
webidl = "0.6.0"
webidl = "0.7.0"
3 changes: 2 additions & 1 deletion crates/webidl/src/util.rs
Expand Up @@ -43,7 +43,8 @@ pub fn webidl_const_v_to_backend_const_v(v: &webidl::ast::ConstValue) -> backend
match *v {
webidl::ast::ConstValue::BooleanLiteral(b) => backend::ast::ConstValue::BooleanLiteral(b),
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,
}
}
Expand Down
6 changes: 2 additions & 4 deletions crates/webidl/tests/all/consts.rs
Expand Up @@ -71,9 +71,7 @@ fn ints() {
const long long imin = -9223372036854775808;
const long long imax = 9223372036854775807;
const unsigned long long umin = 0;
// bug in webidl
// https://github.com/sgodwincs/webidl-rs/issues/15
//const unsigned long long umax = 18446744073709551615;
const unsigned long long umax = 18446744073709551615;
};
"#,
)
Expand Down Expand Up @@ -121,7 +119,7 @@ fn ints() {
assert_eq!(foo::LongLong::IMIN, i64::min_value());
assert_eq!(foo::LongLong::IMAX, i64::max_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());
}
"#,
)
Expand Down