From ad4c8e35d448abf9777ee9c0c80d7a059e8e54bb Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 12 Jan 2021 00:21:43 +0000 Subject: [PATCH] changing read2.c --- lib/cnode.c | 18 +++++++++++++++--- lib/hcl-prv.h | 10 ++++++++++ lib/read2.c | 14 ++++++++++++-- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/lib/cnode.c b/lib/cnode.c index cc0c1bb..4fa55da 100644 --- a/lib/cnode.c +++ b/lib/cnode.c @@ -7,10 +7,10 @@ modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. + notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -38,6 +38,18 @@ static hcl_cnode_t* make_cnode (hcl_t* hcl, hcl_cnode_type_t type, const hcl_iol return cnode; } +hcl_cnode_t* hcl_makecnodersn (hcl_t* hcl, const hcl_ioloc_t* loc) +{ + hcl_cnode_t* cnode; + cnode = make_cnode(hcl, loc); + if (HCL_UNLIKELY(!cnode)) return HCL_NULL; + cnode->u.rsn.head = HCL_NULL; + cnode->u.rsn.tail = HCL_NULL; + cnode->u.rsn.flags = 0; + cnode->u.rsn.rsn_par = HCL_NULL; + return cnode; +} + hcl_cnode_t* hcl_makecnodenil (hcl_t* hcl, const hcl_ioloc_t* loc) { return make_cnode(hcl, HCL_CNODE_NIL, loc, 0); diff --git a/lib/hcl-prv.h b/lib/hcl-prv.h index 50019e7..022ccc9 100644 --- a/lib/hcl-prv.h +++ b/lib/hcl-prv.h @@ -183,6 +183,8 @@ struct hcl_iolink_t enum hcl_cnode_type_t { + HCL_CNODE_RSN, /* internally used */ + HCL_CNODE_CHARLIT, HCL_CNODE_STRLIT, HCL_CNODE_NUMLIT, @@ -226,6 +228,13 @@ struct hcl_cnode_t union { + struct + { + hcl_cnode_t* head; + hcl_cnode_t* tail; + hcl_oow_t count; + hcl_cnode_t* rsn_par; /* parent item in the stack */ + } rsn; /* reader stack node */ struct { hcl_ooch_t v; @@ -1237,6 +1246,7 @@ int hcl_emitbyteinstruction ( /* ========================================================================= */ /* cnode.c */ /* ========================================================================= */ +hcl_cnode_t* hcl_makecnodersn (hcl_t* hcl, const hcl_ioloc_t* loc); 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); diff --git a/lib/read2.c b/lib/read2.c index 8a8fdbe..c9ff061 100644 --- a/lib/read2.c +++ b/lib/read2.c @@ -13,7 +13,7 @@ documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAfRRANTIES + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT @@ -1405,8 +1405,9 @@ static int end_include (hcl_t* hcl) } -static HCL_INLINE hcl_oop_t enter_list (hcl_t* hcl, int flagv) +static HCL_INLINE hcl_cnode_t* enter_list (hcl_t* hcl, int flagv) { +#if 0 hcl_oop_oop_t rsa; /* upon entering a list, it pushes a frame of 4 slots. @@ -1426,6 +1427,15 @@ static HCL_INLINE hcl_oop_t enter_list (hcl_t* hcl, int flagv) rsa->slot[4] = HCL_SMOOI_TO_OOP(0); return hcl->c->r.s; +#else + hcl_cnode_t* rsn; + rsn = hcl_makecnodersn(hcl, loc) + if (HCL_UNLIKELY(!rsn)) return HCL_NULL + rsn->flags = flagv; + rsn->rsn_par = hcl->c->r.st; /* push */ + hcl->c.r.st = rsn; + return rsn; /* returns the stack top */ +#endif } static HCL_INLINE hcl_oop_t leave_list (hcl_t* hcl, int* flagv, int* oldflagv)