var/const decl; remove : from parameter lists

This commit is contained in:
Ginger Bill
2016-12-18 21:50:14 +00:00
parent 5217eb55b4
commit e370337f97
15 changed files with 2009 additions and 1989 deletions
+34 -34
View File
@@ -2,9 +2,9 @@
#import "mem.odin";
#import "utf8.odin";
PRINT_BUF_SIZE :: 1<<12;
const PRINT_BUF_SIZE = 1<<12;
proc fprint(f: ^os.File, args: ..any) -> int {
proc fprint(f ^os.File, args ..any) -> int {
data: [PRINT_BUF_SIZE]byte;
buf := data[:0];
bprint(^buf, ..args);
@@ -12,14 +12,14 @@ proc fprint(f: ^os.File, args: ..any) -> int {
return buf.count;
}
proc fprintln(f: ^os.File, args: ..any) -> int {
proc fprintln(f ^os.File, args ..any) -> int {
data: [PRINT_BUF_SIZE]byte;
buf := data[:0];
bprintln(^buf, ..args);
os.write(f, buf);
return buf.count;
}
proc fprintf(f: ^os.File, fmt: string, args: ..any) -> int {
proc fprintf(f ^os.File, fmt string, args ..any) -> int {
data: [PRINT_BUF_SIZE]byte;
buf := data[:0];
bprintf(^buf, fmt, ..args);
@@ -28,19 +28,19 @@ proc fprintf(f: ^os.File, fmt: string, args: ..any) -> int {
}
proc print(args: ..any) -> int {
proc print(args ..any) -> int {
return fprint(os.stdout, ..args);
}
proc println(args: ..any) -> int {
proc println(args ..any) -> int {
return fprintln(os.stdout, ..args);
}
proc printf(fmt: string, args: ..any) -> int {
proc printf(fmt string, args ..any) -> int {
return fprintf(os.stdout, fmt, ..args);
}
proc fprint_type(f: ^os.File, info: ^Type_Info) {
proc fprint_type(f ^os.File, info ^Type_Info) {
data: [PRINT_BUF_SIZE]byte;
buf := data[:0];
bprint_type(^buf, info);
@@ -49,7 +49,7 @@ proc fprint_type(f: ^os.File, info: ^Type_Info) {
proc print_byte_buffer(buf: ^[]byte, b: []byte) {
proc print_byte_buffer(buf ^[]byte, b []byte) {
if buf.count < buf.capacity {
n := min(buf.capacity-buf.count, b.count);
if n > 0 {
@@ -59,29 +59,29 @@ proc print_byte_buffer(buf: ^[]byte, b: []byte) {
}
}
proc bprint_string(buf: ^[]byte, s: string) {
proc bprint_string(buf ^[]byte, s string) {
print_byte_buffer(buf, s as []byte);
}
proc byte_reverse(b: []byte) {
proc byte_reverse(b []byte) {
n := b.count;
for i := 0; i < n/2; i++ {
b[i], b[n-1-i] = b[n-1-i], b[i];
}
}
proc bprint_rune(buf: ^[]byte, r: rune) {
proc bprint_rune(buf ^[]byte, r rune) {
b, n := utf8.encode_rune(r);
bprint_string(buf, b[:n] as string);
}
proc bprint_space(buf: ^[]byte) { bprint_rune(buf, ' '); }
proc bprint_nl (buf: ^[]byte) { bprint_rune(buf, '\n'); }
proc bprint_space(buf ^[]byte) { bprint_rune(buf, ' '); }
proc bprint_nl (buf ^[]byte) { bprint_rune(buf, '\n'); }
__NUM_TO_CHAR_TABLE := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@$";
proc bprint_bool(buffer: ^[]byte, b : bool) {
proc bprint_bool(buffer ^[]byte, b bool) {
if b {
bprint_string(buffer, "true");
} else {
@@ -89,15 +89,15 @@ proc bprint_bool(buffer: ^[]byte, b : bool) {
}
}
proc bprint_pointer(buffer: ^[]byte, p: rawptr) #inline {
proc bprint_pointer(buffer ^[]byte, p rawptr) #inline {
bprint_string(buffer, "0x");
bprint_u64(buffer, p as uint as u64);
}
proc bprint_f16 (buffer: ^[]byte, f: f32) #inline { print__f64(buffer, f as f64, 4); }
proc bprint_f32 (buffer: ^[]byte, f: f32) #inline { print__f64(buffer, f as f64, 7); }
proc bprint_f64 (buffer: ^[]byte, f: f64) #inline { print__f64(buffer, f as f64, 16); }
proc bprint_u64(buffer: ^[]byte, value: u64) {
proc bprint_f16 (buffer ^[]byte, f f32) #inline { print__f64(buffer, f as f64, 4); }
proc bprint_f32 (buffer ^[]byte, f f32) #inline { print__f64(buffer, f as f64, 7); }
proc bprint_f64 (buffer ^[]byte, f f64) #inline { print__f64(buffer, f as f64, 16); }
proc bprint_u64(buffer ^[]byte, value u64) {
i := value;
buf: [20]byte;
len := 0;
@@ -113,7 +113,7 @@ proc bprint_u64(buffer: ^[]byte, value: u64) {
byte_reverse(buf[:len]);
bprint_string(buffer, buf[:len] as string);
}
proc bprint_i64(buffer: ^[]byte, value: i64) {
proc bprint_i64(buffer ^[]byte, value i64) {
// TODO(bill): Cleanup printing
i := value;
if i < 0 {
@@ -124,14 +124,14 @@ proc bprint_i64(buffer: ^[]byte, value: i64) {
}
/*
proc bprint_u128(buffer: ^[]byte, value: u128) {
proc bprint_u128(buffer ^[]byte, value u128) {
a := value transmute [2]u64;
if a[1] != 0 {
bprint_u64(buffer, a[1]);
}
bprint_u64(buffer, a[0]);
}
proc bprint_i128(buffer: ^[]byte, value: i128) {
proc bprint_i128(buffer ^[]byte, value i128) {
i := value;
if i < 0 {
i = -i;
@@ -142,7 +142,7 @@ proc bprint_i128(buffer: ^[]byte, value: i128) {
*/
proc print__f64(buffer: ^[]byte, value: f64, decimal_places: int) {
proc print__f64(buffer ^[]byte, value f64, decimal_places int) {
f := value;
if f == 0 {
bprint_rune(buffer, '0');
@@ -168,7 +168,7 @@ proc print__f64(buffer: ^[]byte, value: f64, decimal_places: int) {
}
}
proc bprint_type(buf: ^[]byte, ti: ^Type_Info) {
proc bprint_type(buf ^[]byte, ti ^Type_Info) {
if ti == nil {
return;
}
@@ -299,14 +299,14 @@ proc bprint_type(buf: ^[]byte, ti: ^Type_Info) {
}
proc make_any(type_info: ^Type_Info, data: rawptr) -> any {
proc make_any(type_info ^Type_Info, data rawptr) -> any {
a: any;
a.type_info = type_info;
a.data = data;
return a;
}
proc bprint_any(buf: ^[]byte, arg: any) {
proc bprint_any(buf ^[]byte, arg any) {
if arg.type_info == nil {
bprint_string(buf, "<nil>");
return;
@@ -435,7 +435,7 @@ proc bprint_any(buf: ^[]byte, arg: any) {
}
case Vector:
proc is_bool(type_info: ^Type_Info) -> bool {
proc is_bool(type_info ^Type_Info) -> bool {
match type info : type_info {
case Named:
return is_bool(info.base);
@@ -489,12 +489,12 @@ proc bprint_any(buf: ^[]byte, arg: any) {
}
proc bprintf(buf: ^[]byte, fmt: string, args: ..any) -> int {
proc is_digit(r: rune) -> bool #inline {
proc bprintf(buf ^[]byte, fmt string, args ..any) -> int {
proc is_digit(r rune) -> bool #inline {
return '0' <= r && r <= '9';
}
proc parse_int(s: string, offset: int) -> (int, int) {
proc parse_int(s string, offset int) -> (int, int) {
result := 0;
for ; offset < s.count; offset++ {
@@ -554,8 +554,8 @@ proc bprintf(buf: ^[]byte, fmt: string, args: ..any) -> int {
}
proc bprint(buf: ^[]byte, args: ..any) -> int {
proc is_type_string(info: ^Type_Info) -> bool {
proc bprint(buf ^[]byte, args ..any) -> int {
proc is_type_string(info ^Type_Info) -> bool {
using Type_Info;
if info == nil {
return false;
@@ -582,7 +582,7 @@ proc bprint(buf: ^[]byte, args: ..any) -> int {
return buf.count;
}
proc bprintln(buf: ^[]byte, args: ..any) -> int {
proc bprintln(buf ^[]byte, args ..any) -> int {
for i := 0; i < args.count; i++ {
if i > 0 {
append(buf, ' ');