haku2: make server use haku2 (and make it work!)
This commit is contained in:
parent
c5e2892def
commit
48d03699bd
16 changed files with 329 additions and 174 deletions
|
@ -2,6 +2,7 @@ const std = @import("std");
|
|||
const mem = std.mem;
|
||||
const meta = std.meta;
|
||||
const math = std.math;
|
||||
const log = std.log.scoped(.system);
|
||||
|
||||
const bytecode = @import("bytecode.zig");
|
||||
const Opcode = bytecode.Opcode;
|
||||
|
@ -112,10 +113,13 @@ fn fromArgument(cx: Context, comptime T: type, i: usize) Vm.Error!T {
|
|||
if (val != .ref or val.ref.* != .list) return typeError(cx.vm, val, i, "list");
|
||||
return val.ref.list;
|
||||
},
|
||||
*const value.Shape => {
|
||||
value.Shape => {
|
||||
const val = cx.args[i];
|
||||
if (val != .ref or val.ref.* != .shape) return typeError(cx.vm, val, i, "shape");
|
||||
return &val.ref.shape;
|
||||
if (toShape(val)) |shape| {
|
||||
return shape;
|
||||
} else {
|
||||
return typeError(cx.vm, val, i, "shape");
|
||||
}
|
||||
},
|
||||
*const value.Closure => {
|
||||
const val = cx.args[i];
|
||||
|
@ -756,9 +760,9 @@ fn circle(center: Vec4, radius: f32) value.Ref {
|
|||
} } };
|
||||
}
|
||||
|
||||
fn stroke(thickness: f32, color: Rgba, shape: *const value.Shape) value.Ref {
|
||||
fn stroke(thickness: f32, color: Rgba, shape: value.Shape) value.Ref {
|
||||
return .{ .scribble = .{
|
||||
.shape = shape.*,
|
||||
.shape = shape,
|
||||
.action = .{ .stroke = .{
|
||||
.thickness = thickness,
|
||||
.color = color.value,
|
||||
|
@ -766,9 +770,9 @@ fn stroke(thickness: f32, color: Rgba, shape: *const value.Shape) value.Ref {
|
|||
} };
|
||||
}
|
||||
|
||||
fn fill(color: Rgba, shape: *const value.Shape) value.Ref {
|
||||
fn fill(color: Rgba, shape: value.Shape) value.Ref {
|
||||
return .{ .scribble = .{
|
||||
.shape = shape.*,
|
||||
.shape = shape,
|
||||
.action = .{ .fill = .{
|
||||
.color = color.value,
|
||||
} },
|
||||
|
@ -776,6 +780,7 @@ fn fill(color: Rgba, shape: *const value.Shape) value.Ref {
|
|||
}
|
||||
|
||||
fn withDotter(cont: *const value.Closure, cx: Context) Vm.Error!value.Ref {
|
||||
log.debug("withDotter({})", .{cont});
|
||||
if (cont.param_count != 1) {
|
||||
return cx.vm.throw("function passed to withDotter must have a single parameter (\\d -> _), but it has {}", .{cont.param_count});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue