coding a better compiler
This commit is contained in:
		| @ -1207,6 +1207,24 @@ while (1) | ||||
| 	else | ||||
| 	{ | ||||
| 		hcl_logbfmt (hcl, HCL_LOG_STDERR, "OK: got cnode - %p\n", xx); | ||||
|  | ||||
| 		if (hcl_compile2(hcl, xx) <= -1)  | ||||
| 		{ | ||||
| 			hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERR: unable to compile - %p\n", xx); | ||||
| 			if (hcl->errnum == HCL_ESYNERR) | ||||
| 			{ | ||||
| 				print_synerr (hcl); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot compile object - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl)); | ||||
| 			} | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			hcl_decode (hcl, 0, hcl_getbclen(hcl)); | ||||
| 		} | ||||
|  | ||||
| 		hcl_freecnode (hcl, xx); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @ -66,7 +66,6 @@ libhcl_la_SOURCES = \ | ||||
| 	bigint.c \ | ||||
| 	cnode.c \ | ||||
| 	comp.c \ | ||||
| 	comp2.c \ | ||||
| 	debug.c \ | ||||
| 	decode.c \ | ||||
| 	dic.c \ | ||||
|  | ||||
| @ -151,14 +151,14 @@ am__DEPENDENCIES_5 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ | ||||
| 	$(am__DEPENDENCIES_3) $(am__DEPENDENCIES_4) | ||||
| libhcl_la_DEPENDENCIES = $(am__DEPENDENCIES_5) $(am__append_6) | ||||
| am_libhcl_la_OBJECTS = libhcl_la-bigint.lo libhcl_la-cnode.lo \ | ||||
| 	libhcl_la-comp.lo libhcl_la-comp2.lo libhcl_la-debug.lo \ | ||||
| 	libhcl_la-decode.lo libhcl_la-dic.lo libhcl_la-err.lo \ | ||||
| 	libhcl_la-exec.lo libhcl_la-fmt.lo libhcl_la-gc.lo \ | ||||
| 	libhcl_la-hcl.lo libhcl_la-heap.lo libhcl_la-number.lo \ | ||||
| 	libhcl_la-obj.lo libhcl_la-opt.lo libhcl_la-prim.lo \ | ||||
| 	libhcl_la-print.lo libhcl_la-rbt.lo libhcl_la-read.lo \ | ||||
| 	libhcl_la-read2.lo libhcl_la-sym.lo libhcl_la-utf8.lo \ | ||||
| 	libhcl_la-utl.lo libhcl_la-xma.lo | ||||
| 	libhcl_la-comp.lo libhcl_la-debug.lo libhcl_la-decode.lo \ | ||||
| 	libhcl_la-dic.lo libhcl_la-err.lo libhcl_la-exec.lo \ | ||||
| 	libhcl_la-fmt.lo libhcl_la-gc.lo libhcl_la-hcl.lo \ | ||||
| 	libhcl_la-heap.lo libhcl_la-number.lo libhcl_la-obj.lo \ | ||||
| 	libhcl_la-opt.lo libhcl_la-prim.lo libhcl_la-print.lo \ | ||||
| 	libhcl_la-rbt.lo libhcl_la-read.lo libhcl_la-read2.lo \ | ||||
| 	libhcl_la-sym.lo libhcl_la-utf8.lo libhcl_la-utl.lo \ | ||||
| 	libhcl_la-xma.lo | ||||
| libhcl_la_OBJECTS = $(am_libhcl_la_OBJECTS) | ||||
| AM_V_lt = $(am__v_lt_@AM_V@) | ||||
| am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) | ||||
| @ -198,7 +198,6 @@ depcomp = $(SHELL) $(top_srcdir)/ac/depcomp | ||||
| am__maybe_remake_depfiles = depfiles | ||||
| am__depfiles_remade = ./$(DEPDIR)/libhcl_la-bigint.Plo \ | ||||
| 	./$(DEPDIR)/libhcl_la-cnode.Plo ./$(DEPDIR)/libhcl_la-comp.Plo \ | ||||
| 	./$(DEPDIR)/libhcl_la-comp2.Plo \ | ||||
| 	./$(DEPDIR)/libhcl_la-debug.Plo \ | ||||
| 	./$(DEPDIR)/libhcl_la-decode.Plo ./$(DEPDIR)/libhcl_la-dic.Plo \ | ||||
| 	./$(DEPDIR)/libhcl_la-err.Plo ./$(DEPDIR)/libhcl_la-exec.Plo \ | ||||
| @ -394,6 +393,7 @@ pdfdir = @pdfdir@ | ||||
| prefix = @prefix@ | ||||
| program_transform_name = @program_transform_name@ | ||||
| psdir = @psdir@ | ||||
| runstatedir = @runstatedir@ | ||||
| sbindir = @sbindir@ | ||||
| sharedstatedir = @sharedstatedir@ | ||||
| srcdir = @srcdir@ | ||||
| @ -440,7 +440,6 @@ libhcl_la_SOURCES = \ | ||||
| 	bigint.c \ | ||||
| 	cnode.c \ | ||||
| 	comp.c \ | ||||
| 	comp2.c \ | ||||
| 	debug.c \ | ||||
| 	decode.c \ | ||||
| 	dic.c \ | ||||
| @ -579,7 +578,6 @@ distclean-compile: | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-bigint.Plo@am__quote@ # am--include-marker | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-cnode.Plo@am__quote@ # am--include-marker | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-comp.Plo@am__quote@ # am--include-marker | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-comp2.Plo@am__quote@ # am--include-marker | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-debug.Plo@am__quote@ # am--include-marker | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-decode.Plo@am__quote@ # am--include-marker | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_la-dic.Plo@am__quote@ # am--include-marker | ||||
| @ -659,13 +657,6 @@ libhcl_la-comp.lo: comp.c | ||||
| @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||||
| @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhcl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhcl_la-comp.lo `test -f 'comp.c' || echo '$(srcdir)/'`comp.c | ||||
|  | ||||
| libhcl_la-comp2.lo: comp2.c | ||||
| @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhcl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhcl_la-comp2.lo -MD -MP -MF $(DEPDIR)/libhcl_la-comp2.Tpo -c -o libhcl_la-comp2.lo `test -f 'comp2.c' || echo '$(srcdir)/'`comp2.c | ||||
| @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libhcl_la-comp2.Tpo $(DEPDIR)/libhcl_la-comp2.Plo | ||||
| @AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='comp2.c' object='libhcl_la-comp2.lo' libtool=yes @AMDEPBACKSLASH@ | ||||
| @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||||
| @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhcl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libhcl_la-comp2.lo `test -f 'comp2.c' || echo '$(srcdir)/'`comp2.c | ||||
|  | ||||
| libhcl_la-debug.lo: debug.c | ||||
| @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhcl_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libhcl_la-debug.lo -MD -MP -MF $(DEPDIR)/libhcl_la-debug.Tpo -c -o libhcl_la-debug.lo `test -f 'debug.c' || echo '$(srcdir)/'`debug.c | ||||
| @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libhcl_la-debug.Tpo $(DEPDIR)/libhcl_la-debug.Plo | ||||
| @ -1013,7 +1004,6 @@ distclean: distclean-am | ||||
| 		-rm -f ./$(DEPDIR)/libhcl_la-bigint.Plo | ||||
| 	-rm -f ./$(DEPDIR)/libhcl_la-cnode.Plo | ||||
| 	-rm -f ./$(DEPDIR)/libhcl_la-comp.Plo | ||||
| 	-rm -f ./$(DEPDIR)/libhcl_la-comp2.Plo | ||||
| 	-rm -f ./$(DEPDIR)/libhcl_la-debug.Plo | ||||
| 	-rm -f ./$(DEPDIR)/libhcl_la-decode.Plo | ||||
| 	-rm -f ./$(DEPDIR)/libhcl_la-dic.Plo | ||||
| @ -1090,7 +1080,6 @@ maintainer-clean: maintainer-clean-am | ||||
| 		-rm -f ./$(DEPDIR)/libhcl_la-bigint.Plo | ||||
| 	-rm -f ./$(DEPDIR)/libhcl_la-cnode.Plo | ||||
| 	-rm -f ./$(DEPDIR)/libhcl_la-comp.Plo | ||||
| 	-rm -f ./$(DEPDIR)/libhcl_la-comp2.Plo | ||||
| 	-rm -f ./$(DEPDIR)/libhcl_la-debug.Plo | ||||
| 	-rm -f ./$(DEPDIR)/libhcl_la-decode.Plo | ||||
| 	-rm -f ./$(DEPDIR)/libhcl_la-dic.Plo | ||||
|  | ||||
| @ -61,11 +61,10 @@ hcl_cnode_t* hcl_makecnodecharlit (hcl_t* hcl, const hcl_ioloc_t* loc, const hcl | ||||
| 	return c; | ||||
| } | ||||
|  | ||||
| hcl_cnode_t* hcl_makecnodesymbol (hcl_t* hcl, const hcl_ioloc_t* loc, int dotted, const hcl_ooch_t* ptr, hcl_oow_t len) | ||||
| hcl_cnode_t* hcl_makecnodesymbol (hcl_t* hcl, const hcl_ioloc_t* loc, const hcl_ooch_t* ptr, hcl_oow_t len) | ||||
| { | ||||
| 	hcl_cnode_t* c =  make_cnode(hcl, HCL_CNODE_SYMBOL, loc, HCL_SIZEOF(*ptr) * (len + 1)); | ||||
| 	if (HCL_UNLIKELY(!c)) return HCL_NULL; | ||||
| 	c->u.symbol.dotted = dotted; | ||||
| 	c->u.symbol.ptr = (hcl_ooch_t*)(c + 1); | ||||
| 	c->u.symbol.len = len; | ||||
| 	hcl_copy_oochars (c->u.symbol.ptr, ptr, len); | ||||
| @ -73,6 +72,17 @@ hcl_cnode_t* hcl_makecnodesymbol (hcl_t* hcl, const hcl_ioloc_t* loc, int dotted | ||||
| 	return c; | ||||
| } | ||||
|  | ||||
| hcl_cnode_t* hcl_makecnodedsymbol (hcl_t* hcl, const hcl_ioloc_t* loc, const hcl_ooch_t* ptr, hcl_oow_t len) | ||||
| { | ||||
| 	hcl_cnode_t* c =  make_cnode(hcl, HCL_CNODE_DSYMBOL, loc, HCL_SIZEOF(*ptr) * (len + 1)); | ||||
| 	if (HCL_UNLIKELY(!c)) return HCL_NULL; | ||||
| 	c->u.dsymbol.ptr = (hcl_ooch_t*)(c + 1); | ||||
| 	c->u.dsymbol.len = len; | ||||
| 	hcl_copy_oochars (c->u.dsymbol.ptr, ptr, len); | ||||
| 	c->u.dsymbol.ptr[len] = '\0'; | ||||
| 	return c; | ||||
| } | ||||
|  | ||||
| hcl_cnode_t* hcl_makecnodestrlit (hcl_t* hcl, const hcl_ioloc_t* loc, const hcl_ooch_t* ptr, hcl_oow_t len) | ||||
| { | ||||
| 	hcl_cnode_t* c =  make_cnode(hcl, HCL_CNODE_STRLIT, loc, HCL_SIZEOF(*ptr) * (len + 1)); | ||||
|  | ||||
| @ -2770,7 +2770,7 @@ static HCL_INLINE int emit_set (hcl_t* hcl) | ||||
|  | ||||
| /* ========================================================================= */ | ||||
|  | ||||
| int hcl_compile2 (hcl_t* hcl, hcl_oop_t obj) | ||||
| int hcl_compile (hcl_t* hcl, hcl_oop_t obj) | ||||
| { | ||||
| 	hcl_oow_t saved_bc_len, saved_lit_len; | ||||
| 	hcl_bitmask_t log_default_type_mask; | ||||
|  | ||||
							
								
								
									
										835
									
								
								hcl/lib/comp2.c
									
									
									
									
									
								
							
							
						
						
									
										835
									
								
								hcl/lib/comp2.c
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -89,6 +89,7 @@ static hcl_ooch_t* errstr[] = | ||||
| static char* synerrstr[] =  | ||||
| { | ||||
| 	"no error", | ||||
| 	"internal error", | ||||
| 	"illegal character", | ||||
| 	"illegal token", | ||||
| 	"comment not closed", | ||||
| @ -100,6 +101,7 @@ static char* synerrstr[] = | ||||
| 	"wrong error literal", | ||||
| 	"wrong smptr literal", | ||||
| 	"wrong multi-segment identifer", | ||||
| 	"invalid radix for a numeric literal", | ||||
|  | ||||
| 	"sudden end of input", | ||||
| 	"( expected", | ||||
|  | ||||
							
								
								
									
										13
									
								
								hcl/lib/gc.c
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								hcl/lib/gc.c
									
									
									
									
									
								
							| @ -58,6 +58,7 @@ static struct | ||||
|  | ||||
| /* ========================================================================= */ | ||||
|  | ||||
|  | ||||
| static void compact_symbol_table (hcl_t* hcl, hcl_oop_t _nil) | ||||
| { | ||||
| 	hcl_oop_char_t symbol; | ||||
| @ -837,3 +838,15 @@ int hcl_ignite (hcl_t* hcl) | ||||
| 	hcl->p.e = hcl->_nil; | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
|  | ||||
| int hcl_getsyncodebyoocs_noseterr (hcl_t* hcl, const hcl_oocs_t* name) | ||||
| { | ||||
| 	hcl_oow_t i; | ||||
| 	for (i = 0; i < HCL_COUNTOF(syminfo); i++) | ||||
| 	{ | ||||
| 		if (hcl_comp_oochars(syminfo[i].ptr, syminfo[i].len, name->ptr, name->len) == 0)  | ||||
| 			return syminfo[i].syncode; | ||||
| 	} | ||||
| 	return 0; /* 0 indicates no syntax code found */ | ||||
| } | ||||
|  | ||||
| @ -185,6 +185,7 @@ enum hcl_cnode_type_t | ||||
| { | ||||
| 	HCL_CNODE_CHARLIT, | ||||
| 	HCL_CNODE_SYMBOL, | ||||
| 	HCL_CNODE_DSYMBOL, /* dotted symbol */ | ||||
| 	HCL_CNODE_STRLIT, | ||||
| 	HCL_CNODE_NUMLIT, | ||||
| 	HCL_CNODE_RADNUMLIT, | ||||
| @ -195,6 +196,7 @@ enum hcl_cnode_type_t | ||||
| 	HCL_CNODE_TRUE, | ||||
| 	HCL_CNODE_FALSE, | ||||
|  | ||||
| #if 0 | ||||
| 	HCL_CNODE_AND, | ||||
| 	HCL_CNODE_BREAK, | ||||
| 	HCL_CNODE_DEFUN, | ||||
| @ -209,6 +211,7 @@ enum hcl_cnode_type_t | ||||
| 	HCL_CNODE_SET, | ||||
| 	HCL_CNODE_UNTIL, | ||||
| 	HCL_CNODE_WHILE, | ||||
| #endif | ||||
|  | ||||
| 	HCL_CNODE_CONS, | ||||
| 	HCL_CNODE_LIST | ||||
| @ -227,32 +230,14 @@ struct hcl_cnode_t | ||||
| 		{ | ||||
| 			hcl_ooch_t v; | ||||
| 		} charlit; | ||||
| 		struct | ||||
| 		{ | ||||
| 			int dotted; | ||||
| 			hcl_ooch_t* ptr; | ||||
| 			hcl_oow_t len; | ||||
| 		} symbol; | ||||
| 		struct | ||||
| 		{ | ||||
| 			hcl_ooch_t* ptr; | ||||
| 			hcl_oow_t len; | ||||
| 		} strlit; | ||||
| 		struct | ||||
| 		{ | ||||
| 			hcl_ooch_t* ptr; | ||||
| 			hcl_oow_t len; | ||||
| 		} numlit; | ||||
| 		struct | ||||
| 		{ | ||||
| 			hcl_ooch_t* ptr; | ||||
| 			hcl_oow_t len; | ||||
| 		} radnumlit; | ||||
| 		struct | ||||
| 		{ | ||||
| 			hcl_ooch_t* ptr; | ||||
| 			hcl_oow_t len; | ||||
| 		} fpdeclit; | ||||
|  | ||||
| 		hcl_oocs_t symbol; | ||||
| 		hcl_oocs_t dsymbol; | ||||
| 		hcl_oocs_t strlit; | ||||
| 		hcl_oocs_t numlit; | ||||
| 		hcl_oocs_t radnumlit; | ||||
| 		hcl_oocs_t fpdeclit; | ||||
|  | ||||
| 		struct | ||||
| 		{ | ||||
| 			hcl_oow_t v; | ||||
| @ -279,6 +264,7 @@ struct hcl_cframe_t | ||||
| { | ||||
| 	int       opcode; | ||||
| 	hcl_oop_t operand; | ||||
|  | ||||
| 	union | ||||
| 	{ | ||||
| 		struct | ||||
| @ -316,6 +302,48 @@ struct hcl_cframe_t | ||||
| }; | ||||
| typedef struct hcl_cframe_t hcl_cframe_t; | ||||
|  | ||||
| struct hcl_cframe2_t | ||||
| { | ||||
| 	int          opcode; | ||||
| 	hcl_cnode_t* operand; | ||||
|  | ||||
| 	union | ||||
| 	{ | ||||
| 		struct | ||||
| 		{ | ||||
| 			int var_type; | ||||
| 		} set; | ||||
|  | ||||
| 		struct | ||||
| 		{ | ||||
| 			hcl_ooi_t cond_pos; | ||||
| 			hcl_ooi_t body_pos; | ||||
| 		} post_while; | ||||
|  | ||||
| 		struct | ||||
| 		{ | ||||
| 			hcl_ooi_t body_pos; | ||||
| 		} post_if; | ||||
|  | ||||
| 		struct | ||||
| 		{ | ||||
| 			hcl_ooi_t index; | ||||
| 		} array_list; | ||||
|  | ||||
| 		struct | ||||
| 		{ | ||||
| 			hcl_ooi_t index; | ||||
| 		} bytearray_list; | ||||
|  | ||||
| 		struct | ||||
| 		{ | ||||
| 			hcl_ooi_t lfbase_pos; | ||||
| 			hcl_ooi_t lfsize_pos; | ||||
| 		} lambda; | ||||
| 	} u; | ||||
| }; | ||||
| typedef struct hcl_cframe2_t hcl_cframe2_t; | ||||
|  | ||||
| struct hcl_blk_info_t | ||||
| { | ||||
| 	hcl_oow_t tmprcnt; | ||||
| @ -334,6 +362,14 @@ struct hcl_rstl_t /* reader stack for list reading */ | ||||
| 	hcl_rstl_t* prev; | ||||
| }; | ||||
|  | ||||
|  | ||||
| typedef struct hcl_oocx_t hcl_oocx_t; | ||||
| struct hcl_oocx_t | ||||
| { | ||||
| 	hcl_oocs_t s; | ||||
| 	hcl_oow_t capa; | ||||
| }; | ||||
|  | ||||
| struct hcl_compiler_t | ||||
| { | ||||
| 	/* output handler */ | ||||
| @ -400,6 +436,13 @@ struct hcl_compiler_t | ||||
| 		hcl_ooi_t     top; | ||||
| 		hcl_oow_t     capa; | ||||
| 	} cfs; | ||||
|  | ||||
| 	struct | ||||
| 	{ | ||||
| 		hcl_cframe2_t* ptr; | ||||
| 		hcl_ooi_t     top; | ||||
| 		hcl_oow_t     capa; | ||||
| 	} cfs2; | ||||
| 	/* == END COMPILER STACK == */ | ||||
|  | ||||
| 	struct | ||||
| @ -409,6 +452,8 @@ struct hcl_compiler_t | ||||
| 		hcl_oow_t capa; | ||||
| 	} tv; /* temporary variables including arguments */ | ||||
|  | ||||
| 	hcl_oocx_t tv2; | ||||
|  | ||||
| 	struct | ||||
| 	{ | ||||
| 		hcl_ooi_t depth; | ||||
| @ -802,7 +847,7 @@ void* hcl_callocheapmem ( | ||||
| 	hcl_oow_t    size | ||||
| ); | ||||
|  | ||||
| void* hcl_callocheapmem_noerr ( | ||||
| void* hcl_callocheapmem_noseterr ( | ||||
| 	hcl_t*       hcl, | ||||
| 	hcl_heap_t*  heap, | ||||
| 	hcl_oow_t    size | ||||
| @ -901,10 +946,15 @@ hcl_oow_t hcl_getobjpayloadbytes ( | ||||
| ); | ||||
|  | ||||
| void hcl_gc_ms_sweep_lazy ( | ||||
| 	hcl_t*    moo, | ||||
| 	hcl_t*    hcl, | ||||
| 	hcl_oow_t allocsize | ||||
| ); | ||||
|  | ||||
| int hcl_getsyncodebyoocs_noseterr ( | ||||
| 	hcl_t*            hcl, | ||||
| 	const hcl_oocs_t* name | ||||
| ); | ||||
|  | ||||
| /* ========================================================================= */ | ||||
| /* utf8.c                                                                    */ | ||||
| /* ========================================================================= */ | ||||
| @ -1261,7 +1311,8 @@ hcl_cnode_t* hcl_makecnodenil (hcl_t* hcl, const hcl_ioloc_t* loc); | ||||
| hcl_cnode_t* hcl_makecnodetrue (hcl_t* hcl, const hcl_ioloc_t* loc); | ||||
| hcl_cnode_t* hcl_makecnodefalse (hcl_t* hcl, const hcl_ioloc_t* loc); | ||||
| hcl_cnode_t* hcl_makecnodecharlit (hcl_t* hcl, const hcl_ioloc_t* loc, const hcl_ooch_t ch); | ||||
| hcl_cnode_t* hcl_makecnodesymbol (hcl_t* hcl, const hcl_ioloc_t* loc, int dotted, const hcl_ooch_t* ptr, hcl_oow_t len); | ||||
| hcl_cnode_t* hcl_makecnodesymbol (hcl_t* hcl, const hcl_ioloc_t* loc, const hcl_ooch_t* ptr, hcl_oow_t len); | ||||
| hcl_cnode_t* hcl_makecnodedsymbol (hcl_t* hcl, const hcl_ioloc_t* loc, const hcl_ooch_t* ptr, hcl_oow_t len); | ||||
| hcl_cnode_t* hcl_makecnodestrlit (hcl_t* hcl, const hcl_ioloc_t* loc, const hcl_ooch_t* ptr, hcl_oow_t len); | ||||
| hcl_cnode_t* hcl_makecnodenumlit (hcl_t* hcl, const hcl_ioloc_t* loc, const hcl_ooch_t* ptr, hcl_oow_t len); | ||||
| hcl_cnode_t* hcl_makecnoderadnumlit (hcl_t* hcl, const hcl_ioloc_t* loc, const hcl_ooch_t* ptr, hcl_oow_t len); | ||||
|  | ||||
| @ -95,6 +95,7 @@ typedef enum hcl_errnum_t hcl_errnum_t; | ||||
| enum hcl_synerrnum_t | ||||
| { | ||||
| 	HCL_SYNERR_NOERR, | ||||
| 	HCL_SYNERR_INTERN,        /* internal error */ | ||||
| 	HCL_SYNERR_ILCHR,         /* illegal character */ | ||||
| 	HCL_SYNERR_ILTOK,         /* invalid token */ | ||||
| 	HCL_SYNERR_CMTNC,         /* comment not closed */ | ||||
| @ -106,6 +107,7 @@ enum hcl_synerrnum_t | ||||
| 	HCL_SYNERR_ERRLIT,        /* wrong error literal */ | ||||
| 	HCL_SYNERR_SMPTRLIT,      /* wrong smptr literal */ | ||||
| 	HCL_SYNERR_MSEGIDENT,     /* wrong multi-segment identifier */ | ||||
| 	HCL_SYNERR_RADIX,         /* invalid radix for a numeric literal */ | ||||
|  | ||||
| 	HCL_SYNERR_EOF,           /* sudden end of input */ | ||||
| 	HCL_SYNERR_LPAREN,        /* ( expected */ | ||||
|  | ||||
| @ -107,7 +107,7 @@ void* hcl_callocheapmem (hcl_t* hcl, hcl_heap_t* heap, hcl_oow_t size) | ||||
| 	return ptr; | ||||
| } | ||||
|  | ||||
| void* hcl_callocheapmem_noerr (hcl_t* hcl, hcl_heap_t* heap, hcl_oow_t size) | ||||
| void* hcl_callocheapmem_noseterr (hcl_t* hcl, hcl_heap_t* heap, hcl_oow_t size) | ||||
| { | ||||
| 	void* ptr; | ||||
| 	ptr = HCL_MMGR_ALLOC(&heap->xmmgr, size); | ||||
|  | ||||
| @ -62,7 +62,7 @@ void* hcl_allocbytes (hcl_t* hcl, hcl_oow_t size) | ||||
|  | ||||
| 	if (hcl->gci.lazy_sweep) hcl_gc_ms_sweep_lazy (hcl, allocsize); | ||||
|  | ||||
| 	gch = (hcl_gchdr_t*)hcl_callocheapmem_noerr(hcl, hcl->heap, allocsize);  | ||||
| 	gch = (hcl_gchdr_t*)hcl_callocheapmem_noseterr(hcl, hcl->heap, allocsize);  | ||||
| 	if (!gch) | ||||
| 	{ | ||||
| 		if (HCL_UNLIKELY(hcl->option.trait & HCL_TRAIT_NOGC)) goto calloc_heapmem_fail; | ||||
| @ -71,7 +71,7 @@ void* hcl_allocbytes (hcl_t* hcl, hcl_oow_t size) | ||||
| 		hcl_gc (hcl, 0); | ||||
| 		if (hcl->gci.lazy_sweep) hcl_gc_ms_sweep_lazy (hcl, allocsize); | ||||
|  | ||||
| 		gch = (hcl_gchdr_t*)hcl_callocheapmem_noerr(hcl, hcl->heap, allocsize);  | ||||
| 		gch = (hcl_gchdr_t*)hcl_callocheapmem_noseterr(hcl, hcl->heap, allocsize);  | ||||
| 		if (HCL_UNLIKELY(!gch))  | ||||
| 		{ | ||||
| 		sweep_the_rest: | ||||
|  | ||||
| @ -2256,6 +2256,14 @@ static void fini_compiler (hcl_t* hcl) | ||||
| 			hcl->c->cfs.capa = 0; | ||||
| 		} | ||||
|  | ||||
| 		if (hcl->c->cfs2.ptr) | ||||
| 		{ | ||||
| 			hcl_freemem (hcl, hcl->c->cfs2.ptr); | ||||
| 			hcl->c->cfs2.ptr = HCL_NULL; | ||||
| 			hcl->c->cfs2.top = -1; | ||||
| 			hcl->c->cfs2.capa = 0; | ||||
| 		} | ||||
|  | ||||
| 		if (hcl->c->tv.ptr) | ||||
| 		{ | ||||
| 			hcl_freemem (hcl, hcl->c->tv.ptr); | ||||
| @ -2317,6 +2325,7 @@ int hcl_attachio (hcl_t* hcl, hcl_ioimpl_t reader, hcl_ioimpl_t printer) | ||||
| 		hcl->c->r.e = hcl->_nil; | ||||
|  | ||||
| 		hcl->c->cfs.top = -1; | ||||
| 		hcl->c->cfs2.top = -1; | ||||
| 		hcl->c->blk.depth = -1; | ||||
| 	} | ||||
| 	else if (hcl->c->reader || hcl->c->printer) | ||||
|  | ||||
| @ -1638,7 +1638,7 @@ static hcl_cnode_t* read_vlist (hcl_t* hcl) | ||||
| 	{ | ||||
| 		hcl_cnode_t* sym, * cons; | ||||
|  | ||||
| 		sym = hcl_makecnodesymbol(hcl, TOKEN_LOC(hcl), 0, TOKEN_NAME_PTR(hcl), TOKEN_NAME_LEN(hcl)); | ||||
| 		sym = hcl_makecnodesymbol(hcl, TOKEN_LOC(hcl), TOKEN_NAME_PTR(hcl), TOKEN_NAME_LEN(hcl)); | ||||
| 		if (HCL_UNLIKELY(!sym)) goto oops; | ||||
|  | ||||
| #if 0 | ||||
| @ -1958,11 +1958,11 @@ static hcl_cnode_t* read_object (hcl_t* hcl) | ||||
| 				break; | ||||
|  | ||||
| 			case HCL_IOTOK_IDENT: | ||||
| 				obj = hcl_makecnodesymbol(hcl, TOKEN_LOC(hcl), 0, TOKEN_NAME_PTR(hcl), TOKEN_NAME_LEN(hcl)); | ||||
| 				obj = hcl_makecnodesymbol(hcl, TOKEN_LOC(hcl), TOKEN_NAME_PTR(hcl), TOKEN_NAME_LEN(hcl)); | ||||
| 				break; | ||||
|  | ||||
| 			case HCL_IOTOK_IDENT_DOTTED: | ||||
| 				obj = hcl_makecnodesymbol(hcl, TOKEN_LOC(hcl), 1, TOKEN_NAME_PTR(hcl), TOKEN_NAME_LEN(hcl)); | ||||
| 				obj = hcl_makecnodedsymbol(hcl, TOKEN_LOC(hcl), TOKEN_NAME_PTR(hcl), TOKEN_NAME_LEN(hcl)); | ||||
| 				break; | ||||
| 		} | ||||
|  | ||||
| @ -2045,6 +2045,14 @@ hcl_cnode_t* hcl_read2 (hcl_t* hcl) | ||||
| } | ||||
|  | ||||
|  | ||||
| /* TODO: | ||||
| hcl_cnodetoobj (hcl_t* hcl, hcl_cnode_t* x) | ||||
| { | ||||
|  * drop location information and compose object ?? | ||||
|  * is it doable? can convert a dotted symbol to a proper value?  | ||||
| } | ||||
| */ | ||||
|   | ||||
| #if 0 | ||||
| /* ========================================================================= */ | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user