From b7ec37325a2478493b9b717854b88291e0afb7a1 Mon Sep 17 00:00:00 2001 From: Henner Zeller
Date: Thu, 3 Oct 2019 18:12:23 -0700 Subject: [PATCH 2/2] Remove trailing whitespaces in sources. 2019-10-03 Henner Zeller * src/*.[hc]: remove trailing whitespace. --- src/ios-dev.h | 2 +- src/ios.c | 70 +++++++++++++++++------------------ src/ios.h | 16 ++++---- src/pk-cmd.c | 32 ++++++++-------- src/pk-def.c | 4 +- src/pk-file.c | 8 ++-- src/pk-misc.c | 2 +- src/pk-print.c | 2 +- src/pk-set.c | 4 +- src/pk-vm.c | 10 ++--- src/pkl-anal.c | 6 +-- src/pkl-asm.c | 64 ++++++++++++++++---------------- src/pkl-asm.h | 6 +-- src/pkl-ast.c | 96 ++++++++++++++++++++++++------------------------ src/pkl-ast.h | 18 ++++----- src/pkl-env.c | 8 ++-- src/pkl-fold.c | 6 +-- src/pkl-gen.c | 72 ++++++++++++++++++------------------ src/pkl-lex.l | 8 ++-- src/pkl-parser.c | 2 +- src/pkl-pass.c | 8 ++-- src/pkl-pass.h | 4 +- src/pkl-promo.c | 46 +++++++++++------------ src/pkl-tab.y | 32 ++++++++-------- src/pkl-trans.c | 40 ++++++++++---------- src/pkl-trans.h | 2 +- src/pkl-typify.c | 76 +++++++++++++++++++------------------- src/pkl.c | 42 ++++++++++----------- src/poke.c | 10 ++--- src/pvm-alloc.h | 2 +- src/pvm-env.c | 2 +- src/pvm-val.c | 52 +++++++++++++------------- src/pvm-val.h | 6 +-- 33 files changed, 379 insertions(+), 379 deletions(-) diff --git a/src/ios-dev.h b/src/ios-dev.h index bfc6c50..7f8579d 100644 --- a/src/ios-dev.h +++ b/src/ios-dev.h @@ -79,6 +79,6 @@ struct ios_dev_if /* Write a byte to the given device at the current position. Return the character written as an int, or IOD_EOF on error. */ - + int (*put_c) (void *dev, int c); }; diff --git a/src/ios.c b/src/ios.c index c99a35e..7c1f467 100644 --- a/src/ios.c +++ b/src/ios.c @@ -106,7 +106,7 @@ ios_open (const char *handler) goto error; io->dev_if = *dev_if; - + /* Open the device using the interface found above. */ io->dev = io->dev_if->open (handler); if (io->dev == NULL) @@ -133,7 +133,7 @@ void ios_close (ios io) { struct ios *tmp; - + /* XXX: if not saved, ask before closing. */ /* Close the device operated by the IO space. @@ -152,7 +152,7 @@ ios_close (ios io) tmp->next = io->next; } free (io); - + /* Set the new current IO. */ cur_io = io_list; } @@ -204,7 +204,7 @@ ios ios_get (int n) { ios io; - + if (n < 0) return NULL; @@ -246,18 +246,18 @@ ios_read_int (ios io, ios_off offset, int flags, c = io->dev_if->get_c (io->dev); if (c == IOD_EOF) return IOS_EIOFF; - + *value = c; break; } case 16: { int16_t c1, c2; - + c1 = io->dev_if->get_c (io->dev); if (c1 == IOD_EOF) return IOS_EIOFF; - + c2 = io->dev_if->get_c (io->dev); if (c2 == IOD_EOF) return IOS_EIOFF; @@ -272,23 +272,23 @@ ios_read_int (ios io, ios_off offset, int flags, case 32: { int32_t c1, c2, c3, c4; - + c1 = io->dev_if->get_c (io->dev); if (c1 == IOD_EOF) return IOS_EIOFF; - + c2 = io->dev_if->get_c (io->dev); if (c2 == IOD_EOF) return IOS_EIOFF; - + c3 = io->dev_if->get_c (io->dev); if (c3 == IOD_EOF) return IOS_EIOFF; - + c4 = io->dev_if->get_c (io->dev); if (c4 == IOD_EOF) return IOS_EIOFF; - + if (endian == IOS_ENDIAN_LSB) *value = (c4 << 24) | (c3 << 16) | (c2 << 8) | c1; else @@ -299,19 +299,19 @@ ios_read_int (ios io, ios_off offset, int flags, case 64: { int64_t c1, c2, c3, c4, c5, c6, c7, c8; - + c1 = io->dev_if->get_c (io->dev); if (c1 == IOD_EOF) return IOS_EIOFF; - + c2 = io->dev_if->get_c (io->dev); if (c2 == IOD_EOF) return IOS_EIOFF; - + c3 = io->dev_if->get_c (io->dev); if (c3 == IOD_EOF) return IOS_EIOFF; - + c4 = io->dev_if->get_c (io->dev); if (c4 == IOD_EOF) return IOS_EIOFF; @@ -331,7 +331,7 @@ ios_read_int (ios io, ios_off offset, int flags, c8 = io->dev_if->get_c (io->dev); if (c8 == IOD_EOF) return IOS_EIOFF; - + if (endian == IOS_ENDIAN_LSB) *value = (c8 << 56) | (c7 << 48) | (c6 << 40) | (c5 << 32) | (c4 << 24) | (c3 << 16) | (c2 << 8) | c1; else @@ -372,18 +372,18 @@ ios_read_uint (ios io, ios_off offset, int flags, c = io->dev_if->get_c (io->dev); if (c == IOD_EOF) return IOS_EIOFF; - + *value = c; break; } case 16: { int16_t c1, c2; - + c1 = io->dev_if->get_c (io->dev); if (c1 == IOD_EOF) return IOS_EIOFF; - + c2 = io->dev_if->get_c (io->dev); if (c2 == IOD_EOF) return IOS_EIOFF; @@ -398,23 +398,23 @@ ios_read_uint (ios io, ios_off offset, int flags, case 32: { int32_t c1, c2, c3, c4; - + c1 = io->dev_if->get_c (io->dev); if (c1 == IOD_EOF) return IOS_EIOFF; - + c2 = io->dev_if->get_c (io->dev); if (c2 == IOD_EOF) return IOS_EIOFF; - + c3 = io->dev_if->get_c (io->dev); if (c3 == IOD_EOF) return IOS_EIOFF; - + c4 = io->dev_if->get_c (io->dev); if (c4 == IOD_EOF) return IOS_EIOFF; - + if (endian == IOS_ENDIAN_LSB) *value = (c4 << 24) | (c3 << 16) | (c2 << 8) | c1; else @@ -425,19 +425,19 @@ ios_read_uint (ios io, ios_off offset, int flags, case 64: { int64_t c1, c2, c3, c4, c5, c6, c7, c8; - + c1 = io->dev_if->get_c (io->dev); if (c1 == IOD_EOF) return IOS_EIOFF; - + c2 = io->dev_if->get_c (io->dev); if (c2 == IOD_EOF) return IOS_EIOFF; - + c3 = io->dev_if->get_c (io->dev); if (c3 == IOD_EOF) return IOS_EIOFF; - + c4 = io->dev_if->get_c (io->dev); if (c4 == IOD_EOF) return IOS_EIOFF; @@ -457,7 +457,7 @@ ios_read_uint (ios io, ios_off offset, int flags, c8 = io->dev_if->get_c (io->dev); if (c8 == IOD_EOF) return IOS_EIOFF; - + if (endian == IOS_ENDIAN_LSB) *value = (c8 << 56) | (c7 << 48) | (c6 << 40) | (c5 << 32) | (c4 << 24) | (c3 << 16) | (c2 << 8) | c1; else @@ -499,7 +499,7 @@ ios_read_string (ios io, ios_off offset, int flags, char **value) str[i] = (char) c; } while (str[i++] != '\0'); - + *value = str; return IOS_OK; } @@ -522,7 +522,7 @@ ios_write_int (ios io, ios_off offset, int flags, case 32: { int32_t c1, c2, c3, c4; - + c1 = (value >> 24) & 0xff; c2 = (value >> 16) & 0xff; c3 = (value >> 8) & 0xff; @@ -543,7 +543,7 @@ ios_write_int (ios io, ios_off offset, int flags, if (io->dev_if->put_c (io->dev, c4) == IOD_EOF) return IOS_EIOFF; - + break; } case 64: @@ -628,7 +628,7 @@ ios_write_uint (ios io, ios_off offset, int flags, case 32: { int32_t c1, c2, c3, c4; - + c1 = (value >> 24) & 0xff; c2 = (value >> 16) & 0xff; c3 = (value >> 8) & 0xff; @@ -649,7 +649,7 @@ ios_write_uint (ios io, ios_off offset, int flags, if (io->dev_if->put_c (io->dev, c4) == IOD_EOF) return IOS_EIOFF; - + break; } case 64: diff --git a/src/ios.h b/src/ios.h index 3e68ad5..f5fdccf 100644 --- a/src/ios.h +++ b/src/ios.h @@ -35,17 +35,17 @@ void ios_shutdown (void); "IO spaces" "IO devices" Space of IO objects <=======> Space of bytes - - +------+ + + +------+ +----->| File | +-------+ | +------+ - | IO | | + | IO | | | space |<-----+ +---------+ | | +----->| Process | +-------+ | +---------+ - + : : - + | +-------------+ +----->| File system | +-------------+ @@ -97,10 +97,10 @@ typedef int64_t ios_off; there are no spaces open: space1 -> space2 -> ... -> spaceN - + ^ | - + current The functions declared below are used to manage this @@ -183,7 +183,7 @@ void ios_map (ios_map_fn cb, void *data); that reflects the state of the requested operation. The following values are supported, as well as the more generic IOS_OK and IOS_ERROR, */ - + #define IOS_EIOFF -2 /* The provided offset is invalid. This happens for example when the offset translates into a byte offset that exceeds the capacity of the diff --git a/src/pk-cmd.c b/src/pk-cmd.c index 680d5f6..8c560d8 100644 --- a/src/pk-cmd.c +++ b/src/pk-cmd.c @@ -276,7 +276,7 @@ pk_cmd_exec_1 (char *str, struct pk_trie *cmds_trie, char *prefix) if (prefix != NULL) printf ("%s ", prefix); printf (_("%s: command not found.\n"), cmd_name); - return 0; + return 0; } /* Process user flags. */ @@ -312,7 +312,7 @@ pk_cmd_exec_1 (char *str, struct pk_trie *cmds_trie, char *prefix) goto usage; return pk_cmd_exec_1 (p, *cmd->subtrie, cmd_name); } - + /* Parse arguments. */ argc = 0; a = cmd->arg_fmt; @@ -333,13 +333,13 @@ pk_cmd_exec_1 (char *str, struct pk_trie *cmds_trie, char *prefix) { if (*a == '?') a++; - + /* Try the different options, in order, until one succeeds or the next argument or the end of the input is found. */ while (*a != ',' && *a != '\0') { char *beg = p; - + switch (*a) { case 'e': @@ -365,7 +365,7 @@ pk_cmd_exec_1 (char *str, struct pk_trie *cmds_trie, char *prefix) messages, so don't bother the user with the usage message. */ besilent = 1; - + break; } case 'i': @@ -382,7 +382,7 @@ pk_cmd_exec_1 (char *str, struct pk_trie *cmds_trie, char *prefix) match = 1; } } - + break; case 'a': /* Parse an address. */ @@ -396,7 +396,7 @@ pk_cmd_exec_1 (char *str, struct pk_trie *cmds_trie, char *prefix) match = 1; } } - + break; case 't': /* Parse a #N tag. */ @@ -412,7 +412,7 @@ pk_cmd_exec_1 (char *str, struct pk_trie *cmds_trie, char *prefix) match = 1; } } - + break; case 's': { @@ -420,7 +420,7 @@ pk_cmd_exec_1 (char *str, struct pk_trie *cmds_trie, char *prefix) char *end, *str; size_t size; - + end = skip_blanks (p); while (*end != '\0' && *end != ',') end++; @@ -501,16 +501,16 @@ pk_cmd_exec_1 (char *str, struct pk_trie *cmds_trie, char *prefix) /* This should NOT happen. */ assert (0); } - + if (match) break; - + /* Rewind input and try next option. */ p = beg; a++; } } - + /* Boo, could not find valid input for this argument. */ if (!match) goto usage; @@ -565,7 +565,7 @@ pk_cmd_exec_1 (char *str, struct pk_trie *cmds_trie, char *prefix) || argv[i].type == PK_CMD_ARG_STMT) pvm_destroy_program (argv[i].val.prog); } - + return ret; usage: @@ -597,7 +597,7 @@ pk_cmd_exec (char *str) /* If the first non-blank character in STR is a dot ('.'), then this is a poke command. Dispatch it with pk_cmd_exec_1. Otherwise, compile a Poke declaration or a statement and execute it. */ - + char *cmd = skip_blanks (str); if (*cmd == '.') @@ -647,7 +647,7 @@ pk_cmd_exec (char *str) fputc ('\n', stdout); } } - + return 1; error: @@ -689,7 +689,7 @@ pk_cmd_exec_script (const char *filename) int c = fgetc (fd); assert (i < MAX_LINE); - + if (c == EOF) { line[i] = '\0'; diff --git a/src/pk-def.c b/src/pk-def.c index d487736..9330d0a 100644 --- a/src/pk-def.c +++ b/src/pk-def.c @@ -50,7 +50,7 @@ print_var_decl (pkl_ast_node decl, void *data) val = pvm_env_lookup (runtime_env, back, over); assert (val != PVM_NULL); - + /* Print the name and the current value of the variable. */ fputs (PKL_AST_IDENTIFIER_POINTER (decl_name), stdout); fputs ("\t\t", stdout); @@ -82,7 +82,7 @@ print_fun_decl (pkl_ast_node decl, void *data) if (PKL_AST_CODE (func) != PKL_AST_FUNC) return; - + assert (pkl_env_lookup (compiler_env, PKL_AST_IDENTIFIER_POINTER (decl_name), &back, &over) != NULL); diff --git a/src/pk-file.c b/src/pk-file.c index 3f6de5f..8a0667e 100644 --- a/src/pk-file.c +++ b/src/pk-file.c @@ -62,17 +62,17 @@ pk_cmd_file (int argc, struct pk_cmd_arg argv[], uint64_t uflags) printf (_("%s: file cannot be read\n"), arg_str); return 0; } - + strcpy (filename, "file://"); strcat (filename, arg_str); - + if (ios_search (filename) != NULL) { printf (_("File %s already opened. Use `file #N' to switch.\n"), filename); return 0; } - + ios_open (filename); free (filename); } @@ -121,7 +121,7 @@ pk_cmd_close (int argc, struct pk_cmd_arg argv[], uint64_t uflags) ios_handler (ios_cur ())); } } - + return 1; } diff --git a/src/pk-misc.c b/src/pk-misc.c index c0281cd..85a1b13 100644 --- a/src/pk-misc.c +++ b/src/pk-misc.c @@ -34,7 +34,7 @@ pk_cmd_exit (int argc, struct pk_cmd_arg argv[], uint64_t uflags) code = 0; else code = (int) PK_CMD_ARG_INT (argv[0]); - + if (poke_interactive_p) { /* XXX: if unsaved changes, ask and save. */ diff --git a/src/pk-print.c b/src/pk-print.c index afc76bf..da47c34 100644 --- a/src/pk-print.c +++ b/src/pk-print.c @@ -67,7 +67,7 @@ pk_cmd_print (int argc, struct pk_cmd_arg argv[], uint64_t uflags) if (uflags & PK_PRINT_F_MAP) pflags |= PVM_PRINT_F_MAPS; - + pvm_ret = pvm_run (poke_vm, prog, &val); if (pvm_ret != PVM_EXIT_OK) goto rterror; diff --git a/src/pk-set.c b/src/pk-set.c index 0364763..7dbfd02 100644 --- a/src/pk-set.c +++ b/src/pk-set.c @@ -41,7 +41,7 @@ pk_cmd_set_obase (int argc, struct pk_cmd_arg argv[], uint64_t uflags) fputs ("error: obase should be one of 2, 8, 10 or 16.\n", stdout); return 0; } - + poke_obase = base; return 1; } @@ -78,7 +78,7 @@ pk_cmd_set_endian (int argc, struct pk_cmd_arg argv[], uint64_t uflags) else { enum ios_endian endian; - + if (STREQ (arg, "little")) endian = IOS_ENDIAN_LSB; else if (STREQ (arg, "big")) diff --git a/src/pk-vm.c b/src/pk-vm.c index 67569e4..11a4550 100644 --- a/src/pk-vm.c +++ b/src/pk-vm.c @@ -32,7 +32,7 @@ pk_cmd_vm_disas_exp (int argc, struct pk_cmd_arg argv[], uint64_t uflags) /* disassemble expression EXP. */ pvm_program prog; - + assert (argc == 1); assert (PK_CMD_ARG_TYPE (argv[0]) == PK_CMD_ARG_EXP); @@ -60,10 +60,10 @@ pk_cmd_vm_disas_fun (int argc, struct pk_cmd_arg argv[], uint64_t uflags) pkl_env compiler_env = pkl_get_env (poke_compiler); pvm_env runtime_env = pvm_get_env (poke_vm); - + assert (argc == 1); assert (PK_CMD_ARG_TYPE (argv[0]) == PK_CMD_ARG_STR); - + fname = PK_CMD_ARG_STR (argv[0]); decl = pkl_env_lookup (compiler_env, fname, @@ -90,7 +90,7 @@ pk_cmd_vm_disas_fun (int argc, struct pk_cmd_arg argv[], uint64_t uflags) JITTER_OBJDUMP, NULL); else pvm_print_program (stdout, prog); - + return 1; } @@ -152,7 +152,7 @@ pk_cmd_vm_disas_writ (int argc, struct pk_cmd_arg argv[], uint64_t uflags) } program = PVM_VAL_CLS_PROGRAM (writer); - + if (uflags & PK_VM_DIS_F_NAT) pvm_disassemble_program (program, true, JITTER_OBJDUMP, NULL); diff --git a/src/pkl-anal.c b/src/pkl-anal.c index 68e7561..fce4784 100644 --- a/src/pkl-anal.c +++ b/src/pkl-anal.c @@ -64,7 +64,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_anal1_ps_struct) pkl_ast_node t; for (t = elems; t; t = PKL_AST_CHAIN (t)) - { + { pkl_ast_node ename = PKL_AST_STRUCT_FIELD_NAME (t); pkl_ast_node u; @@ -110,7 +110,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_anal1_ps_type_struct) { pkl_ast_node tname = PKL_AST_STRUCT_FIELD_TYPE_NAME (u); pkl_ast_node uname = PKL_AST_STRUCT_FIELD_TYPE_NAME (t); - + if (uname && tname && STREQ (PKL_AST_IDENTIFIER_POINTER (uname), @@ -192,7 +192,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_anal1_ps_funcall) /* If arguments are named, check that there are not arguments named twice. */ if (some_named) - { + { for (funcall_arg = PKL_AST_FUNCALL_ARGS (funcall); funcall_arg; funcall_arg = PKL_AST_CHAIN (funcall_arg)) diff --git a/src/pkl-asm.c b/src/pkl-asm.c index dbbea21..8fb2332 100644 --- a/src/pkl-asm.c +++ b/src/pkl-asm.c @@ -43,7 +43,7 @@ pkl_asm_dotimes (pasm, exp); { ... level-1 ... - + pkl_asm_if (pasm, exp); { ... level-2 ... @@ -62,7 +62,7 @@ PARENT is the parent level, i.e. the level containing this one. This is NULL at the top-level. - + The meaning of the LABEL* and NODE* fields depend on the particular kind of environment. See the details in the implementation of the functions below. */ @@ -254,7 +254,7 @@ pkl_asm_insn_atoa (pkl_asm pasm, /* Both array types are unbounded, hence they are identical => no need to do anything. */ return; - + /* No checks are due in this case, but the value itself should be typed as an unbound array. */ pkl_asm_insn (pasm, PKL_INSN_PUSH, PVM_NULL); /* ARR NULL */ @@ -322,10 +322,10 @@ pkl_asm_insn_nton (pkl_asm pasm, { size_t from_type_size = PKL_AST_TYPE_I_SIZE (from_type); int from_type_sign = PKL_AST_TYPE_I_SIGNED (from_type); - + size_t to_type_size = PKL_AST_TYPE_I_SIZE (to_type); int to_type_sign = PKL_AST_TYPE_I_SIGNED (to_type); - + if (from_type_size == to_type_size && from_type_sign == to_type_sign) { @@ -396,7 +396,7 @@ static void pkl_asm_insn_write (pkl_asm pasm) { RAS_MACRO_WRITE; -} +} /* Macro-instruction: PEEK type, endian, nenc ( -- VAL ) @@ -535,7 +535,7 @@ pkl_asm_insn_poked (pkl_asm pasm, pkl_ast_node type) Macro-instruction: ADD type ( VAL VAL -- VAL VAL VAL ) - + Macro-instruction: SUB type ( VAL VAL -- VAL VAL VAL ) @@ -547,7 +547,7 @@ pkl_asm_insn_poked (pkl_asm pasm, pkl_ast_node type) Macro-instruction: MOD type ( VAL VAL -- VAL VAL VAL ) - + Macro-instruction: BNOT type ( VAL -- VAL VAL VAL ) @@ -637,7 +637,7 @@ pkl_asm_insn_intop (pkl_asm pasm, pkl_asm_insn (pasm, div_table[tl][signed_p]); else pkl_asm_insn (pasm, mod_table[tl][signed_p]); - + break; case PKL_INSN_BNOT: pkl_asm_insn (pasm, bnot_table[tl][signed_p]); @@ -667,10 +667,10 @@ pkl_asm_insn_intop (pkl_asm pasm, Macro-instruction: NE type ( VAL VAL -- INT ) - + Macro-instruction: LT type ( VAL VAL -- INT ) - + Macro-instruction: GT type ( VAL VAL -- INT ) @@ -690,7 +690,7 @@ pkl_asm_insn_cmp (pkl_asm pasm, pkl_ast_node type) { enum pkl_asm_insn oinsn; - + /* Decide what instruction to assembly. */ if (PKL_AST_TYPE_CODE (type) == PKL_TYPE_STRING) { @@ -710,18 +710,18 @@ pkl_asm_insn_cmp (pkl_asm pasm, { static int eq_table[2][2] = {{ PKL_INSN_EQIU, PKL_INSN_EQI }, { PKL_INSN_EQLU, PKL_INSN_EQL }}; - + static int ne_table[2][2] = {{ PKL_INSN_NEIU, PKL_INSN_NEI }, { PKL_INSN_NELU, PKL_INSN_NEL }}; static int lt_table[2][2] = {{ PKL_INSN_LTIU, PKL_INSN_LTI }, { PKL_INSN_LTLU, PKL_INSN_LTL }}; - + static int gt_table[2][2] = {{ PKL_INSN_GTIU, PKL_INSN_GTI }, { PKL_INSN_GTLU, PKL_INSN_GTL }}; - + static int ge_table[2][2] = {{ PKL_INSN_GEIU, PKL_INSN_GEI }, { PKL_INSN_GELU, PKL_INSN_GEL }}; - + static int le_table[2][2] = {{ PKL_INSN_LEIU, PKL_INSN_LEI }, { PKL_INSN_LELU, PKL_INSN_LEL }}; @@ -772,7 +772,7 @@ pkl_asm_insn_gcd (pkl_asm pasm, pkl_ast_node type) { RAS_MACRO_GCD (type); } - + /* Macro-instruction: ADDO base_type ( OFF OFF -- OFF OFF OFF ) @@ -931,7 +931,7 @@ pkl_asm_new (pkl_ast ast, pkl_compiler compiler, pasm->pointers = pvm_alloc (sizeof (void*) * PKL_AST_MAX_POINTERS); memset (pasm->pointers, 0, PKL_AST_MAX_POINTERS); pasm->next_pointer = 0; - + if (prologue) { /* Standard prologue. */ @@ -972,7 +972,7 @@ pkl_asm_finish (pkl_asm pasm, int epilogue, void **pointers) /* Successful program finalization. */ pkl_asm_insn (pasm, PKL_INSN_POPE); pkl_asm_insn (pasm, PKL_INSN_PUSH, pvm_make_int (PVM_EXIT_OK, 32)); - pkl_asm_insn (pasm, PKL_INSN_EXIT); + pkl_asm_insn (pasm, PKL_INSN_EXIT); pvm_append_label (pasm->program, pasm->error_label); @@ -993,17 +993,17 @@ pkl_asm_finish (pkl_asm pasm, int epilogue, void **pointers) /* Set the exit status to ERROR and exit the PVM. */ pkl_asm_insn (pasm, PKL_INSN_PUSH, pvm_make_int (PVM_EXIT_ERROR, 32)); - pkl_asm_insn (pasm, PKL_INSN_EXIT); + pkl_asm_insn (pasm, PKL_INSN_EXIT); pkl_asm_note (pasm, "#end epilogue"); - } + } if (pointers != NULL) *pointers = pasm->pointers; /* Free the first level. */ pkl_asm_poplevel (pasm); - + /* Free the assembler instance and return the assembled program to the user. */ free (pasm); @@ -1029,7 +1029,7 @@ pkl_asm_insn (pkl_asm pasm, enum pkl_asm_insn insn, ...) #define PKL_DEF_INSN(SYM, ARGS, NAME) ARGS, # include "pkl-insn.def" #undef PKL_DEF_INSN - }; + }; va_list valist; @@ -1066,7 +1066,7 @@ pkl_asm_insn (pkl_asm pasm, enum pkl_asm_insn insn, ...) for (p = insn_args[insn]; *p != '\0'; ++p) { char arg_class = *p; - + switch (arg_class) { case 'v': @@ -1412,7 +1412,7 @@ pkl_asm_endif (pkl_asm pasm) { assert (pasm->level->current_env == PKL_ASM_ENV_CONDITIONAL); pvm_append_label (pasm->program, pasm->level->label2); - + /* Cleanup and pop the current level. */ pkl_ast_node_free (pasm->level->node1); pkl_asm_poplevel (pasm); @@ -1459,14 +1459,14 @@ pkl_asm_catch (pkl_asm pasm) /* XXX pkl_asm_note (pasm, "POP-REGISTERS"); */ pkl_asm_insn (pasm, PKL_INSN_BA, pasm->level->label2); pvm_append_label (pasm->program, pasm->level->label1); - + /* At this point the exception number is at the top of the stack. If the catch block received an argument, push a new environment and set it as a local. Otherwise, just discard it. */ - + if (pasm->level->node1) { - pkl_asm_insn (pasm, PKL_INSN_PUSHF); + pkl_asm_insn (pasm, PKL_INSN_PUSHF); pkl_asm_insn (pasm, PKL_INSN_REGVAR); } else @@ -1501,7 +1501,7 @@ pkl_asm_endtry (pkl_asm pasm) label2: POP the condition expression break_label: - + Thus, loops use two labels. */ void @@ -1533,7 +1533,7 @@ pkl_asm_endloop (pkl_asm pasm) pkl_asm_insn (pasm, PKL_INSN_DROP); pvm_append_label (pasm->program, pasm->level->break_label); - + /* Cleanup and pop the current level. */ pkl_asm_poplevel (pasm); } @@ -1552,7 +1552,7 @@ pkl_asm_endloop (pkl_asm pasm) REGVAR ; CONTAINER SEL ; CONTAINER NELEMS PUSH 0UL ; CONTAINER NELEMS 0 - SWAP ; CONTAINER 0 NELEMS + SWAP ; CONTAINER 0 NELEMS PUSH NULL ; CONTAINER 0 NELEMS NULL label2: DROP ; CONTAINER I NELEMS @@ -1690,7 +1690,7 @@ pkl_asm_call (pkl_asm pasm, const char *funcname) { pkl_env compiler_env = pkl_get_env (pasm->compiler); int back, over; - + assert (pkl_env_lookup (compiler_env, funcname, &back, &over) != NULL); diff --git a/src/pkl-asm.h b/src/pkl-asm.h index 4b0c455..5e1e687 100644 --- a/src/pkl-asm.h +++ b/src/pkl-asm.h @@ -116,13 +116,13 @@ void pkl_asm_endif (pkl_asm pasm); /* While loops. * * pkl_asm_while (pasm); - * + * * ... condition ... * * pkl_asm_loop (pasm); * * ... loop body ... - * + * * pkl_asm_end_loop (pasm); */ @@ -157,7 +157,7 @@ void pkl_asm_for_endloop (pkl_asm pasm); /* Try-catch blocks. * * pkl_asm_try (pasm); - * + * * ... stmt ... * * pkl_asm_catch (pasm); diff --git a/src/pkl-ast.c b/src/pkl-ast.c index 7595ed4..30aa804 100644 --- a/src/pkl-ast.c +++ b/src/pkl-ast.c @@ -41,7 +41,7 @@ pkl_ast_default_endian (void) /* Allocate and return a new AST node, with the given CODE. The rest of the node is initialized to zero. */ - + static pkl_ast_node pkl_ast_make_node (pkl_ast ast, enum pkl_ast_code code) @@ -80,7 +80,7 @@ pkl_ast_chainon (pkl_ast_node ast1, pkl_ast_node ast2) /* Build and return an AST node for an integer constant. */ -pkl_ast_node +pkl_ast_node pkl_ast_make_integer (pkl_ast ast, uint64_t value) { @@ -88,13 +88,13 @@ pkl_ast_make_integer (pkl_ast ast, PKL_AST_INTEGER_VALUE (new) = value; PKL_AST_LITERAL_P (new) = 1; - + return new; } /* Build and return an AST node for a string constant. */ -pkl_ast_node +pkl_ast_node pkl_ast_make_string (pkl_ast ast, const char *str) { @@ -125,7 +125,7 @@ pkl_ast_make_identifier (pkl_ast ast, /* Build and return an AST node for an enumerator. */ -pkl_ast_node +pkl_ast_node pkl_ast_make_enumerator (pkl_ast ast, pkl_ast_node identifier, pkl_ast_node value) @@ -160,7 +160,7 @@ pkl_ast_make_cond_exp (pkl_ast ast, PKL_AST_LITERAL_P (cond_exp) = PKL_AST_LITERAL_P (thenexp) && PKL_AST_LITERAL_P (elseexp); - + return cond_exp; } @@ -219,7 +219,7 @@ pkl_ast_make_unary_exp (pkl_ast ast, PKL_AST_EXP_NUMOPS (exp) = 1; PKL_AST_EXP_OPERAND (exp, 0) = ASTREF (op); PKL_AST_LITERAL_P (exp) = PKL_AST_LITERAL_P (op); - + return exp; } @@ -311,7 +311,7 @@ pkl_ast_make_struct_ref (pkl_ast ast, PKL_AST_STRUCT_REF_STRUCT (sref) = ASTREF (sct); PKL_AST_STRUCT_REF_IDENTIFIER (sref) = ASTREF (identifier); - + return sref; } @@ -515,10 +515,10 @@ pkl_ast_node pkl_ast_dup_type (pkl_ast_node type) { pkl_ast_node t, new = pkl_ast_make_type (PKL_AST_AST (type)); - + PKL_AST_TYPE_CODE (new) = PKL_AST_TYPE_CODE (type); PKL_AST_TYPE_COMPLETE (new) = PKL_AST_TYPE_COMPLETE (type); - + switch (PKL_AST_TYPE_CODE (type)) { case PKL_TYPE_ANY: @@ -647,7 +647,7 @@ pkl_ast_type_equal (pkl_ast_node a, pkl_ast_node b) return 0; } } - + return pkl_ast_type_equal (PKL_AST_TYPE_A_ETYPE (a), PKL_AST_TYPE_A_ETYPE (b)); break; @@ -680,7 +680,7 @@ pkl_ast_type_equal (pkl_ast_node a, pkl_ast_node b) if (PKL_AST_FUNC_TYPE_ARG_VARARG (fa) != PKL_AST_FUNC_TYPE_ARG_VARARG (fb)) return 0; - + if (!pkl_ast_type_equal (PKL_AST_FUNC_TYPE_ARG_TYPE (fa), PKL_AST_FUNC_TYPE_ARG_TYPE (fb))) return 0; @@ -834,7 +834,7 @@ int pkl_ast_type_is_complete (pkl_ast_node type) { int complete = PKL_AST_TYPE_COMPLETE_UNKNOWN; - + switch (PKL_AST_TYPE_CODE (type)) { /* Integral, offset and struct types are always complete. */ @@ -920,7 +920,7 @@ pkl_print_type (FILE *out, pkl_ast_node type, int use_given_name) case PKL_TYPE_ARRAY: { pkl_ast_node bound = PKL_AST_TYPE_A_BOUND (type); - + pkl_print_type (out, PKL_AST_TYPE_A_ETYPE (type), use_given_name); fputc ('[', out); @@ -968,7 +968,7 @@ pkl_print_type (FILE *out, pkl_ast_node type, int use_given_name) if (PKL_AST_TYPE_F_NARG (type) > 0) { fputc ('(', out); - + for (t = PKL_AST_TYPE_F_ARGS (type); t; t = PKL_AST_CHAIN (t)) { @@ -986,7 +986,7 @@ pkl_print_type (FILE *out, pkl_ast_node type, int use_given_name) fputc ('?', out); } } - + fputc (')', out); } @@ -1013,7 +1013,7 @@ pkl_print_type (FILE *out, pkl_ast_node type, int use_given_name) fprintf (out, "%" PRIu64, PKL_AST_INTEGER_VALUE (unit)); else assert (0); - + fputc ('>', out); break; } @@ -1168,7 +1168,7 @@ pkl_ast_make_offset (pkl_ast ast, pkl_ast_node offset = pkl_ast_make_node (ast, PKL_AST_OFFSET); assert (unit); - + if (magnitude != NULL) PKL_AST_OFFSET_MAGNITUDE (offset) = ASTREF (magnitude); PKL_AST_OFFSET_UNIT (offset) = ASTREF (unit); @@ -1414,7 +1414,7 @@ pkl_ast_make_loop_stmt (pkl_ast ast, pkl_ast_node condition, PKL_AST_LOOP_STMT_ITERATOR (loop_stmt) = ASTREF (iterator); if (container) PKL_AST_LOOP_STMT_CONTAINER (loop_stmt) = ASTREF (container); - + PKL_AST_LOOP_STMT_BODY (loop_stmt) = ASTREF (body); return loop_stmt; @@ -1565,7 +1565,7 @@ pkl_ast_node_free (pkl_ast_node ast) { pkl_ast_node t, n; size_t i; - + if (ast == NULL) return; @@ -1586,7 +1586,7 @@ pkl_ast_node_free (pkl_ast_node ast) n = PKL_AST_CHAIN (t); pkl_ast_node_free (t); } - + break; case PKL_AST_EXP: @@ -1595,18 +1595,18 @@ pkl_ast_node_free (pkl_ast_node ast) pkl_ast_node_free (PKL_AST_EXP_OPERAND (ast, i)); break; - + case PKL_AST_COND_EXP: pkl_ast_node_free (PKL_AST_COND_EXP_COND (ast)); pkl_ast_node_free (PKL_AST_COND_EXP_THENEXP (ast)); pkl_ast_node_free (PKL_AST_COND_EXP_ELSEEXP (ast)); break; - + case PKL_AST_ENUM: pkl_ast_node_free (PKL_AST_ENUM_TAG (ast)); - + for (t = PKL_AST_ENUM_VALUES (ast); t; t = n) { n = PKL_AST_CHAIN (t); @@ -1614,13 +1614,13 @@ pkl_ast_node_free (pkl_ast_node ast) } break; - + case PKL_AST_ENUMERATOR: pkl_ast_node_free (PKL_AST_ENUMERATOR_IDENTIFIER (ast)); pkl_ast_node_free (PKL_AST_ENUMERATOR_VALUE (ast)); break; - + case PKL_AST_TYPE: free (PKL_AST_TYPE_NAME (ast)); @@ -1665,7 +1665,7 @@ pkl_ast_node_free (pkl_ast_node ast) default: break; } - + break; case PKL_AST_STRUCT_FIELD_TYPE: @@ -1681,7 +1681,7 @@ pkl_ast_node_free (pkl_ast_node ast) pkl_ast_node_free (PKL_AST_FUNC_TYPE_ARG_TYPE (ast)); pkl_ast_node_free (PKL_AST_FUNC_TYPE_ARG_NAME (ast)); break; - + case PKL_AST_INDEXER: pkl_ast_node_free (PKL_AST_INDEXER_ENTITY (ast)); @@ -1714,23 +1714,23 @@ pkl_ast_node_free (pkl_ast_node ast) pkl_ast_node_free (PKL_AST_FUNC_ARG_IDENTIFIER (ast)); pkl_ast_node_free (PKL_AST_FUNC_ARG_INITIAL (ast)); break; - + case PKL_AST_STRING: free (PKL_AST_STRING_POINTER (ast)); break; - + case PKL_AST_IDENTIFIER: free (PKL_AST_IDENTIFIER_POINTER (ast)); break; - + case PKL_AST_STRUCT_REF: pkl_ast_node_free (PKL_AST_STRUCT_REF_STRUCT (ast)); pkl_ast_node_free (PKL_AST_STRUCT_REF_IDENTIFIER (ast)); break; - + case PKL_AST_STRUCT_FIELD: pkl_ast_node_free (PKL_AST_STRUCT_FIELD_NAME (ast)); @@ -1745,7 +1745,7 @@ pkl_ast_node_free (pkl_ast_node ast) pkl_ast_node_free (t); } break; - + case PKL_AST_ARRAY_INITIALIZER: pkl_ast_node_free (PKL_AST_ARRAY_INITIALIZER_INDEX (ast)); @@ -1759,7 +1759,7 @@ pkl_ast_node_free (pkl_ast_node ast) n = PKL_AST_CHAIN (t); pkl_ast_node_free (t); } - + break; case PKL_AST_DECL: @@ -1786,7 +1786,7 @@ pkl_ast_node_free (pkl_ast_node ast) pkl_ast_node_free (PKL_AST_ISA_TYPE (ast)); pkl_ast_node_free (PKL_AST_ISA_EXP (ast)); break; - + case PKL_AST_MAP: pkl_ast_node_free (PKL_AST_MAP_TYPE (ast)); @@ -1807,7 +1807,7 @@ pkl_ast_node_free (pkl_ast_node ast) n = PKL_AST_CHAIN (t); pkl_ast_node_free (t); } - + break; case PKL_AST_FUNCALL_ARG: @@ -1897,7 +1897,7 @@ pkl_ast_node_free (pkl_ast_node ast) case PKL_AST_BREAK_STMT: break; - + case PKL_AST_RAISE_STMT: pkl_ast_node_free (PKL_AST_RAISE_STMT_EXP (ast)); @@ -1909,7 +1909,7 @@ pkl_ast_node_free (pkl_ast_node ast) case PKL_AST_INTEGER: /* Fallthrough. */ break; - + default: assert (0); } @@ -1939,7 +1939,7 @@ pkl_ast_free (pkl_ast ast) { if (ast == NULL) return; - + pkl_ast_node_free (ast->ast); free (ast->buffer); free (ast->filename); @@ -2204,7 +2204,7 @@ pkl_ast_print_1 (FILE *fd, pkl_ast_node ast, int indent) { pkl_ast_node child; size_t i; - + if (ast == NULL) { IPRINTF ("NULL::\n"); @@ -2223,7 +2223,7 @@ pkl_ast_print_1 (FILE *fd, pkl_ast_node ast, int indent) PKL_AST_LOC (ast).last_column); \ } \ while (0) - + switch (PKL_AST_CODE (ast)) { case PKL_AST_PROGRAM: @@ -2314,7 +2314,7 @@ pkl_ast_print_1 (FILE *fd, pkl_ast_node ast, int indent) IPRINTF ("elems:\n"); PRINT_AST_SUBAST_CHAIN (STRUCT_FIELDS); break; - + case PKL_AST_ARRAY_INITIALIZER: IPRINTF ("ARRAY_INITIALIZER::\n"); @@ -2410,7 +2410,7 @@ pkl_ast_print_1 (FILE *fd, pkl_ast_node ast, int indent) case PKL_AST_STRUCT_FIELD_TYPE: IPRINTF ("STRUCT_FIELD_TYPE::\n"); - PRINT_COMMON_FIELDS; + PRINT_COMMON_FIELDS; PRINT_AST_SUBAST (name, STRUCT_FIELD_TYPE_NAME); PRINT_AST_SUBAST (type, STRUCT_FIELD_TYPE_TYPE); PRINT_AST_SUBAST (exp, STRUCT_FIELD_TYPE_CONSTRAINT); @@ -2425,7 +2425,7 @@ pkl_ast_print_1 (FILE *fd, pkl_ast_node ast, int indent) PRINT_AST_SUBAST (type, FUNC_TYPE_ARG_NAME); PRINT_AST_IMM (optional, FUNC_TYPE_ARG_OPTIONAL, "%d"); break; - + case PKL_AST_TRIMMER: IPRINTF ("TRIMMER::\n"); PRINT_AST_SUBAST (from, TRIMMER_FROM); @@ -2460,7 +2460,7 @@ pkl_ast_print_1 (FILE *fd, pkl_ast_node ast, int indent) PRINT_AST_SUBAST (identifier, FUNC_ARG_IDENTIFIER); PRINT_AST_IMM (vararg, FUNC_ARG_VARARG, "%d"); break; - + case PKL_AST_STRUCT_REF: IPRINTF ("STRUCT_REF::\n"); @@ -2551,7 +2551,7 @@ pkl_ast_print_1 (FILE *fd, pkl_ast_node ast, int indent) PRINT_AST_IMM (back, VAR_BACK, "%d"); PRINT_AST_IMM (over, VAR_OVER, "%d"); break; - + case PKL_AST_COMP_STMT: IPRINTF ("COMP_STMT::\n"); @@ -2644,10 +2644,10 @@ pkl_ast_print_1 (FILE *fd, pkl_ast_node ast, int indent) case PKL_AST_NULL_STMT: IPRINTF ("NULL_STMT::\n"); - + PRINT_COMMON_FIELDS; break; - + default: IPRINTF ("UNKNOWN:: code=%d\n", PKL_AST_CODE (ast)); break; diff --git a/src/pkl-ast.h b/src/pkl-ast.h index 1f0558e..3aa323b 100644 --- a/src/pkl-ast.h +++ b/src/pkl-ast.h @@ -282,7 +282,7 @@ pkl_ast_node pkl_ast_make_program (pkl_ast ast, pkl_ast_node declarations); /* PKL_AST_IDENTIFIER nodes represent identifiers in PKL programs. - + POINTER must point to a NULL-terminated string. LENGTH contains the size in bytes of the identifier @@ -432,7 +432,7 @@ pkl_ast_node pkl_ast_make_struct_field (pkl_ast ast, The supported operators are specified in pkl-ops.def. The supported attributes are defined in pkl-attrs.def. - + In PKL_AST_OP_ATTR exprssions, ATTR contains the code for the invoked attribute. @@ -628,7 +628,7 @@ pkl_ast_node pkl_ast_make_func_arg (pkl_ast ast, pkl_ast_node init); /* PKL_AST_TRIMMER nodes represent a trim of an array, or a string. - + ENTITY is either an array or a string, which is the subject of the trim. @@ -705,7 +705,7 @@ pkl_ast_node pkl_ast_make_struct_ref (pkl_ast ast, element has no name. TYPE is a PKL_AST_TYPE node. - + CONSTRAINT is a constraint associated with the struct field. It is an expression that should evaluate to a boolean. @@ -764,7 +764,7 @@ pkl_ast_node pkl_ast_make_func_type_arg (pkl_ast ast, pkl_ast_node type, pkl_ast_node name); /* PKL_AST_TYPE nodes represent type expressions. - + If NAME is not NULL, then this specific type instance has a given name, which is encoded in a PKL_AST_IDENTIFIER node. @@ -841,7 +841,7 @@ struct pkl_ast_type union pkl_ast_node *name; enum pkl_ast_type_code code; int complete; - + union { struct @@ -883,7 +883,7 @@ struct pkl_ast_type union pkl_ast_node *args; union pkl_ast_node *first_opt_arg; } fun; - + } val; }; @@ -993,7 +993,7 @@ pkl_ast_node pkl_ast_id_to_offset_unit (pkl_ast ast, pkl_ast_node id); /* PKL_AST_CAST nodes represent casts at the language level. - + TYPE is the target type in the case. EXP is the expression whole value should be casted to the targe type. */ @@ -1361,7 +1361,7 @@ pkl_ast_node pkl_ast_make_exp_stmt (pkl_ast ast, pkl_ast_node exp); TYPE, if specified, is the argument to the catch clause. The type of the argument must be a signed 32-bit type, which is the type used to denote exception types. - + EXP, if specified, is an expression evaluating to a 32-bit integer. Exceptions having any other type won't be catched by the `catch' clause of the statement. diff --git a/src/pkl-env.c b/src/pkl-env.c index 0e4072f..7a315e5 100644 --- a/src/pkl-env.c +++ b/src/pkl-env.c @@ -43,7 +43,7 @@ struct pkl_env int num_types; int num_vars; - + struct pkl_env *up; }; @@ -109,7 +109,7 @@ register_decl (pkl_hash hash_table, pkl_ast_node decl) { int hash; - + if (get_registered (hash_table, name) != NULL) /* Already registered. */ return 0; @@ -239,7 +239,7 @@ pkl_env_map_decls (pkl_env env, for (i = 0; i < HASH_TABLE_SIZE; ++i) { pkl_ast_node t = env->hash_table[i]; - + for (; t; t = PKL_AST_CHAIN2 (t)) { if ((what == PKL_AST_DECL_KIND_ANY @@ -274,6 +274,6 @@ pkl_env_dup_toplevel (pkl_env env) new->num_types = env->num_types; new->num_vars = env->num_vars; - + return new; } diff --git a/src/pkl-fold.c b/src/pkl-fold.c index 2a16f18..684723f 100644 --- a/src/pkl-fold.c +++ b/src/pkl-fold.c @@ -39,7 +39,7 @@ The letter-codes after EMUL_ specify the number and kind of arguments that the operations receive and return. The type of the returned value comes last. - + So, for example, EMUL_III declares an int64 OP int64 -> int64 operation, whereas EMUL_SSI declares a string OP string -> int64 operation. */ @@ -553,7 +553,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_fold_div) && PKL_AST_INTEGER_VALUE (magnitude) == 0) goto divbyzero; } - + OP_BINARY_III (div); OP_BINARY_OOI (divo); @@ -584,7 +584,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_fold_mod) && PKL_AST_INTEGER_VALUE (magnitude) == 0) goto divbyzero; } - + OP_BINARY_III (mod); OP_BINARY_OOO (modo); diff --git a/src/pkl-gen.c b/src/pkl-gen.c index 9a15ec8..d42d6ba 100644 --- a/src/pkl-gen.c +++ b/src/pkl-gen.c @@ -46,7 +46,7 @@ PKL_GEN_PAYLOAD->ASM[++(PKL_GEN_PAYLOAD->cur_##ASM)] = (new_pasm); \ } \ while (0) - + #define PKL_GEN_PUSH_ASM(new_pasm) PKL_GEN_PUSH_AN_ASM(pasm,new_pasm) #define PKL_GEN_PUSH_ASM2(new_pasm) PKL_GEN_PUSH_AN_ASM(pasm2,new_pasm) @@ -100,7 +100,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_ps_program) && PKL_AST_PROGRAM_ELEMS (PKL_PASS_NODE) && PKL_AST_CODE (PKL_AST_PROGRAM_ELEMS (PKL_PASS_NODE)) == PKL_AST_EXP_STMT)) pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, PVM_NULL); - + PKL_GEN_PAYLOAD->program = pkl_asm_finish (PKL_GEN_ASM, 1 /* prologue */, &PKL_GEN_PAYLOAD->pointers); @@ -127,21 +127,21 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_decl) pvm_val mapper_closure; pvm_val writer_closure; pvm_val constructor_closure; - + pkl_ast_node type_struct = initial; pkl_ast_node type_struct_fields = PKL_AST_TYPE_S_ELEMS (type_struct); pkl_ast_node field; - + /* Compile the struct closures and complete them using the current environment. */ - + PKL_GEN_PAYLOAD->in_writer = 1; RAS_FUNCTION_STRUCT_WRITER (writer_closure); pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, writer_closure); /* CLS */ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PEC); /* CLS */ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_DROP); /* _ */ PKL_GEN_PAYLOAD->in_writer = 0; - + PKL_GEN_PAYLOAD->in_mapper = 1; RAS_FUNCTION_STRUCT_MAPPER (mapper_closure); pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, mapper_closure); /* CLS */ @@ -169,9 +169,9 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_decl) { pvm_val mapper_closure; pvm_val writer_closure; - + pkl_ast_node array_type = initial; - + /* Compile the arrays closures and complete them using the current environment. */ @@ -181,7 +181,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_decl) pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PEC); /* CLS */ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_DROP); /* _ */ PKL_GEN_PAYLOAD->in_writer = 0; - + PKL_GEN_PAYLOAD->in_mapper = 1; RAS_FUNCTION_ARRAY_MAPPER (mapper_closure); pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, mapper_closure); /* CLS */ @@ -334,7 +334,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_comp_stmt) if (PKL_AST_COMP_STMT_BUILTIN (comp_stmt) == PKL_AST_BUILTIN_NONE) /* Push a frame into the environment. */ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSHF); - + } PKL_PHASE_END_HANDLER @@ -407,7 +407,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_ass_stmt) case PKL_AST_STRUCT_REF: { jitter_label label = pkl_asm_fresh_label (PKL_GEN_ASM); - + valmapper = PVM_NULL; /* XXX PKL_AST_TYPE_S_VALMAPPER (lvalue_type) */ /* We need to get the value (array element, or struct field) @@ -428,7 +428,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_ass_stmt) pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSHR, 0); /* LVALUE IDX VAL EXP */ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_SWAP); /* LVALUE IDX EXP VAL */ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_MGETM); /* LVALUE IDX EXP VAL MCLS */ - pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_BN, label); /* LVALUE IDX EXP VAL MCLS */ + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_BN, label); /* LVALUE IDX EXP VAL MCLS */ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_DROP); /* LVALUE IDX EXP VAL */ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_MGETO); /* LVALUE IDX EXP VAL OFFSET */ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_NROT); /* LVALUE IDX OFFSET EXP VAL */ @@ -460,7 +460,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_ass_stmt) default: break; } - + /* All right, now assign the resulting rvalue to the lvalue. */ switch (PKL_AST_CODE (lvalue)) { @@ -604,7 +604,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_loop_stmt) else if (iterator && container) { pkl_ast_node container_type = PKL_AST_TYPE (container); - + /* This is a FOR-IN[-WHERE] loop. */ pkl_asm_for (PKL_GEN_ASM, PKL_AST_TYPE_CODE (container_type), @@ -671,7 +671,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_ps_return_stmt) if (PKL_AST_TYPE_CODE (PKL_AST_TYPE_F_RTYPE (function_type)) == PKL_TYPE_VOID) pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, PVM_NULL); - + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_RETURN); } PKL_PHASE_END_HANDLER @@ -715,7 +715,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_print_stmt) pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, pvm_make_string (prefix)); pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PRINTS); } - + for (arg = print_stmt_args; arg; arg = PKL_AST_CHAIN (arg)) { /* Print the argument, and the optional suffix. */ @@ -785,7 +785,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_try_catch_stmt) PKL_PASS_SUBPASS (catch_exp); else pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, pvm_make_int (0, 32)); - + pkl_asm_try (PKL_GEN_ASM, catch_arg); { PKL_PASS_SUBPASS (code); @@ -826,7 +826,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_funcall) int vararg = PKL_AST_TYPE_F_VARARG (function_type); int i, aindex = 0, vararg_actual = 0, optionals_specified = 0; pkl_ast_node aa; - + /* Push the actuals to the stack. */ for (aa = PKL_AST_FUNCALL_ARGS (funcall); aa; aa = PKL_AST_CHAIN (aa)) { @@ -854,7 +854,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_funcall) else PKL_PASS_SUBPASS (aa); } - + if (vararg) { if (aindex == 0) @@ -862,12 +862,12 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_funcall) pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, PVM_NULL); /* Array offset. */ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, pvm_make_any_type ()); } - + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, pvm_make_ulong (aindex, 64)); pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_DUP); pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_MKA); } - + /* Complete non-specified actuals for formals having default values. For these, we should push nulls. But beware the vararg! */ { @@ -942,7 +942,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_func) { PKL_GEN_PAYLOAD->in_array_bounder = 1; PKL_PASS_SUBPASS (rtype); - PKL_GEN_PAYLOAD->in_array_bounder = 0; + PKL_GEN_PAYLOAD->in_array_bounder = 0; } } } @@ -998,7 +998,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_func_arg) pkl_asm_insn (pasm, PKL_INSN_ATOA, NULL /* from_type */, func_arg_type); } - + pkl_asm_label (PKL_GEN_ASM, after_conv_label); /* Pop the actual argument from the stack and put it in the current @@ -1036,7 +1036,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_ps_func) pvm_make_int (PVM_E_NO_RETURN, 32)); pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_RAISE); } - + /* Pop the function's argument environment, if any, and return. */ if (PKL_AST_FUNC_ARGS (function)) pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_POPF, 1); @@ -1077,7 +1077,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_ps_integer) else val = pvm_make_uint (value, size); } - + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, val); } PKL_PHASE_END_HANDLER @@ -1356,7 +1356,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_map) pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_RAISE); pkl_asm_label (PKL_GEN_ASM, label); } - + PKL_PASS_BREAK; } PKL_PHASE_END_HANDLER @@ -1761,7 +1761,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_type_array) RAS_FUNCTION_ARRAY_MAPPER (mapper_closure); PKL_GEN_PAYLOAD->in_mapper = 0; PKL_GEN_PAYLOAD->in_valmapper = 1; - + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, mapper_closure); /* VAL OFF CLS */ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PEC); /* VAL OFF CLS */ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_NIP); /* VAL CLS */ @@ -1842,7 +1842,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_type_array) else { pvm_val writer_closure; - + /* Compile a writer function to a closure. */ RAS_FUNCTION_ARRAY_WRITER (writer_closure); @@ -1864,7 +1864,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_type_array) if (PKL_AST_TYPE_CODE (etype) == PKL_TYPE_ARRAY) PKL_PASS_SUBPASS (etype); - + RAS_FUNCTION_ARRAY_BOUNDER (bounder_closure); pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, bounder_closure); /* CLS */ pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PEC); /* CLS */ @@ -2084,7 +2084,7 @@ PKL_PHASE_END_HANDLER PKL_PHASE_BEGIN_HANDLER (pkl_gen_ps_type_struct) { /* We are generating a PVM struct type. */ - + pkl_ast_node struct_type = PKL_PASS_NODE; pkl_ast_node type_name = PKL_AST_TYPE_NAME (struct_type); @@ -2095,7 +2095,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_ps_type_struct) pvm_make_string (PKL_AST_IDENTIFIER_POINTER (type_name))); else pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSH, PVM_NULL); - + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_MKTYSCT); } PKL_PHASE_END_HANDLER @@ -2130,12 +2130,12 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_pr_struct_field_type) PKL_PASS_SUBPASS (PKL_AST_STRUCT_FIELD_TYPE_NAME (PKL_PASS_NODE)); PKL_PASS_SUBPASS (PKL_AST_STRUCT_FIELD_TYPE_TYPE (PKL_PASS_NODE)); } - + PKL_PASS_BREAK; } PKL_PHASE_END_HANDLER -/* +/* * Expression handlers. * * | OPERAND1 @@ -2216,7 +2216,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_ps_op_mul) pkl_asm_insn (pasm, PKL_INSN_NIP2); break; case PKL_TYPE_OFFSET: - { + { pkl_ast_node op1 = PKL_AST_EXP_OPERAND (node, 0); pkl_ast_node op2 = PKL_AST_EXP_OPERAND (node, 1); pkl_ast_node op1_type = PKL_AST_TYPE (op1); @@ -2329,7 +2329,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_ps_op_intexp) assert (0); break; } - + switch (PKL_AST_TYPE_CODE (type)) { case PKL_TYPE_INTEGRAL: @@ -2496,7 +2496,7 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_ps_op_attr) case PKL_TYPE_STRUCT: { jitter_label label = pkl_asm_fresh_label (PKL_GEN_ASM); - + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_MGETO); pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_NIP); pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_BNN, label); diff --git a/src/pkl-lex.l b/src/pkl-lex.l index 31d0dc1..91b612e 100644 --- a/src/pkl-lex.l +++ b/src/pkl-lex.l @@ -139,7 +139,7 @@ D [0-9] {NEWLINE} { /* Ignore newlines. */ } {BLANK} { /* Ignore whitespace. */ } -"/*" { BEGIN(C_COMMENT); } +"/*" { BEGIN(C_COMMENT); }