-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,7 +240,7 @@ bool can_cast_to_size_t(huo_int_t i) { | |
struct Value set(struct Value index_val, struct Value item, struct Value *to_set) { | ||
huo_int_t index = value_as_long(&index_val); | ||
if (!can_cast_to_size_t(index)) { | ||
ERROR("Index out of range for set: should be 0 <= %" PRIhi " < %zu", index, SIZE_MAX); | ||
ERROR("Index out of range for set: should be 0 <= %" PRIhi " < %llu", index, SIZE_MAX); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
incrediblesound
Member
|
||
} | ||
if (to_set->type == ARRAY) { | ||
return value_from_array(array_set((size_t) index, item, value_as_array(to_set))); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#include <assert.h> | ||
#include "structures.h" | ||
#include "../constants.h" | ||
#include "value.h" | ||
|
||
#include "../base_util.h" | ||
|
@@ -225,6 +226,32 @@ void value_negate(struct Value *v) { | |
} | ||
} | ||
|
||
struct String type_to_string(enum Value_type type){ | ||
switch (type) { | ||
case STRING: | ||
return string_copy_stack(&string_const); | ||
break; | ||
case FLOAT: | ||
case LONG: | ||
return string_copy_stack(&number_const); | ||
break; | ||
case ARRAY: | ||
return string_copy_stack(&array_const); | ||
break; | ||
case BOOL: | ||
return string_copy_stack(&boolean_const); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
TheLoneWolfling
Collaborator
|
||
break; | ||
case KEYWORD: | ||
return string_copy_stack(&keyword_const); | ||
break; | ||
case UNDEF: | ||
return string_copy_stack(&undefined_const); | ||
break; | ||
default: | ||
ERROR("Type error: unrecognized type: '%c'.", type) | ||
} | ||
} | ||
|
||
void value_free_stack(struct Value v) { | ||
switch (v.type) { | ||
case ARRAY: | ||
|
2 comments
on commit e9e2a7c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TheLoneWolfling I tried to use your utility functions to do this here but I'm not sure if I used them well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
This is wrong. SIZE_MAX is (or should be) of type size_t, as SIZE_MAX is defined to be the maximum value that a size_t can hold.