table: register u8 type
parent
a7270148e5
commit
628498e0dc
|
@ -398,11 +398,14 @@ pub const (
|
||||||
int_literal_type_idx = 26
|
int_literal_type_idx = 26
|
||||||
thread_type_idx = 27
|
thread_type_idx = 27
|
||||||
error_type_idx = 28
|
error_type_idx = 28
|
||||||
|
u8_type_idx = 29
|
||||||
)
|
)
|
||||||
|
|
||||||
pub const (
|
pub const (
|
||||||
integer_type_idxs = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx,
|
integer_type_idxs = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx,
|
||||||
byte_type_idx, u16_type_idx, u32_type_idx, u64_type_idx, int_literal_type_idx, rune_type_idx]
|
byte_type_idx, u8_type_idx, u16_type_idx, u32_type_idx, u64_type_idx, int_literal_type_idx,
|
||||||
|
rune_type_idx,
|
||||||
|
]
|
||||||
signed_integer_type_idxs = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx]
|
signed_integer_type_idxs = [i8_type_idx, i16_type_idx, int_type_idx, i64_type_idx]
|
||||||
unsigned_integer_type_idxs = [byte_type_idx, u16_type_idx, u32_type_idx, u64_type_idx]
|
unsigned_integer_type_idxs = [byte_type_idx, u16_type_idx, u32_type_idx, u64_type_idx]
|
||||||
float_type_idxs = [f32_type_idx, f64_type_idx, float_literal_type_idx]
|
float_type_idxs = [f32_type_idx, f64_type_idx, float_literal_type_idx]
|
||||||
|
@ -424,6 +427,7 @@ pub const (
|
||||||
i16_type = new_type(i16_type_idx)
|
i16_type = new_type(i16_type_idx)
|
||||||
i64_type = new_type(i64_type_idx)
|
i64_type = new_type(i64_type_idx)
|
||||||
byte_type = new_type(byte_type_idx)
|
byte_type = new_type(byte_type_idx)
|
||||||
|
u8_type = new_type(u8_type_idx)
|
||||||
u16_type = new_type(u16_type_idx)
|
u16_type = new_type(u16_type_idx)
|
||||||
u32_type = new_type(u32_type_idx)
|
u32_type = new_type(u32_type_idx)
|
||||||
u64_type = new_type(u64_type_idx)
|
u64_type = new_type(u64_type_idx)
|
||||||
|
@ -457,10 +461,11 @@ pub fn merge_types(params ...[]Type) []Type {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const (
|
pub const (
|
||||||
|
// must be in the same order as the idx consts above
|
||||||
builtin_type_names = ['void', 'voidptr', 'charptr', 'byteptr', 'i8', 'i16', 'int', 'i64', 'u16',
|
builtin_type_names = ['void', 'voidptr', 'charptr', 'byteptr', 'i8', 'i16', 'int', 'i64', 'u16',
|
||||||
'u32', 'u64', 'int_literal', 'f32', 'f64', 'float_literal', 'string', 'char', 'byte', 'bool',
|
'u32', 'u64', 'int_literal', 'f32', 'f64', 'float_literal', 'string', 'char', 'byte', 'bool',
|
||||||
'none', 'array', 'array_fixed', 'map', 'chan', 'any', 'struct', 'mapnode', 'size_t', 'rune',
|
'none', 'array', 'array_fixed', 'map', 'chan', 'any', 'struct', 'mapnode', 'size_t', 'rune',
|
||||||
'thread', 'Error']
|
'thread', 'Error', 'u8']
|
||||||
)
|
)
|
||||||
|
|
||||||
pub struct MultiReturn {
|
pub struct MultiReturn {
|
||||||
|
@ -494,6 +499,7 @@ pub enum Kind {
|
||||||
int
|
int
|
||||||
i64
|
i64
|
||||||
byte
|
byte
|
||||||
|
u8
|
||||||
u16
|
u16
|
||||||
u32
|
u32
|
||||||
u64
|
u64
|
||||||
|
@ -664,6 +670,7 @@ pub fn (mut t Table) register_builtin_type_symbols() {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
t.register_type_symbol(kind: .interface_, name: 'IError', cname: 'IError', mod: 'builtin')
|
t.register_type_symbol(kind: .interface_, name: 'IError', cname: 'IError', mod: 'builtin')
|
||||||
|
t.register_type_symbol(kind: .u8, name: 'u8', cname: 'u8', mod: 'builtin')
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
[inline]
|
||||||
|
@ -719,6 +726,7 @@ pub fn (k Kind) str() string {
|
||||||
.i16 { 'i16' }
|
.i16 { 'i16' }
|
||||||
.i64 { 'i64' }
|
.i64 { 'i64' }
|
||||||
.byte { 'byte' }
|
.byte { 'byte' }
|
||||||
|
.u8 { 'u8' }
|
||||||
.u16 { 'u16' }
|
.u16 { 'u16' }
|
||||||
.u32 { 'u32' }
|
.u32 { 'u32' }
|
||||||
.u64 { 'u64' }
|
.u64 { 'u64' }
|
||||||
|
@ -917,7 +925,7 @@ pub fn (t &Table) type_to_str_using_aliases(typ Type, import_aliases map[string]
|
||||||
.int_literal, .float_literal {
|
.int_literal, .float_literal {
|
||||||
res = sym.name
|
res = sym.name
|
||||||
}
|
}
|
||||||
.i8, .i16, .int, .i64, .byte, .u16, .u32, .u64, .f32, .f64, .char, .rune, .string, .bool,
|
.i8, .i16, .int, .i64, .byte, .u8, .u16, .u32, .u64, .f32, .f64, .char, .rune, .string, .bool,
|
||||||
.none_, .byteptr, .voidptr, .charptr {
|
.none_, .byteptr, .voidptr, .charptr {
|
||||||
// primitive types
|
// primitive types
|
||||||
if sym.kind == .byteptr {
|
if sym.kind == .byteptr {
|
||||||
|
|
|
@ -19,8 +19,8 @@ fn (mut g JsGen) to_js_typ_val(t ast.Type) string {
|
||||||
mut styp := ''
|
mut styp := ''
|
||||||
mut prefix := if g.file.mod.name == 'builtin' { 'new ' } else { '' }
|
mut prefix := if g.file.mod.name == 'builtin' { 'new ' } else { '' }
|
||||||
match sym.kind {
|
match sym.kind {
|
||||||
.i8, .i16, .int, .i64, .byte, .u16, .u32, .u64, .f32, .f64, .int_literal, .float_literal,
|
.i8, .i16, .int, .i64, .byte, .u8, .u16, .u32, .u64, .f32, .f64, .int_literal,
|
||||||
.size_t {
|
.float_literal, .size_t {
|
||||||
styp = '$prefix${g.sym_to_js_typ(sym)}(0)'
|
styp = '$prefix${g.sym_to_js_typ(sym)}(0)'
|
||||||
}
|
}
|
||||||
.bool {
|
.bool {
|
||||||
|
@ -132,8 +132,8 @@ pub fn (mut g JsGen) typ(t ast.Type) string {
|
||||||
.byteptr, .charptr {
|
.byteptr, .charptr {
|
||||||
styp = '${g.sym_to_js_typ(sym)}'
|
styp = '${g.sym_to_js_typ(sym)}'
|
||||||
}
|
}
|
||||||
.i8, .i16, .int, .i64, .byte, .u16, .u32, .u64, .f32, .f64, .int_literal, .float_literal,
|
.i8, .i16, .int, .i64, .byte, .u8, .u16, .u32, .u64, .f32, .f64, .int_literal,
|
||||||
.size_t {
|
.float_literal, .size_t {
|
||||||
styp = '${g.sym_to_js_typ(sym)}'
|
styp = '${g.sym_to_js_typ(sym)}'
|
||||||
}
|
}
|
||||||
.bool {
|
.bool {
|
||||||
|
|
Loading…
Reference in New Issue