@@ -14,15 +14,6 @@ use sway_types::{integer_bits::IntegerBits, span::Span};
1414
1515pub ( super ) fn convert_literal_to_value ( context : & mut Context , ast_literal : & Literal ) -> Value {
1616 match ast_literal {
17- // In Sway for now we don't have `as` casting and for integers which may be implicitly cast
18- // between widths we just emit a warning, and essentially ignore it. We also assume a
19- // 'Numeric' integer of undetermined width is 'u64`. The IR would like to be type
20- // consistent and doesn't tolerate missing integers of different width, so for now, until we
21- // do introduce explicit `as` casting, all integers are `u64` as far as the IR is
22- // concerned.
23- //
24- // XXX The above isn't true for other targets. We need to improved this.
25- // FIXME
2617 Literal :: U8 ( n) => ConstantContent :: get_uint ( context, 8 , * n as u64 ) ,
2718 Literal :: U16 ( n) => ConstantContent :: get_uint ( context, 64 , * n as u64 ) ,
2819 Literal :: U32 ( n) => ConstantContent :: get_uint ( context, 64 , * n as u64 ) ,
@@ -32,6 +23,7 @@ pub(super) fn convert_literal_to_value(context: &mut Context, ast_literal: &Lite
3223 Literal :: String ( s) => ConstantContent :: get_string ( context, s. as_str ( ) . as_bytes ( ) . to_vec ( ) ) ,
3324 Literal :: Boolean ( b) => ConstantContent :: get_bool ( context, * b) ,
3425 Literal :: B256 ( bs) => ConstantContent :: get_b256 ( context, * bs) ,
26+ Literal :: Binary ( bytes) => ConstantContent :: get_untyped_slice ( context, bytes. clone ( ) ) ,
3527 }
3628}
3729
@@ -40,7 +32,6 @@ pub(super) fn convert_literal_to_constant(
4032 ast_literal : & Literal ,
4133) -> Constant {
4234 let c = match ast_literal {
43- // All integers are `u64`. See comment above.
4435 Literal :: U8 ( n) => ConstantContent :: new_uint ( context, 8 , * n as u64 ) ,
4536 Literal :: U16 ( n) => ConstantContent :: new_uint ( context, 64 , * n as u64 ) ,
4637 Literal :: U32 ( n) => ConstantContent :: new_uint ( context, 64 , * n as u64 ) ,
@@ -50,6 +41,7 @@ pub(super) fn convert_literal_to_constant(
5041 Literal :: String ( s) => ConstantContent :: new_string ( context, s. as_str ( ) . as_bytes ( ) . to_vec ( ) ) ,
5142 Literal :: Boolean ( b) => ConstantContent :: new_bool ( context, * b) ,
5243 Literal :: B256 ( bs) => ConstantContent :: new_b256 ( context, * bs) ,
44+ Literal :: Binary ( _) => todo ! ( ) ,
5345 } ;
5446 Constant :: unique ( context, c)
5547}
0 commit comments