@@ -15,9 +15,6 @@ const SpvBool = spv.SpvBool;
1515
1616// DUMB INDEV OPCODES TODO :
1717// OpVariable X
18- // OpFunction X
19- // OpLabel X
20- // OpCompositeConstruct X
2118// OpAccessChain X
2219// OpStore X
2320// OpLoad X
@@ -51,6 +48,9 @@ pub const SetupDispatcher = block: {
5148 .TypeVector = opTypeVector ,
5249 .TypeVoid = opTypeVoid ,
5350 .Variable = opVariable ,
51+ .Function = opFunction ,
52+ .Label = opLabel ,
53+ .CompositeConstruct = opCompositeConstruct ,
5454 });
5555};
5656
@@ -334,7 +334,7 @@ fn opConstant(_: std.mem.Allocator, word_count: SpvWord, rt: *Runtime) RuntimeEr
334334 .Int = > {
335335 break :value if (word_count - 2 != 1 ) .{
336336 .Int = .{
337- .uint64 = try rt .it .next () | (@as (u64 , try rt .it .next ()) >> 32 ),
337+ .uint64 = @as ( u64 , try rt .it .next () ) | (@as (u64 , try rt .it .next ()) >> 32 ),
338338 },
339339 } else .{
340340 .Int = .{
@@ -382,6 +382,46 @@ fn opVariable(_: std.mem.Allocator, word_count: SpvWord, rt: *Runtime) RuntimeEr
382382 };
383383}
384384
385+ fn opFunction (allocator : std.mem.Allocator , _ : SpvWord , rt : * Runtime ) RuntimeError ! void {
386+ const return_type = try rt .it .next ();
387+ const id = try rt .it .next ();
388+ _ = rt .it .skip (); // Skip function control
389+ const function_type_id = try rt .it .next ();
390+
391+ rt .mod .results .items [id ].variant = .{
392+ .Function = .{
393+ .return_type = return_type ,
394+ .function_type = function_type_id ,
395+ .params = params : {
396+ if (rt .mod .results .items [function_type_id ].variant ) | variant | {
397+ const params_count = switch (variant ) {
398+ .Type = > | t | switch (t ) {
399+ .Function = > | f | f .params .len ,
400+ else = > return RuntimeError .InvalidSpirV ,
401+ },
402+ else = > return RuntimeError .InvalidSpirV ,
403+ };
404+ break :params allocator .alloc (SpvWord , params_count ) catch return RuntimeError .OutOfMemory ;
405+ }
406+ return RuntimeError .InvalidSpirV ;
407+ },
408+ },
409+ };
410+
411+ rt .current_function = & rt .mod .results .items [id ];
412+ }
413+
414+ fn opLabel (_ : std.mem.Allocator , _ : SpvWord , rt : * Runtime ) RuntimeError ! void {
415+ const id = try rt .it .next ();
416+ rt .mod .results .items [id ].variant = .{
417+ .Label = .{},
418+ };
419+ }
420+
421+ fn opCompositeConstruct (_ : std.mem.Allocator , _ : SpvWord , rt : * Runtime ) RuntimeError ! void {
422+ _ = rt ;
423+ }
424+
385425fn readString (allocator : std.mem.Allocator , it : * WordIterator ) RuntimeError ! []const u8 {
386426 var str : std .ArrayList (u8 ) = .empty ;
387427 while (it .nextOrNull ()) | word | {
0 commit comments