~sircmpwn/mercury

3e1f8b4542de311d84de5803a4dbd89627dd9d1e — Drew DeVault 2 months ago 9968af7
all: flesh out IPC generation support
5 files changed, 25 insertions(+), 5 deletions(-)

M cmd/hello/hello.ipc
M cmd/hello/main.ha
M cmd/init/main.ha
M errors/common.ha
M errors/syserror.ha
M cmd/hello/hello.ipc => cmd/hello/hello.ipc +1 -1
@@ 2,5 2,5 @@ namespace hello;

interface hello {
	call say_hello() void;
	call add(a: uint, b: uint) void;
	call add(a: uint, b: uint) uint;
};

M cmd/hello/main.ha => cmd/hello/main.ha +2 -2
@@ 22,6 22,6 @@ fn say_hello(object: *hello) void = {
	log::println("[hello] Hello world!");
};

fn add(object: *hello, a: uint, b: uint) void = {
	log::printfln("[hello] add {} + {} == {}", a, b, a + b);
fn add(object: *hello, a: uint, b: uint) uint = {
	return a + b;
};

M cmd/init/main.ha => cmd/init/main.ha +2 -1
@@ 35,7 35,8 @@ export fn main(bi: *rt::bootinfo) void = {
	helios::task_resume(proc.task)!;

	hello_say_hello(hello);
	hello_add(hello, 2, 2);
	const four = hello_add(hello, 2, 2);
	log::printfln("[init] hello_add 2 + 2 = {}", four);

	// XXX TEMP


M errors/common.ha => errors/common.ha +5 -1
@@ 57,5 57,9 @@ export type error = !(
	nomem |
	interrupted |
	again |
	opaque
	opaque |
	// syserrors
	invalid_caddr |
	invalid_cslot |
	invalid_ctype |
);

M errors/syserror.ha => errors/syserror.ha +15 -0
@@ 1,5 1,14 @@
use rt;

// The given capability address exceeds the bounds of its cspace.
export type invalid_caddr = !void;

// The desired cslot is already occupied by another capability.
export type invalid_cslot = !void;

// A provided capability is not the expected type for the requested operation.
export type invalid_ctype = !void;

// Wraps an [[rt::syserror]] to produce an [[errors::opaque]]. This is a
// non-portable interface which is mainly provided to support internal stdlib
// requirements.


@@ 12,6 21,12 @@ export fn syserror(err: rt::syserror) error = {
		return unsupported;
	case rt::would_block =>
		return again;
	case rt::invalid_caddr =>
		return invalid_caddr;
	case rt::invalid_cslot =>
		return invalid_cslot;
	case rt::invalid_ctype =>
		return invalid_ctype;
	case =>
		yield;
	};