Fix exact value bug when updating expressions

This commit is contained in:
Ginger Bill
2016-10-16 00:26:53 +01:00
parent 79af939522
commit b9719df0ad
8 changed files with 86 additions and 52 deletions
+7 -8
View File
@@ -74,11 +74,12 @@ type_info_base :: proc(info: ^Type_Info) -> ^Type_Info {
if info == nil {
return nil
}
match type i : info {
base := info
match type i : base {
case Type_Info.Named:
info = i.base
base = i.base
}
return info
return base
}
@@ -259,10 +260,10 @@ __string_eq :: proc(a, b: string) -> bool {
if a.count != b.count {
return false
}
if ^a[0] == ^b[0] {
if a.data == b.data {
return true
}
return mem.compare(^a[0], ^b[0], a.count) == 0
return mem.compare(a.data, b.data, a.count) == 0
}
__string_cmp :: proc(a, b : string) -> int {
@@ -312,9 +313,7 @@ __substring_expr_error :: proc(file: string, line, column: int,
}
__enum_to_string :: proc(info: ^Type_Info, value: i64) -> string {
info = type_info_base(info)
match type ti : info {
match type ti : type_info_base(info) {
case Type_Info.Enum:
// TODO(bill): Search faster than linearly
for i := 0; i < ti.values.count; i++ {
+7 -5
View File
@@ -90,7 +90,8 @@ print_pointer_to_buffer :: proc(buffer: ^[]byte, p: rawptr) #inline {
print_f32_to_buffer :: proc(buffer: ^[]byte, f: f32) #inline { print__f64(buffer, f as f64, 7) }
print_f64_to_buffer :: proc(buffer: ^[]byte, f: f64) #inline { print__f64(buffer, f, 10) }
print_u64_to_buffer :: proc(buffer: ^[]byte, i: u64) {
print_u64_to_buffer :: proc(buffer: ^[]byte, value: u64) {
i := value
buf: [22]byte
len := 0
if i == 0 {
@@ -105,7 +106,8 @@ print_u64_to_buffer :: proc(buffer: ^[]byte, i: u64) {
byte_reverse(buf[:len])
print_string_to_buffer(buffer, buf[:len] as string)
}
print_i64_to_buffer :: proc(buffer: ^[]byte, i: i64) {
print_i64_to_buffer :: proc(buffer: ^[]byte, value: i64) {
i := value
neg := i < 0
if neg {
i = -i
@@ -114,7 +116,8 @@ print_i64_to_buffer :: proc(buffer: ^[]byte, i: i64) {
print_u64_to_buffer(buffer, i as u64)
}
print__f64 :: proc(buffer: ^[]byte, f: f64, decimal_places: int) {
print__f64 :: proc(buffer: ^[]byte, value: f64, decimal_places: int) {
f := value
if f == 0 {
print_rune_to_buffer(buffer, #rune "0")
return
@@ -555,12 +558,11 @@ bprintf :: proc(buf: ^[]byte, fmt: string, args: ..any) {
bprint :: proc(buf: ^[]byte, args: ..any) {
is_type_string :: proc(info: ^Type_Info) -> bool {
using Type_Info
info = type_info_base(info)
if info == nil {
return false
}
match type i : info {
match type i : type_info_base(info) {
case String:
return true
}
+2 -1
View File
@@ -39,7 +39,8 @@ accept_sizes := [256]byte{
0x34, 0x04, 0x04, 0x04, 0x44, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, // 0xf0-0xff
}
encode_rune :: proc(r: rune) -> ([4]byte, int) {
encode_rune :: proc(r_: rune) -> ([4]byte, int) {
r := r_
buf: [4]byte
i := r as u32
mask: byte : 0x3f