~ecs/qbe2c

2eb6fd0d70204cc88ad5abe668e1d51ed480c20a — Sebastian 5 months ago d9daae1 master
fix compilation

Signed-off-by: Sebastian <sebastian@sebsite.pw>
3 files changed, 9 insertions(+), 4 deletions(-)

M alloca.ha
M main.ha
M unparse.ha
M alloca.ha => alloca.ha +2 -0
@@ 8,12 8,14 @@ fn alloc_type(i: qbe::itype1) str = switch (i) {
case itype1::ALLOC4 => return "uint32_t";
case itype1::ALLOC8 => return "uint64_t";
case itype1::ALLOC16 => return "long double";
case => abort(); // unreachable
};

fn alloc_sz(i: qbe::itype1) size = switch (i) {
case itype1::ALLOC4 => return 4;
case itype1::ALLOC8 => return 8;
case itype1::ALLOC16 => return 16;
case => abort(); // unreachable
};

fn need_alloca(d: qbe::definitions) bool = {

M main.ha => main.ha +2 -2
@@ 42,8 42,8 @@ fn _main() (void | io::error | fs::error) = {
		os::exit(1);
	};

	static let inbuf: [os::BUFSIZ]u8 = [0...];
	static let outbuf: [os::BUFSIZ]u8 = [0...];
	static let inbuf: [os::BUFSZ]u8 = [0...];
	static let outbuf: [os::BUFSZ]u8 = [0...];
	let inbuffered = bufio::init(in, inbuf, []);
	let outbuffered = bufio::init(out, [], outbuf);
	let c = ctx {

M unparse.ha => unparse.ha +5 -2
@@ 4,6 4,7 @@ use fmt;
use io;
use qbe;
use sort;
use sort::cmp;
use strings;
use math;



@@ 83,7 84,9 @@ const keywords: [_]str = [
	"while",
];

fn iskeyword(n: str) bool = sort::searchstrings(keywords, n) is size;
fn iskeyword(n: str) bool = {
	return sort::search(keywords, size(str), &n, &cmp::strs) is size;
};

fn name(c: *ctx, n: (str | qbe::temp | datatype)) (void | io::error) = {
	if (!(n is qbe::temp || n is datatype || strings::contains(n: str, '.', '$') ||


@@ 736,7 739,7 @@ fn funcdef(c: *ctx, f: qbe::funcdef) (void | io::error) = {
			append(temps, temp);
		};
	};
	sort::strings(temps: []str);
	sort::sort(temps: []str, size(str), &cmp::strs);
	for (let i = 0z; i < len(temps); i += 1) {
		if (i != 0 && temps[i] == temps[i - 1]) continue;
		fmt::fprint(c.out, "\tunion __qbe2c_union ")?;