This commit is contained in:
Justin Ethier 2015-10-10 02:21:10 -04:00
parent 9579a803bf
commit b7d13e6899

View file

@ -186,12 +186,13 @@ typedef struct {gc_header_type hdr; tag_type tag; double value;} double_type;
/* Define string type */ /* Define string type */
typedef struct {gc_header_type hdr; tag_type tag; int len; char *str;} string_type; typedef struct {gc_header_type hdr; tag_type tag; int len; char *str;} string_type;
// TODO: new way to allocate strings, but this requires changes to //// TODO: new way to allocate strings, but this requires changes to
// all functions that allocate strings, the GC, cgen, and maybe more. //// all functions that allocate strings, the GC, cgen, and maybe more.
#define make_string(cs, len, s) string_type cs; \ //// Because these strings are (at least for now) allocaed on the stack.
{ cs.tag = string_tag; cs.len = len; \ //#define make_string(cs, len, s) string_type cs; \
cs.str = alloca(sizeof(char) * (len + 1)); \ //{ cs.tag = string_tag; cs.len = len; \
strcpy(cs.str, s);} // cs.str = alloca(sizeof(char) * (len + 1)); \
// strcpy(cs.str, s);}
// TODO: all of the dhalloc below needs to go away... // TODO: all of the dhalloc below needs to go away...
#define make_string(cv,s) string_type cv; cv.tag = string_tag; \ #define make_string(cv,s) string_type cv; cv.tag = string_tag; \
{ int len = strlen(s); cv.str = dhallocp; \ { int len = strlen(s); cv.str = dhallocp; \