From bf0ff03b49e345514b34e8c0acb5e63e63423438 Mon Sep 17 00:00:00 2001 From: kayomn Date: Sun, 4 Jun 2023 14:45:06 +0000 Subject: [PATCH] Add stubs for chunk executor to be implemented in --- source/ona/kym/Chunk.zig | 7 +++++++ source/ona/kym/Environment.zig | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/source/ona/kym/Chunk.zig b/source/ona/kym/Chunk.zig index a2c10f1..287de16 100644 --- a/source/ona/kym/Chunk.zig +++ b/source/ona/kym/Chunk.zig @@ -210,6 +210,13 @@ pub fn error_details(self: Self) []const u8 { 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 { var message_data = Buffer{}; diff --git a/source/ona/kym/Environment.zig b/source/ona/kym/Environment.zig index e35742b..0a2855c 100644 --- a/source/ona/kym/Environment.zig +++ b/source/ona/kym/Environment.zig @@ -198,6 +198,10 @@ pub fn execute_data(self: *Self, source: DataSource) types.RuntimeError!types.Va const typeid = ""; 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 { (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), .{ .identity = typeid, .deinitializer = Behaviors.deinitialize, + .caller = Behaviors.call, }); defer self.discard(script);