removed the option HCL_TRAIT_LANG_ENABLE_BLOCK, thus removing conditional codes for simplicity.
All checks were successful
continuous-integration/drone/push Build is passing

changed the compiler to require a block expression as the class body
This commit is contained in:
hyung-hwan 2024-07-06 12:16:05 +09:00
parent 0befaf0a97
commit 6407d3c175
10 changed files with 64 additions and 108 deletions

View File

@ -722,7 +722,7 @@ int main (int argc, char* argv[])
}; };
static hcl_bopt_t opt = static hcl_bopt_t opt =
{ {
"l:bnv", "l:nv",
lopt lopt
}; };
@ -730,7 +730,6 @@ int main (int argc, char* argv[])
hcl_oow_t heapsize = DEFAULT_HEAPSIZE; hcl_oow_t heapsize = DEFAULT_HEAPSIZE;
int verbose = 0; int verbose = 0;
int show_info = 0; int show_info = 0;
int enable_block = 0;
int nl_terminator = 0; int nl_terminator = 0;
const char* modlibdirs = HCL_NULL; const char* modlibdirs = HCL_NULL;
@ -746,7 +745,6 @@ int main (int argc, char* argv[])
print_usage: print_usage:
fprintf (stderr, "Usage: %s [options] script-filename [output-filename]\n", argv[0]); fprintf (stderr, "Usage: %s [options] script-filename [output-filename]\n", argv[0]);
fprintf (stderr, "Options are:\n"); fprintf (stderr, "Options are:\n");
fprintf (stderr, " -b enable block construct with {}\n");
fprintf (stderr, " -n enable line-break as expression terminator\n"); fprintf (stderr, " -n enable line-break as expression terminator\n");
return -1; return -1;
} }
@ -759,10 +757,6 @@ int main (int argc, char* argv[])
logopt = opt.arg; logopt = opt.arg;
break; break;
case 'b':
enable_block = 1;
break;
case 'n': case 'n':
nl_terminator = 1; nl_terminator = 1;
break; break;
@ -838,10 +832,8 @@ int main (int argc, char* argv[])
/*trait |= HCL_TRAIT_NOGC;*/ /*trait |= HCL_TRAIT_NOGC;*/
trait |= HCL_TRAIT_AWAIT_PROCS; trait |= HCL_TRAIT_AWAIT_PROCS;
#if 0 #if 0
if (enable_block) trait |= HCL_TRAIT_LANG_ENABLE_BLOCK;
if (nl_terminator) trait |= HCL_TRAIT_LANG_ENABLE_EOL; if (nl_terminator) trait |= HCL_TRAIT_LANG_ENABLE_EOL;
#else #else
trait |= HCL_TRAIT_LANG_ENABLE_BLOCK;
trait |= HCL_TRAIT_LANG_ENABLE_EOL; trait |= HCL_TRAIT_LANG_ENABLE_EOL;
#endif #endif
hcl_setoption (hcl, HCL_TRAIT, &trait); hcl_setoption (hcl, HCL_TRAIT, &trait);

View File

@ -67,7 +67,6 @@ type Ext struct {
type BitMask C.hcl_bitmask_t type BitMask C.hcl_bitmask_t
const TRAIT_LANG_ENABLE_BLOCK BitMask = C.HCL_TRAIT_LANG_ENABLE_BLOCK
const TRAIT_LANG_ENABLE_EOL BitMask = C.HCL_TRAIT_LANG_ENABLE_EOL const TRAIT_LANG_ENABLE_EOL BitMask = C.HCL_TRAIT_LANG_ENABLE_EOL
var inst_table InstanceTable var inst_table InstanceTable

View File

@ -28,9 +28,10 @@
* no variable declaration if not enclosed in parentheses */ * no variable declaration if not enclosed in parentheses */
#define LANG_LIMIT_DO #define LANG_LIMIT_DO
#define FOR_NONE (0) #define FOR_NONE (0)
#define FOR_IF (1) #define FOR_IF (1)
#define FOR_TRY (2) #define FOR_TRY (2)
#define FOR_CLASS (3)
enum enum
{ {
@ -469,8 +470,6 @@ static int check_block_expression_as_body (hcl_t* hcl, hcl_cnode_t* c, const hcl
car = HCL_CNODE_CONS_CAR(c); car = HCL_CNODE_CONS_CAR(c);
if (!car || (HCL_CNODE_IS_CONS_CONCODED(car, HCL_CONCODE_VLIST) || if (!car || (HCL_CNODE_IS_CONS_CONCODED(car, HCL_CONCODE_VLIST) ||
HCL_CNODE_IS_ELIST_CONCODED(car, HCL_CONCODE_VLIST))) HCL_CNODE_IS_ELIST_CONCODED(car, HCL_CONCODE_VLIST)))
/*(!HCL_CNODE_IS_CONS_CONCODED(car, HCL_CONCODE_BLOCK) &&
!HCL_CNODE_IS_ELIST_CONCODED(car, HCL_CONCODE_BLOCK)))*/
{ {
no_block: no_block:
hcl_setsynerrbfmt ( hcl_setsynerrbfmt (
@ -480,6 +479,13 @@ static int check_block_expression_as_body (hcl_t* hcl, hcl_cnode_t* c, const hcl
return -1; return -1;
} }
if (for_what == FOR_CLASS)
{
/* the class body must be enclosed in { .. }. e.g class X { ... } */
if (!HCL_CNODE_IS_CONS_CONCODED(car, HCL_CONCODE_BLOCK) &&
!HCL_CNODE_IS_ELIST_CONCODED(car, HCL_CONCODE_BLOCK)) goto no_block;
}
/* there are special words that can't start a new expression */ /* there are special words that can't start a new expression */
if (HCL_CNODE_IS_SYMBOL_SYNCODED(car, HCL_SYNCODE_ELIF) || if (HCL_CNODE_IS_SYMBOL_SYNCODED(car, HCL_SYNCODE_ELIF) ||
HCL_CNODE_IS_SYMBOL_SYNCODED(car, HCL_SYNCODE_ELSE) || HCL_CNODE_IS_SYMBOL_SYNCODED(car, HCL_SYNCODE_ELSE) ||
@ -2331,10 +2337,7 @@ static HCL_INLINE int compile_else (hcl_t* hcl)
return -1; return -1;
} }
if (hcl->option.trait & HCL_TRAIT_LANG_ENABLE_BLOCK) if (check_block_expression_as_body(hcl, obj, cmd, FOR_NONE) <= -1) return -1;
{
if (check_block_expression_as_body(hcl, obj, cmd, FOR_NONE) <= -1) return -1;
}
SWITCH_TOP_CFRAME (hcl, COP_COMPILE_OBJECT_LIST, obj); SWITCH_TOP_CFRAME (hcl, COP_COMPILE_OBJECT_LIST, obj);
@ -2381,7 +2384,7 @@ static int compile_class (hcl_t* hcl, hcl_cnode_t* src, int defclass)
if (defclass) if (defclass)
{ {
/* defun must be followed by an explicit function name */ /* defclass must be followed by an explicit class name */
HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(cmd, HCL_SYNCODE_DEFCLASS)); HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(cmd, HCL_SYNCODE_DEFCLASS));
class_as_defclass: class_as_defclass:
@ -2426,16 +2429,9 @@ static int compile_class (hcl_t* hcl, hcl_cnode_t* src, int defclass)
class_name = HCL_CNODE_CONS_CAR(obj); class_name = HCL_CNODE_CONS_CAR(obj);
if (HCL_CNODE_IS_SYMBOL(class_name)) if (HCL_CNODE_IS_SYMBOL(class_name))
{ {
#if 0
hcl_setsynerrbfmt (
hcl, HCL_SYNERR_BANNEDVARNAME, HCL_CNODE_GET_LOC(class_name), HCL_CNODE_GET_TOK(class_name),
"class name not allowed in %.*js", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd));
return -1;
#else
/* to handle 'class' in place of 'defclass' */ /* to handle 'class' in place of 'defclass' */
defclass = 1; defclass = 1;
goto class_as_defclass; goto class_as_defclass;
#endif
} }
} }
@ -2447,7 +2443,7 @@ static int compile_class (hcl_t* hcl, hcl_cnode_t* src, int defclass)
hcl_cnode_t* tmp, * dcl; hcl_cnode_t* tmp, * dcl;
tmp = HCL_CNODE_CONS_CAR(obj); tmp = HCL_CNODE_CONS_CAR(obj);
if (!HCL_CNODE_IS_DBLCOLONS(tmp)) goto no_superclass; if (/*!HCL_CNODE_IS_COLON(tmp)*/!HCL_CNODE_IS_DBLCOLONS(tmp)) goto no_superclass;
tmp = obj; tmp = obj;
obj = HCL_CNODE_CONS_CDR(obj); obj = HCL_CNODE_CONS_CDR(obj);
@ -2537,7 +2533,7 @@ static HCL_INLINE int compile_class_p1 (hcl_t* hcl)
) )
*/ */
tmp = HCL_CNODE_CONS_CAR(obj); tmp = HCL_CNODE_CONS_CAR(obj);
if (HCL_CNODE_IS_DBLCOLONS(tmp)) if (/*HCL_CNODE_IS_COLON(tmp)|| */ HCL_CNODE_IS_DBLCOLONS(tmp))
{ {
/* class variables */ /* class variables */
hcl_oow_t checkpoint; hcl_oow_t checkpoint;
@ -2545,14 +2541,14 @@ static HCL_INLINE int compile_class_p1 (hcl_t* hcl)
obj = HCL_CNODE_CONS_CDR(obj); obj = HCL_CNODE_CONS_CDR(obj);
if (!obj || !HCL_CNODE_IS_CONS(obj)) if (!obj || !HCL_CNODE_IS_CONS(obj))
{ {
hcl_setsynerrbfmt (hcl, HCL_SYNERR_EOX, HCL_CNODE_GET_LOC(tmp), HCL_NULL, "no expression or declaration after triple colons"); hcl_setsynerrbfmt (hcl, HCL_SYNERR_EOX, HCL_CNODE_GET_LOC(tmp), HCL_NULL, "no expression or declaration after colon");
return -1; return -1;
} }
tmp = HCL_CNODE_CONS_CAR(obj); tmp = HCL_CNODE_CONS_CAR(obj);
if (!HCL_CNODE_IS_CONS_CONCODED(tmp, HCL_CONCODE_VLIST)) if (!HCL_CNODE_IS_CONS_CONCODED(tmp, HCL_CONCODE_VLIST))
{ {
hcl_setsynerrbfmt (hcl, HCL_SYNERR_EOX, HCL_CNODE_GET_LOC(tmp), HCL_NULL, "no declaration after triple colons"); hcl_setsynerrbfmt (hcl, HCL_SYNERR_EOX, HCL_CNODE_GET_LOC(tmp), HCL_NULL, "no declaration after colon");
return -1; return -1;
} }
@ -2624,10 +2620,7 @@ static HCL_INLINE int compile_class_p1 (hcl_t* hcl)
if (emit_push_literal(hcl, tmp, &cf->u._class.start_loc) <= -1) goto oops; if (emit_push_literal(hcl, tmp, &cf->u._class.start_loc) <= -1) goto oops;
} }
if (hcl->option.trait & HCL_TRAIT_LANG_ENABLE_BLOCK) if (check_block_expression_as_body(hcl, obj, cf->u._class.cmd_cnode, FOR_CLASS) <= -1) return -1;
{
if (check_block_expression_as_body(hcl, obj, cf->u._class.cmd_cnode, FOR_NONE) <= -1) return -1;
}
if (push_clsblk(hcl, &cf->u._class.start_loc, nivars, ncvars, &hcl->c->tv.s.ptr[ivar_start], ivar_len, &hcl->c->tv.s.ptr[cvar_start], cvar_len) <= -1) goto oops; if (push_clsblk(hcl, &cf->u._class.start_loc, nivars, ncvars, &hcl->c->tv.s.ptr[ivar_start], ivar_len, &hcl->c->tv.s.ptr[cvar_start], cvar_len) <= -1) goto oops;
if (push_cblk(hcl, &cf->u._class.start_loc, HCL_CBLK_TYPE_CLASS) <= -1) goto oops; /* the class block shall be treated as a control block, too */ if (push_cblk(hcl, &cf->u._class.start_loc, HCL_CBLK_TYPE_CLASS) <= -1) goto oops; /* the class block shall be treated as a control block, too */
@ -3049,34 +3042,20 @@ static int compile_lambda (hcl_t* hcl, hcl_cnode_t* src, int defun)
} }
HCL_ASSERT (hcl, nargs + nrvars == hcl->c->tv.wcount - saved_tv_wcount); HCL_ASSERT (hcl, nargs + nrvars == hcl->c->tv.wcount - saved_tv_wcount);
if (hcl->option.trait & HCL_TRAIT_LANG_ENABLE_BLOCK)
{
/*
* defun aa(a b) { ... };
* (defun aa(a b) { ... })
*
* the block expression must be the first and the only expression at the body position.
* the variable declaration can't be placed before the block expression.
* it is supported inside the block expression itself.
*/
hcl_cnode_t* blk;
blk = HCL_CNODE_CONS_CDR(obj);
if (check_block_expression_as_body(hcl, blk, cmd, FOR_NONE) <= -1) return -1;
obj = blk;
nlvars = 0; /* no known local variables until the actual block is processed */
}
else
{
obj = HCL_CNODE_CONS_CDR(obj);
tv_dup_start = hcl->c->tv.s.len;
if (collect_vardcls(hcl, obj, &obj, tv_dup_start, &nlvars, "local") <= -1) return -1;
if (nlvars > MAX_CODE_NBLKLVARS) /*
{ * defun aa(a b) { ... };
hcl_setsynerrbfmt (hcl, HCL_SYNERR_VARFLOOD, HCL_CNODE_GET_LOC(args), HCL_NULL, "too many(%zu) variables in %.*js", nlvars, HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); * (defun aa(a b) { ... })
return -1; *
} * the block expression must be the first and the only expression at the body position.
} * the variable declaration can't be placed before the block expression.
* it is supported inside the block expression itself.
*/
hcl_cnode_t* blk;
blk = HCL_CNODE_CONS_CDR(obj);
if (check_block_expression_as_body(hcl, blk, cmd, FOR_NONE) <= -1) return -1;
obj = blk;
nlvars = 0; /* no known local variables until the actual block is processed */
HCL_ASSERT (hcl, nargs + nrvars + nlvars == hcl->c->tv.wcount - saved_tv_wcount); HCL_ASSERT (hcl, nargs + nrvars + nlvars == hcl->c->tv.wcount - saved_tv_wcount);
@ -3468,10 +3447,7 @@ static int compile_try (hcl_t* hcl, hcl_cnode_t* src)
jump_inst_pos = hcl->code.bc.len; jump_inst_pos = hcl->code.bc.len;
if (emit_single_param_instruction(hcl, HCL_CODE_TRY_ENTER, MAX_CODE_JUMP, HCL_CNODE_GET_LOC(cmd)) <= -1) return -1; if (emit_single_param_instruction(hcl, HCL_CODE_TRY_ENTER, MAX_CODE_JUMP, HCL_CNODE_GET_LOC(cmd)) <= -1) return -1;
if (hcl->option.trait & HCL_TRAIT_LANG_ENABLE_BLOCK) if (check_block_expression_as_body(hcl, obj, cmd, FOR_TRY) <= -1) return -1;
{
if (check_block_expression_as_body(hcl, obj, cmd, FOR_TRY) <= -1) return -1;
}
SWITCH_TOP_CFRAME (hcl, COP_COMPILE_TRY_OBJECT_LIST, obj); /* 1*/ SWITCH_TOP_CFRAME (hcl, COP_COMPILE_TRY_OBJECT_LIST, obj); /* 1*/
PUSH_SUBCFRAME (hcl, COP_POST_TRY, cmd); /* 2 */ PUSH_SUBCFRAME (hcl, COP_POST_TRY, cmd); /* 2 */
@ -3598,10 +3574,7 @@ static HCL_INLINE int compile_catch (hcl_t* hcl)
HCL_ASSERT (hcl, fbi->tmpr_nargs + fbi->tmpr_nrvars + fbi->tmpr_nlvars == fbi->tmprcnt - par_tmprcnt); HCL_ASSERT (hcl, fbi->tmpr_nargs + fbi->tmpr_nrvars + fbi->tmpr_nlvars == fbi->tmprcnt - par_tmprcnt);
obj = HCL_CNODE_CONS_CDR(obj); obj = HCL_CNODE_CONS_CDR(obj);
if (hcl->option.trait & HCL_TRAIT_LANG_ENABLE_BLOCK) if (check_block_expression_as_body(hcl, obj, cmd, FOR_NONE) <= -1) return -1;
{
if (check_block_expression_as_body(hcl, obj, cmd, FOR_NONE) <= -1) return -1;
}
/* jump_inst_pos hold the instruction pointer that skips the catch block at the end of the try block */ /* jump_inst_pos hold the instruction pointer that skips the catch block at the end of the try block */
patch_nearest_post_try (hcl, &jump_inst_pos); patch_nearest_post_try (hcl, &jump_inst_pos);
@ -3748,10 +3721,7 @@ static int compile_while (hcl_t* hcl, hcl_cnode_t* src, int next_cop)
cond = HCL_CNODE_CONS_CAR(obj); cond = HCL_CNODE_CONS_CAR(obj);
body = HCL_CNODE_CONS_CDR(obj); body = HCL_CNODE_CONS_CDR(obj);
if (hcl->option.trait & HCL_TRAIT_LANG_ENABLE_BLOCK) if (check_block_expression_as_body(hcl, body, cmd, FOR_NONE) <= -1) return -1;
{
if (check_block_expression_as_body(hcl, body, cmd, FOR_NONE) <= -1) return -1;
}
SWITCH_TOP_CFRAME (hcl, COP_COMPILE_OBJECT, cond); /* 1 */ SWITCH_TOP_CFRAME (hcl, COP_COMPILE_OBJECT, cond); /* 1 */
@ -4661,11 +4631,6 @@ redo:
break; break;
case HCL_CONCODE_BLOCK: case HCL_CONCODE_BLOCK:
if (!(hcl->option.trait & HCL_TRAIT_LANG_ENABLE_BLOCK))
{
hcl_setsynerrbfmt (hcl, HCL_SYNERR_BLOCKBANNED, HCL_CNODE_GET_LOC(oprnd), HCL_NULL, "block expression disallowed");
return -1;
}
if (compile_cons_block_expression(hcl, oprnd) <= -1) return -1; if (compile_cons_block_expression(hcl, oprnd) <= -1) return -1;
break; break;
@ -4721,12 +4686,6 @@ redo:
return -1; return -1;
case HCL_CONCODE_BLOCK: case HCL_CONCODE_BLOCK:
if (!(hcl->option.trait & HCL_TRAIT_LANG_ENABLE_BLOCK))
{
/* this is treated the same as HCL_CNODE_CONS with CONCODE BLOCK */
hcl_setsynerrbfmt (hcl, HCL_SYNERR_BLOCKBANNED, HCL_CNODE_GET_LOC(oprnd), HCL_NULL, "block expression disallowed");
return -1;
}
if (compile_cons_block_expression(hcl, oprnd) <= -1) return -1; if (compile_cons_block_expression(hcl, oprnd) <= -1) return -1;
break; break;
@ -5176,10 +5135,7 @@ static HCL_INLINE int post_if_cond (hcl_t* hcl)
HCL_ASSERT (hcl, hcl->code.bc.len < HCL_SMOOI_MAX); HCL_ASSERT (hcl, hcl->code.bc.len < HCL_SMOOI_MAX);
body_pos = hcl->code.bc.len; body_pos = hcl->code.bc.len;
if (hcl->option.trait & HCL_TRAIT_LANG_ENABLE_BLOCK) if (check_block_expression_as_body(hcl, cf->operand, cf->u.post_if.cmd_cnode, FOR_IF) <= -1) return -1;
{
if (check_block_expression_as_body(hcl, cf->operand, cf->u.post_if.cmd_cnode, FOR_IF) <= -1) return -1;
}
SWITCH_TOP_CFRAME (hcl, COP_COMPILE_IF_OBJECT_LIST, cf->operand); /* 1 */ SWITCH_TOP_CFRAME (hcl, COP_COMPILE_IF_OBJECT_LIST, cf->operand); /* 1 */
PUSH_SUBCFRAME (hcl, COP_POST_IF_BODY, cf->operand); /* 2 */ PUSH_SUBCFRAME (hcl, COP_POST_IF_BODY, cf->operand); /* 2 */

View File

@ -236,9 +236,6 @@ enum hcl_trait_t
/* return EOL as a token */ /* TODO: make this pragma controllable */ /* return EOL as a token */ /* TODO: make this pragma controllable */
HCL_TRAIT_LANG_ENABLE_EOL = (((hcl_bitmask_t)1) << 14), HCL_TRAIT_LANG_ENABLE_EOL = (((hcl_bitmask_t)1) << 14),
/* enable block expression as mandatory argument to some expresions */
HCL_TRAIT_LANG_ENABLE_BLOCK = (((hcl_bitmask_t)1) << 15),
}; };
typedef enum hcl_trait_t hcl_trait_t; typedef enum hcl_trait_t hcl_trait_t;
@ -1566,10 +1563,7 @@ enum hcl_compile_flag_t
HCL_COMPILE_CLEAR_CODE = (1 << 0), HCL_COMPILE_CLEAR_CODE = (1 << 0),
/* clear the top-level function block at the end of hcl_compile() */ /* clear the top-level function block at the end of hcl_compile() */
HCL_COMPILE_CLEAR_FNBLK = (1 << 1), HCL_COMPILE_CLEAR_FNBLK = (1 << 1)
/* enable the block {} mode */
HCL_COMPILE_ENABLE_BLOCK = (1 << 2) /*TODO: make this #pragma controllable */
}; };
typedef enum hcl_compile_flag_t hcl_compile_flag_t; typedef enum hcl_compile_flag_t hcl_compile_flag_t;
#endif #endif

View File

@ -1522,7 +1522,6 @@ static int init_worker_hcl (hcl_server_worker_t* worker)
if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_GC) trait |= HCL_TRAIT_DEBUG_GC; if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_GC) trait |= HCL_TRAIT_DEBUG_GC;
if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_BIGINT) trait |= HCL_TRAIT_DEBUG_BIGINT; if (server->cfg.trait & HCL_SERVER_TRAIT_DEBUG_BIGINT) trait |= HCL_TRAIT_DEBUG_BIGINT;
#endif #endif
trait |= HCL_TRAIT_LANG_ENABLE_BLOCK;
trait |= HCL_TRAIT_LANG_ENABLE_EOL; trait |= HCL_TRAIT_LANG_ENABLE_EOL;
hcl_setoption (hcl, HCL_TRAIT, &trait); hcl_setoption (hcl, HCL_TRAIT, &trait);

View File

@ -80,7 +80,7 @@ func main() {
x.SetLogTarget("/dev/stderr") x.SetLogTarget("/dev/stderr")
} }
x.SetTrait(x.GetTrait() | hcl.TRAIT_LANG_ENABLE_EOL | hcl.TRAIT_LANG_ENABLE_BLOCK) x.SetTrait(x.GetTrait() | hcl.TRAIT_LANG_ENABLE_EOL)
err = x.Ignite(1000000) err = x.Ignite(1000000)
if err != nil { if err != nil {

View File

@ -16,13 +16,11 @@ type
BitMask = longword; (* this must match hcl_bitmask_t in hcl.h *) BitMask = longword; (* this must match hcl_bitmask_t in hcl.h *)
(*const (*const
TRAIT_LANG_ENABLE_EOF = (BitMask(1) shl 14); TRAIT_LANG_ENABLE_EOL = (BitMask(1) shl 14); *)
TRAIT_LANG_ENABLE_BLOCK = (BitMask(1) shl 15);*)
type type
TraitBit = ( (* this enum must follow hcl_trait_t in hcl.h *) TraitBit = ( (* this enum must follow hcl_trait_t in hcl.h *)
LANG_ENABLE_EOF = (BitMask(1) shl 14), LANG_ENABLE_EOL = (BitMask(1) shl 14)
LANG_ENABLE_BLOCK = (BitMask(1) shl 15)
); );
Option = ( (* this enum must follow hcl_option_t in hcl.h *) Option = ( (* this enum must follow hcl_option_t in hcl.h *)
@ -171,8 +169,9 @@ begin
raise Exception.Create(errmsg); raise Exception.Create(errmsg);
end; end;
if hcl_getoption(h, Option.TRAIT, @tb) <= -1 then tb := 0;
tb := BitMask(TraitBit.LANG_ENABLE_EOF) or BitMask(TraitBit.LANG_ENABLE_BLOCK); tb := tb or BitMask(TraitBit.LANG_ENABLE_EOL);
if hcl_setoption(h, Option.TRAIT, @tb) <= -1 then begin if hcl_setoption(h, Option.TRAIT, @tb) <= -1 then begin
hcl_errnum_to_errbcstr(errnum, @errmsg, length(errmsg)); hcl_errnum_to_errbcstr(errnum, @errmsg, length(errmsg));
hcl_close(h); hcl_close(h);

View File

@ -1,7 +1,7 @@
class Object { class Object {
} }
class Collection: Object { class Collection : Object {
} }
class IndexedCollection: Collection { class IndexedCollection: Collection {
@ -26,5 +26,22 @@ fun Collection:slice(index count) {
class String: Array (a b c) {
}
class String: Array (
monaco
duncan
falcon
:deuce
:canival
:pebble
:godzilla
) {
fun Collection:slice(index count) {
return (arr.slice self index count)
}
}
printf "string length %d\n" ("aaaa":length) printf "string length %d\n" ("aaaa":length)

View File

@ -32,8 +32,8 @@ TESTS = $(check_PROGRAMS) $(check_SCRIPTS) $(check_ERRORS)
TEST_EXTENSIONS = .hcl .err TEST_EXTENSIONS = .hcl .err
HCL_LOG_COMPILER = $(SHELL) $(abs_srcdir)/run.sh ../bin/hcl --modlibdirs="@abs_top_builddir@/mod:@abs_top_builddir@/mod/.libs" --heapsize=0 -b -n HCL_LOG_COMPILER = $(SHELL) $(abs_srcdir)/run.sh ../bin/hcl --modlibdirs="@abs_top_builddir@/mod:@abs_top_builddir@/mod/.libs" --heapsize=0 -n
AM_HCL_LOG_FLAGS = AM_HCL_LOG_FLAGS =
ERR_LOG_COMPILER = $(SHELL) $(abs_srcdir)/err.sh ../bin/hcl --modlibdirs="@abs_top_builddir@/mod:@abs_top_builddir@/mod/.libs" --heapsize=0 -b -n ERR_LOG_COMPILER = $(SHELL) $(abs_srcdir)/err.sh ../bin/hcl --modlibdirs="@abs_top_builddir@/mod:@abs_top_builddir@/mod/.libs" --heapsize=0 -n
AM_ERR_LOG_FLAGS = AM_ERR_LOG_FLAGS =

View File

@ -497,9 +497,9 @@ check_ERRORS = \
EXTRA_DIST = $(check_SCRIPTS) $(check_ERRORS) EXTRA_DIST = $(check_SCRIPTS) $(check_ERRORS)
TEST_EXTENSIONS = .hcl .err TEST_EXTENSIONS = .hcl .err
HCL_LOG_COMPILER = $(SHELL) $(abs_srcdir)/run.sh ../bin/hcl --modlibdirs="@abs_top_builddir@/mod:@abs_top_builddir@/mod/.libs" --heapsize=0 -b -n HCL_LOG_COMPILER = $(SHELL) $(abs_srcdir)/run.sh ../bin/hcl --modlibdirs="@abs_top_builddir@/mod:@abs_top_builddir@/mod/.libs" --heapsize=0 -n
AM_HCL_LOG_FLAGS = AM_HCL_LOG_FLAGS =
ERR_LOG_COMPILER = $(SHELL) $(abs_srcdir)/err.sh ../bin/hcl --modlibdirs="@abs_top_builddir@/mod:@abs_top_builddir@/mod/.libs" --heapsize=0 -b -n ERR_LOG_COMPILER = $(SHELL) $(abs_srcdir)/err.sh ../bin/hcl --modlibdirs="@abs_top_builddir@/mod:@abs_top_builddir@/mod/.libs" --heapsize=0 -n
AM_ERR_LOG_FLAGS = AM_ERR_LOG_FLAGS =
all: all-am all: all-am