Add stubs for chunk executor to be implemented in
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
kayomn 2023-06-04 14:45:06 +00:00
parent 7714dae4d8
commit bf0ff03b49
2 changed files with 12 additions and 0 deletions

View File

@ -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{};

View File

@ -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);