Implement Bytecode Executor for Kym #19
|
@ -210,6 +210,13 @@ pub fn error_details(self: Self) []const u8 {
|
||||||
return self.message_data.values;
|
return self.message_data.values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn execute(self: *Self) types.RuntimeError!types.Val {
|
||||||
|
_ = self;
|
||||||
|
// TODO: Implement.
|
||||||
|
|
||||||
|
return .nil;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn init(env: *Environment, chunk_name: []const u8) coral.io.AllocationError!Self {
|
pub fn init(env: *Environment, chunk_name: []const u8) coral.io.AllocationError!Self {
|
||||||
var message_data = Buffer{};
|
var message_data = Buffer{};
|
||||||
|
|
||||||
|
|
|
@ -198,6 +198,10 @@ pub fn execute_data(self: *Self, source: DataSource) types.RuntimeError!types.Va
|
||||||
const typeid = "<chunk>";
|
const typeid = "<chunk>";
|
||||||
|
|
||||||
const Behaviors = struct {
|
const Behaviors = struct {
|
||||||
|
fn call(context: ObjectInfo.CallContext) types.RuntimeError!types.Val {
|
||||||
|
return (context.env.native_cast(context.callable, typeid, Chunk) catch unreachable).execute();
|
||||||
|
}
|
||||||
|
|
||||||
fn deinitialize(context: ObjectInfo.DeinitializeContext) void {
|
fn deinitialize(context: ObjectInfo.DeinitializeContext) void {
|
||||||
(context.env.native_cast(context.obj, typeid, Chunk) catch unreachable).deinit();
|
(context.env.native_cast(context.obj, typeid, Chunk) catch unreachable).deinit();
|
||||||
}
|
}
|
||||||
|
@ -220,6 +224,7 @@ pub fn execute_data(self: *Self, source: DataSource) types.RuntimeError!types.Va
|
||||||
const script = try self.new_object(coral.io.bytes_of(&compiled_chunk), .{
|
const script = try self.new_object(coral.io.bytes_of(&compiled_chunk), .{
|
||||||
.identity = typeid,
|
.identity = typeid,
|
||||||
.deinitializer = Behaviors.deinitialize,
|
.deinitializer = Behaviors.deinitialize,
|
||||||
|
.caller = Behaviors.call,
|
||||||
});
|
});
|
||||||
|
|
||||||
defer self.discard(script);
|
defer self.discard(script);
|
||||||
|
|
Loading…
Reference in New Issue