feat: semantics for if statements and multi-prong if statements
This commit is contained in:
parent
9658c8a308
commit
ce5385ebac
6 changed files with 553 additions and 317 deletions
|
|
@ -227,15 +227,14 @@ pub const Object = struct {
|
|||
}
|
||||
|
||||
pub fn fromObject(story: *Story, object: *Object) !*Object.String {
|
||||
// NOTE: 20 bytes should be enough.
|
||||
const print_buffer_len = 20;
|
||||
var print_buffer: [print_buffer_len]u8 = undefined;
|
||||
|
||||
switch (object.tag) {
|
||||
.number => {
|
||||
// NOTE: 20 bytes should be enough.
|
||||
const print_buffer_len = 20;
|
||||
var print_buffer: [print_buffer_len]u8 = undefined;
|
||||
const number_object: *Object.Number = @ptrCast(object);
|
||||
const number_bytes = try std.fmt.bufPrint(&print_buffer, "{}", .{
|
||||
number_object.data.floating,
|
||||
number_object.data.integer,
|
||||
});
|
||||
return Object.String.create(story, number_bytes);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue