Compare commits

..

No commits in common. "ece9bb8bf21507b5d2a7c870f55aa2e9c5ab9f26" and "a7fda408eff7767480bfce94694cac531346bba2" have entirely different histories.

2 changed files with 9 additions and 17 deletions

View file

@ -237,7 +237,7 @@ main := fn(): int {
size_of_Type_in_bytes := @sizeof(foo.Type) size_of_Type_in_bytes := @sizeof(foo.Type)
align_of_Type_in_bytes := @alignof(foo.Type) align_of_Type_in_bytes := @alignof(foo.Type)
hardcoded_pointer := @as(^u8, @bitcast(10)) hardcoded_pointer := @as(^u8, @bitcast(10))
ecall_that_returns_int := @as(int, @eca(1, foo.Type.(10, 20), 5, 6)) ecall_that_returns_int := @eca(int, 1, foo.Type.(10, 20), 5, 6)
return @inline(foo.foo) return @inline(foo.foo)
} }
@ -399,8 +399,8 @@ modify := fn($num: ^int): void {
MALLOC_SYS_CALL := 69 MALLOC_SYS_CALL := 69
FREE_SYS_CALL := 96 FREE_SYS_CALL := 96
malloc := fn(size: uint, align: uint): ^void return @eca(MALLOC_SYS_CALL, size, align) malloc := fn(size: uint, align: uint): ^void return @eca(^void, MALLOC_SYS_CALL, size, align)
free := fn(ptr: ^void, size: uint, align: uint): void return @eca(FREE_SYS_CALL, ptr, size, align) free := fn(ptr: ^void, size: uint, align: uint): void return @eca(void, FREE_SYS_CALL, ptr, size, align)
Vec := fn($Elem: type): type { Vec := fn($Elem: type): type {
return struct { return struct {
@ -773,7 +773,7 @@ screenidx := fn(orange: int): int {
// in module: random.hb // in module: random.hb
integer := fn(min: int, max: int): int { integer := fn(min: int, max: int): int {
rng := @as(int, @eca(3, 4)) rng := @eca(int, 3, 4)
if min != 0 | max != 0 { if min != 0 | max != 0 {
return rng % (max - min + 1) + min return rng % (max - min + 1) + min
@ -804,7 +804,7 @@ main := fn(): void {
// in module: random.hb // in module: random.hb
integer_range := fn(min: uint, max: int): uint { integer_range := fn(min: uint, max: int): uint {
return @eca(3, 4) % (@bitcast(max) - min + 1) + min return @eca(uint, 3, 4) % (@bitcast(max) - min + 1) + min
} }
``` ```
@ -899,7 +899,7 @@ request_page := fn(page_count: u8): ^u8 {
msg := "\{00}\{01}xxxxxxxx\0" msg := "\{00}\{01}xxxxxxxx\0"
msg_page_count := msg + 1; msg_page_count := msg + 1;
*msg_page_count = page_count *msg_page_count = page_count
return @eca(3, 2, msg, 12) return @eca(^u8, 3, 2, msg, 12)
} }
create_back_buffer := fn(total_pages: int): ^u32 { create_back_buffer := fn(total_pages: int): ^u32 {

View file

@ -898,21 +898,13 @@ impl Codegen {
E::Directive { name: "TypeOf", args: [expr], .. } => { E::Directive { name: "TypeOf", args: [expr], .. } => {
Some(Value::ty(self.infer_type(expr))) Some(Value::ty(self.infer_type(expr)))
} }
E::Directive { name: "eca", args, pos } => { E::Directive { name: "eca", args: [ret_ty, args @ ..], .. } => {
let Some(ty) = ctx.ty else { let ty = self.ty(ret_ty);
self.report(
pos,
"type to return form eca is unknown, use `@as(<type>, @eca(...<expr>))`",
);
};
let mut parama = self.tys.parama(ty); let mut parama = self.tys.parama(ty);
let base = self.pool.arg_locs.len(); let base = self.pool.arg_locs.len();
for arg in args { for arg in args {
let arg = self.expr(arg)?; let arg = self.expr(arg)?;
if arg.ty == ty::Id::from(ty::TYPE) {
self.report(pos, "na na na nana, no passing types to ecas");
}
self.pass_arg(&arg, &mut parama); self.pass_arg(&arg, &mut parama);
self.pool.arg_locs.push(arg.loc); self.pool.arg_locs.push(arg.loc);
} }
@ -940,7 +932,7 @@ impl Codegen {
let Some(ty) = ctx.ty else { let Some(ty) = ctx.ty else {
self.report( self.report(
expr.pos(), expr.pos(),
"type to cast to is unknown, use `@as(<type>, @intcast(<expr>))`", "type to cast to is unknown, use `@as(<type>, <expr>)`",
); );
}; };
let mut val = self.expr(val)?; let mut val = self.expr(val)?;