diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-02-11 15:04:26 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-02-13 09:54:47 +0000 |
commit | 3ae8d55860cbe95f80d5e5c76ca71883dbde0e10 (patch) | |
tree | 3fc0385c18fe11a4ceb8ae34ad3c208f027efebb /gcc/rust/rust-gcc.cc | |
parent | fac8276f737351afbde34a85f2b6c224b400313b (diff) | |
download | gcc-3ae8d55860cbe95f80d5e5c76ca71883dbde0e10.zip gcc-3ae8d55860cbe95f80d5e5c76ca71883dbde0e10.tar.gz gcc-3ae8d55860cbe95f80d5e5c76ca71883dbde0e10.tar.bz2 |
Add char type
This might need changes in the Lexer to allow for wchar_t to be preserved.
Addresses #85
Diffstat (limited to 'gcc/rust/rust-gcc.cc')
-rw-r--r-- | gcc/rust/rust-gcc.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc index 82ebb98..b2538b4 100644 --- a/gcc/rust/rust-gcc.cc +++ b/gcc/rust/rust-gcc.cc @@ -165,6 +165,17 @@ public: Btype *bool_type () { return this->make_type (boolean_type_node); } + Btype *char_type () { return this->make_type (char_type_node); } + + Btype *wchar_type () + { + // i think this is meant to be 32 bit from + // https://www.unicode.org/versions/Unicode13.0.0/ch03.pdf#G7404 + int precision = 32; + tree wchar = make_unsigned_type (precision); + return this->make_type (wchar); + } + int get_pointer_size (); Btype *integer_type (bool, int); @@ -247,6 +258,8 @@ public: Bexpression *string_constant_expression (const std::string &val); + Bexpression *wchar_constant_expression (wchar_t c); + Bexpression *boolean_constant_expression (bool val); Bexpression *real_part_expression (Bexpression *bcomplex, Location); @@ -1409,6 +1422,13 @@ Gcc_backend::string_constant_expression (const std::string &val) return this->make_expression (string_val); } +Bexpression * +Gcc_backend::wchar_constant_expression (wchar_t c) +{ + tree ret = build_int_cst (this->wchar_type ()->get_tree (), c); + return this->make_expression (ret); +} + // Make a constant boolean expression. Bexpression * |