commit 1f37a12bc86cd362eea39dea5ab321751f52b224
parent 74af0de1fab90c9d4531452fa1376cce1df13fce
Author: Sebastian <sebastian@sebsite.pw>
Date: Tue, 9 May 2023 21:59:07 -0400
hare::*: remove char
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
11 files changed, 9 insertions(+), 32 deletions(-)
diff --git a/cmd/harec/qtype.ha b/cmd/harec/qtype.ha
@@ -43,8 +43,6 @@ fn qtype_lookup(
match (_type.repr) {
case let bi: builtin =>
switch (bi) {
- case builtin::CHAR =>
- return if (extype) &qbyte else &qword;
case builtin::I8, builtin::U8 =>
return if (extype) &qbyte else &qword;
case builtin::I16, builtin::U16 =>
diff --git a/hare/ast/type.ha b/hare/ast/type.ha
@@ -12,7 +12,7 @@ export type alias_type = struct {
// A built-in primitive type (int, bool, str, etc).
export type builtin_type = enum {
- BOOL, CHAR, F32, F64, FCONST, I16, I32, I64, I8, ICONST, INT, NULL,
+ BOOL, F32, F64, FCONST, I16, I32, I64, I8, ICONST, INT, NULL,
RUNE, SIZE, STR, U16, U32, U64, U8, UINT, UINTPTR, VALIST, VOID,
};
diff --git a/hare/lex/token.ha b/hare/lex/token.ha
@@ -28,7 +28,6 @@ export type ltok = enum uint {
BOOL,
BREAK,
CASE,
- CHAR,
CONST,
CONTINUE,
DEF,
@@ -179,7 +178,6 @@ const bmap: [_]str = [
"bool",
"break",
"case",
- "char",
"const",
"continue",
"def",
diff --git a/hare/parse/type.ha b/hare/parse/type.ha
@@ -68,8 +68,6 @@ fn integer_type(
lexer: *lex::lexer,
) (builtin_type | error) = {
switch (want(lexer)?.0) {
- case ltok::CHAR =>
- return builtin_type::CHAR;
case ltok::INT =>
return builtin_type::INT;
case ltok::I8 =>
@@ -102,7 +100,7 @@ fn integer_type(
fn primitive_type(lexer: *lex::lexer) (ast::_type | error) = {
let tok = want(lexer)?;
let builtin = switch (tok.0) {
- case ltok::CHAR, ltok::I8, ltok::I16, ltok::I32, ltok::I64,
+ case ltok::I8, ltok::I16, ltok::I32, ltok::I64,
ltok::INT, ltok::UINT, ltok::UINTPTR, ltok::SIZE,
ltok::U8, ltok::U16, ltok::U32, ltok::U64 =>
lex::unlex(lexer, tok);
@@ -465,7 +463,7 @@ export fn _type(lexer: *lex::lexer) (ast::_type | error) = {
let tok = peek(lexer)? as lex::token;
let typ: ast::_type = switch (tok.0) {
- case ltok::CHAR, ltok::RUNE, ltok::STR, ltok::BOOL,
+ case ltok::RUNE, ltok::STR, ltok::BOOL,
ltok::I8, ltok::I16, ltok::I32, ltok::I64,
ltok::U8, ltok::U16, ltok::U32, ltok::U64,
ltok::INT, ltok::UINT, ltok::UINTPTR, ltok::SIZE,
diff --git a/hare/types/+test.ha b/hare/types/+test.ha
@@ -333,9 +333,9 @@ fn resolve(
assert(htype._align == 8);
let t = htype.repr as tagged;
assert(len(t) == 3);
- assert(t[0].repr as builtin == builtin::INT);
- assert(t[1].repr as builtin == builtin::VOID);
- assert(t[2].repr as builtin == builtin::STR);
+ assert(t[0].repr as builtin == builtin::STR);
+ assert(t[1].repr as builtin == builtin::INT);
+ assert(t[2].repr as builtin == builtin::VOID);
};
@test fn alias() void = {
diff --git a/hare/types/builtins.ha b/hare/types/builtins.ha
@@ -8,13 +8,6 @@ export const builtin_bool: _type = _type {
...
};
-// [[_type]] representation of char.
-export const builtin_char: _type = _type {
- repr = builtin::CHAR,
- sz = 1, _align = 1,
- ...
-};
-
// [[_type]] representation of f32.
export const builtin_f32: _type = _type {
repr = builtin::F32,
@@ -109,7 +102,6 @@ export const builtin_void: _type = _type {
@init fn init() void = {
const builtins = [
&builtin_bool,
- &builtin_char,
&builtin_f32,
&builtin_f64,
&builtin_i8,
diff --git a/hare/types/class.ha b/hare/types/class.ha
@@ -54,7 +54,7 @@ export fn is_integer(ty: const *_type) bool = {
switch (bi) {
case builtin::INT, builtin::UINT, builtin::I16,
builtin::I32, builtin::I64, builtin::I8, builtin::U16,
- builtin::U32, builtin::U64, builtin::U8, builtin::CHAR,
+ builtin::U32, builtin::U64, builtin::U8,
builtin::SIZE, builtin::UINTPTR =>
return true;
case =>
diff --git a/hare/types/hash.ha b/hare/types/hash.ha
@@ -9,7 +9,7 @@ use fmt;
// Keep ordered with respect to bootstrap harec:include/types.h
type storage = enum u8 {
- BOOL, CHAR, F32, F64, I16, I32, I64, I8, INT, NULL, RUNE, SIZE, STRING,
+ BOOL, F32, F64, I16, I32, I64, I8, INT, NULL, RUNE, SIZE, STRING,
U16, U32, U64, U8, UINT, UINTPTR, VOID, ALIAS, ARRAY, ENUM, FUNCTION,
POINTER, SLICE, STRUCT, TAGGED, TUPLE, UNION,
};
@@ -18,8 +18,6 @@ fn builtin_storage(b: builtin) u8 = {
switch (b) {
case builtin::BOOL =>
return storage::BOOL;
- case builtin::CHAR =>
- return storage::CHAR;
case builtin::F32 =>
return storage::F32;
case builtin::F64 =>
diff --git a/hare/types/store.ha b/hare/types/store.ha
@@ -126,8 +126,6 @@ export fn lookup(
if (ty.flags == 0) match (ty.repr) {
case let b: builtin =>
switch (b) {
- case builtin::CHAR =>
- return &builtin_char;
case builtin::F32 =>
return &builtin_f32;
case builtin::F64 =>
@@ -187,9 +185,6 @@ fn fromast(store: *typestore, atype: *ast::_type) (_type | deferred | error) = {
sz = store.arch._int;
_align = store.arch._int;
yield builtin::BOOL;
- case ast::builtin_type::CHAR =>
- sz = 1; _align = 1;
- yield builtin::CHAR;
case ast::builtin_type::F32 =>
sz = 4; _align = 4;
yield builtin::F32;
diff --git a/hare/types/types.ha b/hare/types/types.ha
@@ -22,7 +22,7 @@ export type array = struct {
export type builtin = enum u8 {
// Keep me consistent with ast::builtin
- BOOL, CHAR, F32, F64, FCONST, I16, I32, I64, I8, ICONST, INT, NULL,
+ BOOL, F32, F64, FCONST, I16, I32, I64, I8, ICONST, INT, NULL,
RUNE, SIZE, STR, U16, U32, U64, U8, UINT, UINTPTR, VALIST, VOID,
};
diff --git a/hare/unparse/type.ha b/hare/unparse/type.ha
@@ -16,8 +16,6 @@ case ast::builtin_type::FCONST, ast::builtin_type::ICONST =>
abort("ICONST and FCONST have no lexical representation");
case ast::builtin_type::BOOL =>
yield "bool";
-case ast::builtin_type::CHAR =>
- yield "char";
case ast::builtin_type::F32 =>
yield "f32";
case ast::builtin_type::F64 =>