[svn:parrot] r42918 - in trunk: compilers/imcc compilers/pirc/src config/auto/env config/auto/readline config/gen/platform/ansi config/gen/platform/generic config/gen/platform/win32 examples/benchmarks examples/c examples/compilers include/parrot
fperrad at svn.parrot.org
fperrad at svn.parrot.org
Sun Dec 6 15:03:33 UTC 2009
Author: fperrad
Date: Sun Dec 6 15:03:28 2009
New Revision: 42918
URL: https://trac.parrot.org/parrot/changeset/42918
Log:
[cage] improve C indentation, see TT #1329
Modified:
trunk/compilers/imcc/cfg.c
trunk/compilers/imcc/imcc.y
trunk/compilers/imcc/instructions.c
trunk/compilers/imcc/main.c
trunk/compilers/imcc/optimizer.c
trunk/compilers/imcc/parser_util.c
trunk/compilers/imcc/pbc.c
trunk/compilers/imcc/pcc.c
trunk/compilers/imcc/sets.h
trunk/compilers/imcc/symreg.c
trunk/compilers/pirc/src/bcgen.c
trunk/compilers/pirc/src/pircapi.c
trunk/compilers/pirc/src/piremit.c
trunk/compilers/pirc/src/pirmacro.c
trunk/compilers/pirc/src/pirop.c
trunk/compilers/pirc/src/pirpcc.c
trunk/compilers/pirc/src/pirregalloc.c
trunk/config/auto/env/test_unsetenv_c.in
trunk/config/auto/readline/readline_c.in
trunk/config/gen/platform/ansi/exec.c
trunk/config/gen/platform/generic/stat.c
trunk/config/gen/platform/win32/env.c
trunk/config/gen/platform/win32/stat.c
trunk/examples/benchmarks/primes.c
trunk/examples/benchmarks/primes2.c
trunk/examples/c/test_main.c
trunk/examples/compilers/japhc.c
trunk/include/parrot/exceptions.h
trunk/include/parrot/multidispatch.h
trunk/include/parrot/sub.h
Modified: trunk/compilers/imcc/cfg.c
==============================================================================
--- trunk/compilers/imcc/cfg.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/imcc/cfg.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -1500,10 +1500,10 @@
void
search_predecessors_not_in(ARGIN(const Basic_block *node), ARGMOD(Set *s))
{
- ASSERT_ARGS(search_predecessors_not_in)
- Edge *edge;
+ ASSERT_ARGS(search_predecessors_not_in)
+ Edge *edge;
- for (edge = node->pred_list; edge; edge = edge->pred_next) {
+ for (edge = node->pred_list; edge; edge = edge->pred_next) {
Basic_block * const pred = edge->from;
if (!set_contains(s, pred->index)) {
@@ -1511,7 +1511,7 @@
pred->loop_depth++;
search_predecessors_not_in(pred, s);
}
- }
+ }
}
/*** Utility functions ***/
Modified: trunk/compilers/imcc/imcc.y
==============================================================================
--- trunk/compilers/imcc/imcc.y Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/imcc/imcc.y Sun Dec 6 15:03:28 2009 (r42918)
@@ -452,18 +452,18 @@
}
switch (type_enum) {
- case enum_class_Sub:
- case enum_class_Coroutine:
- rhs = mk_const(interp, name, 'p');
-
- if (!ascii)
- rhs->type |= VT_ENCODED;
-
- rhs->usage |= U_FIXUP | U_SUBID_LOOKUP;
- break;
- default:
- rhs = mk_const(interp, name, 'P');
- break;
+ case enum_class_Sub:
+ case enum_class_Coroutine:
+ rhs = mk_const(interp, name, 'p');
+
+ if (!ascii)
+ rhs->type |= VT_ENCODED;
+
+ rhs->usage |= U_FIXUP | U_SUBID_LOOKUP;
+ break;
+ default:
+ rhs = mk_const(interp, name, 'P');
+ break;
}
r[1] = rhs;
Modified: trunk/compilers/imcc/instructions.c
==============================================================================
--- trunk/compilers/imcc/instructions.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/imcc/instructions.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -747,34 +747,34 @@
}
switch (ins->opsize-1) {
- case -1: /* labels */
- case 1:
- len = Parrot_io_fprintf(interp, io, ins->format, regstr[0]);
- break;
- case 2:
- len = Parrot_io_fprintf(interp, io, ins->format, regstr[0], regstr[1]);
- break;
- case 3:
- len = Parrot_io_fprintf(interp, io, ins->format, regstr[0], regstr[1], regstr[2]);
- break;
- case 4:
- len = Parrot_io_fprintf(interp, io, ins->format, regstr[0], regstr[1], regstr[2],
+ case -1: /* labels */
+ case 1:
+ len = Parrot_io_fprintf(interp, io, ins->format, regstr[0]);
+ break;
+ case 2:
+ len = Parrot_io_fprintf(interp, io, ins->format, regstr[0], regstr[1]);
+ break;
+ case 3:
+ len = Parrot_io_fprintf(interp, io, ins->format, regstr[0], regstr[1], regstr[2]);
+ break;
+ case 4:
+ len = Parrot_io_fprintf(interp, io, ins->format, regstr[0], regstr[1], regstr[2],
regstr[3]);
- break;
- case 5:
- len = Parrot_io_fprintf(interp, io, ins->format, regstr[0], regstr[1], regstr[2],
+ break;
+ case 5:
+ len = Parrot_io_fprintf(interp, io, ins->format, regstr[0], regstr[1], regstr[2],
regstr[3], regstr[4]);
- break;
- case 6:
- len = Parrot_io_fprintf(interp, io, ins->format, regstr[0], regstr[1], regstr[2],
+ break;
+ case 6:
+ len = Parrot_io_fprintf(interp, io, ins->format, regstr[0], regstr[1], regstr[2],
regstr[3], regstr[4], regstr[5]);
- break;
- default:
- Parrot_io_fprintf(interp, Parrot_io_STDERR(interp),
+ break;
+ default:
+ Parrot_io_fprintf(interp, Parrot_io_STDERR(interp),
"unhandled: opsize (%d), op %s, fmt %s\n",
ins->opsize, ins->opname, ins->format);
- exit(EXIT_FAILURE);
- break;
+ exit(EXIT_FAILURE);
+ break;
}
return len;
Modified: trunk/compilers/imcc/main.c
==============================================================================
--- trunk/compilers/imcc/main.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/imcc/main.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -369,167 +369,167 @@
while ((status = longopt_get(interp, *argc, (const char **)*argv, options,
&opt)) > 0) {
switch (opt.opt_id) {
- case 'R':
- if (STREQ(opt.opt_arg, "slow") || STREQ(opt.opt_arg, "bounds"))
- core = PARROT_SLOW_CORE;
- else if (STREQ(opt.opt_arg, "fast") || STREQ(opt.opt_arg, "function"))
- core = PARROT_FAST_CORE;
- else if (STREQ(opt.opt_arg, "switch"))
- core = PARROT_SWITCH_CORE;
- else if (STREQ(opt.opt_arg, "cgp"))
- core = PARROT_CGP_CORE;
- else if (STREQ(opt.opt_arg, "cgoto"))
- core = PARROT_CGOTO_CORE;
- else if (STREQ(opt.opt_arg, "jit"))
- core = PARROT_FAST_CORE;
- else if (STREQ(opt.opt_arg, "cgp-jit"))
- core = PARROT_CGP_CORE;
- else if (STREQ(opt.opt_arg, "switch-jit"))
- core = PARROT_SWITCH_CORE;
- else if (STREQ(opt.opt_arg, "exec"))
- core = PARROT_EXEC_CORE;
- else if (STREQ(opt.opt_arg, "trace"))
- core = PARROT_SLOW_CORE;
- else if (STREQ(opt.opt_arg, "profiling"))
- core = PARROT_PROFILING_CORE;
- else if (STREQ(opt.opt_arg, "gcdebug"))
- core = PARROT_GC_DEBUG_CORE;
- else
- Parrot_ex_throw_from_c_args(interp, NULL, 1,
+ case 'R':
+ if (STREQ(opt.opt_arg, "slow") || STREQ(opt.opt_arg, "bounds"))
+ core = PARROT_SLOW_CORE;
+ else if (STREQ(opt.opt_arg, "fast") || STREQ(opt.opt_arg, "function"))
+ core = PARROT_FAST_CORE;
+ else if (STREQ(opt.opt_arg, "switch"))
+ core = PARROT_SWITCH_CORE;
+ else if (STREQ(opt.opt_arg, "cgp"))
+ core = PARROT_CGP_CORE;
+ else if (STREQ(opt.opt_arg, "cgoto"))
+ core = PARROT_CGOTO_CORE;
+ else if (STREQ(opt.opt_arg, "jit"))
+ core = PARROT_FAST_CORE;
+ else if (STREQ(opt.opt_arg, "cgp-jit"))
+ core = PARROT_CGP_CORE;
+ else if (STREQ(opt.opt_arg, "switch-jit"))
+ core = PARROT_SWITCH_CORE;
+ else if (STREQ(opt.opt_arg, "exec"))
+ core = PARROT_EXEC_CORE;
+ else if (STREQ(opt.opt_arg, "trace"))
+ core = PARROT_SLOW_CORE;
+ else if (STREQ(opt.opt_arg, "profiling"))
+ core = PARROT_PROFILING_CORE;
+ else if (STREQ(opt.opt_arg, "gcdebug"))
+ core = PARROT_GC_DEBUG_CORE;
+ else
+ Parrot_ex_throw_from_c_args(interp, NULL, 1,
"main: Unrecognized runcore '%s' specified."
"\n\nhelp: parrot -h\n", opt.opt_arg);
- break;
- case 't':
- if (opt.opt_arg && is_all_hex_digits(opt.opt_arg))
- SET_TRACE(strtoul(opt.opt_arg, NULL, 16));
- else
- SET_TRACE(PARROT_TRACE_OPS_FLAG);
- break;
- case 'd':
- if (opt.opt_arg && is_all_hex_digits(opt.opt_arg)) {
- IMCC_INFO(interp)->debug = strtoul(opt.opt_arg, NULL, 16);
- }
- else {
- IMCC_INFO(interp)->debug++;
- }
- break;
- case 'D':
- if (opt.opt_arg && is_all_hex_digits(opt.opt_arg)) {
- SET_DEBUG(strtoul(opt.opt_arg, NULL, 16));
- }
- else
- SET_DEBUG(PARROT_MEM_STAT_DEBUG_FLAG);
- break;
- case 'w':
- Parrot_setwarnings(interp, PARROT_WARNINGS_ALL_FLAG);
- IMCC_INFO(interp)->imcc_warn = 1;
- break;
- case 'G':
- IMCC_INFO(interp)->gc_off = 1;
- break;
- case '.': /* Give Windows Parrot hackers an opportunity to
- * attach a debuggger. */
- fgetc(stdin);
- break;
- case 'a':
- SET_STATE_PASM_FILE(interp);
- break;
- case 'h':
- help();
- exit(EX_USAGE);
- break;
- case OPT_HELP_DEBUG:
- help_debug();
- exit(EX_USAGE);
- break;
- case OPT_RUNTIME_PREFIX:
- Parrot_io_printf(interp, "%Ss\n",
+ break;
+ case 't':
+ if (opt.opt_arg && is_all_hex_digits(opt.opt_arg))
+ SET_TRACE(strtoul(opt.opt_arg, NULL, 16));
+ else
+ SET_TRACE(PARROT_TRACE_OPS_FLAG);
+ break;
+ case 'd':
+ if (opt.opt_arg && is_all_hex_digits(opt.opt_arg)) {
+ IMCC_INFO(interp)->debug = strtoul(opt.opt_arg, NULL, 16);
+ }
+ else {
+ IMCC_INFO(interp)->debug++;
+ }
+ break;
+ case 'D':
+ if (opt.opt_arg && is_all_hex_digits(opt.opt_arg)) {
+ SET_DEBUG(strtoul(opt.opt_arg, NULL, 16));
+ }
+ else
+ SET_DEBUG(PARROT_MEM_STAT_DEBUG_FLAG);
+ break;
+ case 'w':
+ Parrot_setwarnings(interp, PARROT_WARNINGS_ALL_FLAG);
+ IMCC_INFO(interp)->imcc_warn = 1;
+ break;
+ case 'G':
+ IMCC_INFO(interp)->gc_off = 1;
+ break;
+ case '.': /* Give Windows Parrot hackers an opportunity to
+ * attach a debuggger. */
+ fgetc(stdin);
+ break;
+ case 'a':
+ SET_STATE_PASM_FILE(interp);
+ break;
+ case 'h':
+ help();
+ exit(EX_USAGE);
+ break;
+ case OPT_HELP_DEBUG:
+ help_debug();
+ exit(EX_USAGE);
+ break;
+ case OPT_RUNTIME_PREFIX:
+ Parrot_io_printf(interp, "%Ss\n",
Parrot_get_runtime_path(interp));
- exit(EXIT_SUCCESS);
- case 'V':
- Parrot_version(interp);
- break;
- case 'r':
- if (STATE_RUN_PBC(interp))
- SET_STATE_RUN_FROM_FILE(interp);
- SET_STATE_RUN_PBC(interp);
- break;
- case 'c':
- SET_STATE_LOAD_PBC(interp);
- break;
- case 'v':
- IMCC_INFO(interp)->verbose++;
- break;
- case 'y':
- yydebug = 1;
- break;
- case 'E':
- SET_STATE_PRE_PROCESS(interp);
- break;
- case 'o':
- UNSET_STATE_RUN_PBC(interp);
- interp->output_file = opt.opt_arg;
- break;
+ exit(EXIT_SUCCESS);
+ case 'V':
+ Parrot_version(interp);
+ break;
+ case 'r':
+ if (STATE_RUN_PBC(interp))
+ SET_STATE_RUN_FROM_FILE(interp);
+ SET_STATE_RUN_PBC(interp);
+ break;
+ case 'c':
+ SET_STATE_LOAD_PBC(interp);
+ break;
+ case 'v':
+ IMCC_INFO(interp)->verbose++;
+ break;
+ case 'y':
+ yydebug = 1;
+ break;
+ case 'E':
+ SET_STATE_PRE_PROCESS(interp);
+ break;
+ case 'o':
+ UNSET_STATE_RUN_PBC(interp);
+ interp->output_file = opt.opt_arg;
+ break;
- case OPT_PBC_OUTPUT:
- UNSET_STATE_RUN_PBC(interp);
- SET_STATE_WRITE_PBC(interp);
- if (!interp->output_file)
- interp->output_file = "-";
+ case OPT_PBC_OUTPUT:
+ UNSET_STATE_RUN_PBC(interp);
+ SET_STATE_WRITE_PBC(interp);
+ if (!interp->output_file)
+ interp->output_file = "-";
+ break;
+
+ case 'O':
+ if (!opt.opt_arg) {
+ IMCC_INFO(interp)->optimizer_level |= OPT_PRE;
break;
-
- case 'O':
- if (!opt.opt_arg) {
- IMCC_INFO(interp)->optimizer_level |= OPT_PRE;
- break;
- }
- if (strchr(opt.opt_arg, 'p'))
- IMCC_INFO(interp)->optimizer_level |= OPT_PASM;
- if (strchr(opt.opt_arg, 'c'))
- IMCC_INFO(interp)->optimizer_level |= OPT_SUB;
-
- IMCC_INFO(interp)->allocator = IMCC_GRAPH_ALLOCATOR;
- /* currently not ok due to different register allocation */
- if (strchr(opt.opt_arg, '1')) {
- IMCC_INFO(interp)->optimizer_level |= OPT_PRE;
- }
- if (strchr(opt.opt_arg, '2')) {
- IMCC_INFO(interp)->optimizer_level |= (OPT_PRE | OPT_CFG);
- }
- if (strchr(opt.opt_arg, 't')) {
+ }
+ if (strchr(opt.opt_arg, 'p'))
+ IMCC_INFO(interp)->optimizer_level |= OPT_PASM;
+ if (strchr(opt.opt_arg, 'c'))
+ IMCC_INFO(interp)->optimizer_level |= OPT_SUB;
+
+ IMCC_INFO(interp)->allocator = IMCC_GRAPH_ALLOCATOR;
+ /* currently not ok due to different register allocation */
+ if (strchr(opt.opt_arg, '1')) {
+ IMCC_INFO(interp)->optimizer_level |= OPT_PRE;
+ }
+ if (strchr(opt.opt_arg, '2')) {
+ IMCC_INFO(interp)->optimizer_level |= (OPT_PRE | OPT_CFG);
+ }
+ if (strchr(opt.opt_arg, 't')) {
#ifdef HAVE_COMPUTED_GOTO
- core = PARROT_CGP_CORE;
+ core = PARROT_CGP_CORE;
#else
- core = PARROT_SWITCH_CORE;
+ core = PARROT_SWITCH_CORE;
#endif
- }
- break;
+ }
+ break;
- case OPT_GC_DEBUG:
+ case OPT_GC_DEBUG:
#if DISABLE_GC_DEBUG
- Parrot_warn(interp, PARROT_WARNINGS_ALL_FLAG,
+ Parrot_warn(interp, PARROT_WARNINGS_ALL_FLAG,
"PARROT_GC_DEBUG is set but the binary was "
"compiled with DISABLE_GC_DEBUG.");
#endif
- SET_FLAG(PARROT_GC_DEBUG_FLAG);
- break;
- case OPT_DESTROY_FLAG:
- SET_FLAG(PARROT_DESTROY_FLAG);
- break;
- case 'I':
- Parrot_lib_add_path_from_cstring(interp, opt.opt_arg,
+ SET_FLAG(PARROT_GC_DEBUG_FLAG);
+ break;
+ case OPT_DESTROY_FLAG:
+ SET_FLAG(PARROT_DESTROY_FLAG);
+ break;
+ case 'I':
+ Parrot_lib_add_path_from_cstring(interp, opt.opt_arg,
PARROT_LIB_PATH_INCLUDE);
- break;
- case 'L':
- Parrot_lib_add_path_from_cstring(interp, opt.opt_arg,
+ break;
+ case 'L':
+ Parrot_lib_add_path_from_cstring(interp, opt.opt_arg,
PARROT_LIB_PATH_LIBRARY);
- break;
- case 'X':
- Parrot_lib_add_path_from_cstring(interp, opt.opt_arg,
+ break;
+ case 'X':
+ Parrot_lib_add_path_from_cstring(interp, opt.opt_arg,
PARROT_LIB_PATH_DYNEXT);
- break;
- default:
- Parrot_ex_throw_from_c_args(interp, NULL, 1,
+ break;
+ default:
+ Parrot_ex_throw_from_c_args(interp, NULL, 1,
"main: Invalid flag '%s' used.\n\nhelp: parrot -h\n",
(*argv)[0]);
}
Modified: trunk/compilers/imcc/optimizer.c
==============================================================================
--- trunk/compilers/imcc/optimizer.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/imcc/optimizer.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -694,7 +694,7 @@
ins2, i);
old = ins2->symregs[i];
ins2->symregs[i] = c;
- /* first we try subst_constants for e.g. if 10 < 5 goto next*/
+ /* first we try subst_constants for e.g. if 10 < 5 goto next*/
tmp = IMCC_subst_constants(interp,
unit, ins2->opname, ins2->symregs, ins2->opsize,
&found);
@@ -810,38 +810,38 @@
eval[0] = opnum;
for (i = 0; i < op_info->op_count - 1; i++) {
switch (op_info->types[i]) {
- case PARROT_ARG_IC:
- PARROT_ASSERT(i && ops == (unsigned int)i);
- /* set branch offset to zero */
- eval[i + 1] = 0;
- break;
- case PARROT_ARG_I:
- case PARROT_ARG_N:
- case PARROT_ARG_S:
- eval[i + 1] = i; /* regs used are I0, I1, I2 */
- if (ops <= 2 || i) { /* fill source regs */
- switch (r[i]->set) {
- case 'I':
- REG_INT(interp, i) = IMCC_int_from_reg(interp, r[i]);
- break;
- case 'N':
- {
- STRING * const s = Parrot_str_new(interp, r[i]->name, 0);
- REG_NUM(interp, i) = Parrot_str_to_num(interp, s);
- }
- break;
- case 'S':
- REG_STR(interp, i) = IMCC_string_from_reg(interp, r[i]);
- break;
- default:
- break;
+ case PARROT_ARG_IC:
+ PARROT_ASSERT(i && ops == (unsigned int)i);
+ /* set branch offset to zero */
+ eval[i + 1] = 0;
+ break;
+ case PARROT_ARG_I:
+ case PARROT_ARG_N:
+ case PARROT_ARG_S:
+ eval[i + 1] = i; /* regs used are I0, I1, I2 */
+ if (ops <= 2 || i) { /* fill source regs */
+ switch (r[i]->set) {
+ case 'I':
+ REG_INT(interp, i) = IMCC_int_from_reg(interp, r[i]);
+ break;
+ case 'N':
+ {
+ STRING * const s = Parrot_str_new(interp, r[i]->name, 0);
+ REG_NUM(interp, i) = Parrot_str_to_num(interp, s);
}
+ break;
+ case 'S':
+ REG_STR(interp, i) = IMCC_string_from_reg(interp, r[i]);
+ break;
+ default:
+ break;
}
- break;
- default:
- IMCC_fatal(interp, 1, "eval_ins"
- "invalid arg #%d for op '%s' not found\n",
- i, op);
+ }
+ break;
+ default:
+ IMCC_fatal(interp, 1, "eval_ins"
+ "invalid arg #%d for op '%s' not found\n",
+ i, op);
}
}
@@ -1037,27 +1037,27 @@
*/
char b[128];
switch (r[0]->set) {
- case 'I':
- snprintf(b, sizeof (b), INTVAL_FMT, REG_INT(interp, 0));
- r[1] = mk_const(interp, b, r[0]->set);
- break;
- case 'N':
- snprintf(b, sizeof (b), fmt, REG_NUM(interp, 0));
- r[1] = mk_const(interp, b, r[0]->set);
- break;
- case 'S':
- {
- char * const name = Parrot_str_to_cstring(interp, REG_STR(interp, 0));
+ case 'I':
+ snprintf(b, sizeof (b), INTVAL_FMT, REG_INT(interp, 0));
+ r[1] = mk_const(interp, b, r[0]->set);
+ break;
+ case 'N':
+ snprintf(b, sizeof (b), fmt, REG_NUM(interp, 0));
+ r[1] = mk_const(interp, b, r[0]->set);
+ break;
+ case 'S':
+ {
+ char * const name = Parrot_str_to_cstring(interp, REG_STR(interp, 0));
- r[1] = mk_const(interp, name, r[0]->set);
+ r[1] = mk_const(interp, name, r[0]->set);
- snprintf(b, sizeof (b), "%p", REG_STR(interp, 0));
- Parrot_str_free_cstring(name);
+ snprintf(b, sizeof (b), "%p", REG_STR(interp, 0));
+ Parrot_str_free_cstring(name);
- break;
- }
- default:
- break;
+ break;
+ }
+ default:
+ break;
}
tmp = INS(interp, unit, "set", "", r, 2, 0, 0);
}
Modified: trunk/compilers/imcc/parser_util.c
==============================================================================
--- trunk/compilers/imcc/parser_util.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/imcc/parser_util.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -465,19 +465,19 @@
/* XXX Speed up some by keep track of the end of format ourselves */
for (i = 0; i < n; i++) {
switch (op_info->dirs[i]) {
- case PARROT_ARGDIR_INOUT:
- dirs |= 1 << (16 + i);
- /* go on */
- case PARROT_ARGDIR_IN:
- dirs |= 1 << i ;
- break;
-
- case PARROT_ARGDIR_OUT:
- dirs |= 1 << (16 + i);
- break;
+ case PARROT_ARGDIR_INOUT:
+ dirs |= 1 << (16 + i);
+ /* go on */
+ case PARROT_ARGDIR_IN:
+ dirs |= 1 << i ;
+ break;
+
+ case PARROT_ARGDIR_OUT:
+ dirs |= 1 << (16 + i);
+ break;
- default:
- PARROT_ASSERT(0);
+ default:
+ PARROT_ASSERT(0);
};
if (keyvec & KEY_BIT(i)) {
Modified: trunk/compilers/imcc/pbc.c
==============================================================================
--- trunk/compilers/imcc/pbc.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/imcc/pbc.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -1344,15 +1344,15 @@
if (ns_const >= 0 && ns_const < ct->const_count) {
switch (ct->constants[ns_const]->type) {
- case PFC_KEY:
- ns_pmc = ct->constants[ns_const]->u.key;
- break;
- case PFC_STRING:
- ns_pmc = constant_pmc_new(interp, enum_class_String);
- VTABLE_set_string_native(interp, ns_pmc, ct->constants[ns_const]->u.string);
- break;
- default:
- break;
+ case PFC_KEY:
+ ns_pmc = ct->constants[ns_const]->u.key;
+ break;
+ case PFC_STRING:
+ ns_pmc = constant_pmc_new(interp, enum_class_String);
+ VTABLE_set_string_native(interp, ns_pmc, ct->constants[ns_const]->u.string);
+ break;
+ default:
+ break;
}
}
@@ -1555,61 +1555,61 @@
r = r->reg;
switch (type) {
- case VTIDENTIFIER: /* P[S0] */
- case VTPASM: /* P[S0] */
- case VTREG: /* P[S0] */
- if (r->set == 'I')
- *pc++ = PARROT_ARG_I; /* register type */
- else if (r->set == 'S')
- *pc++ = PARROT_ARG_S;
- else
- IMCC_fatal(interp, 1, "build_key: wrong register set\n");
-
- /* don't emit mapped regs in key parts */
- if (r->color < 0)
- *pc++ = -1 - r->color;
- else
- *pc++ = r->color;
+ case VTIDENTIFIER: /* P[S0] */
+ case VTPASM: /* P[S0] */
+ case VTREG: /* P[S0] */
+ if (r->set == 'I')
+ *pc++ = PARROT_ARG_I; /* register type */
+ else if (r->set == 'S')
+ *pc++ = PARROT_ARG_S;
+ else
+ IMCC_fatal(interp, 1, "build_key: wrong register set\n");
+
+ /* don't emit mapped regs in key parts */
+ if (r->color < 0)
+ *pc++ = -1 - r->color;
+ else
+ *pc++ = r->color;
+
+ sprintf(s+strlen(s), "%c%d", r->set, (int)r->color);
+
+ IMCC_debug(interp, DEBUG_PBC_CONST,
+ " keypart reg %s %c%d\n",
+ r->name, r->set, (int)r->color);
+ break;
+ case VT_CONSTP:
+ case VTCONST:
+ case VTCONST|VT_ENCODED:
+ switch (r->set) {
+ case 'S': /* P["key"] */
+ /* str constant */
+ *pc++ = PARROT_ARG_SC;
- sprintf(s+strlen(s), "%c%d", r->set, (int)r->color);
+ /* constant idx */
+ *pc++ = r->color;
IMCC_debug(interp, DEBUG_PBC_CONST,
- " keypart reg %s %c%d\n",
- r->name, r->set, (int)r->color);
+ " keypart SC %s #%d\n",
+ r->name, r->color);
break;
- case VT_CONSTP:
- case VTCONST:
- case VTCONST|VT_ENCODED:
- switch (r->set) {
- case 'S': /* P["key"] */
- /* str constant */
- *pc++ = PARROT_ARG_SC;
-
- /* constant idx */
- *pc++ = r->color;
-
- IMCC_debug(interp, DEBUG_PBC_CONST,
- " keypart SC %s #%d\n",
- r->name, r->color);
- break;
- case 'I': /* P[;42;..] */
- /* int constant */
- *pc++ = PARROT_ARG_IC;
-
- /* value */
- *pc++ = r->color = atol(r->name);
-
- IMCC_debug(interp, DEBUG_PBC_CONST,
- " keypart IC %s #%d\n",
- r->name, r->color);
- break;
- default:
- IMCC_fatal(interp, 1, "build_key: unknown set\n");
- }
- sprintf(s+strlen(s), "%cc" INTVAL_FMT, r->set, r->color);
+ case 'I': /* P[;42;..] */
+ /* int constant */
+ *pc++ = PARROT_ARG_IC;
+
+ /* value */
+ *pc++ = r->color = atol(r->name);
+
+ IMCC_debug(interp, DEBUG_PBC_CONST,
+ " keypart IC %s #%d\n",
+ r->name, r->color);
break;
- default:
- IMCC_fatal(interp, 1, "build_key: "
+ default:
+ IMCC_fatal(interp, 1, "build_key: unknown set\n");
+ }
+ sprintf(s+strlen(s), "%cc" INTVAL_FMT, r->set, r->color);
+ break;
+ default:
+ IMCC_fatal(interp, 1, "build_key: "
"unknown type 0x%x on %s\n", type, r->name);
}
}
@@ -1735,35 +1735,39 @@
for (i = l, n = 0; i; --i, ++chr) {
switch (*chr) {
- case ' ': continue;
- case '\t': continue;
- case '(': continue;
- case ')': break;
- case ',':
- n++;
- break;
- default:
- base = 10;
- if (*chr == '0') {
- ++chr;
- --i;
- if (*chr == 'b' || *chr == 'B') {
- base = 2;
- ++chr;
- --i;
- }
- else if (*chr == 'x' || *chr == 'X') {
- base = 16;
- ++chr;
- --i;
- }
- }
- start = chr;
- elem = strtoul(chr, &chr, base);
- --chr;
- i -= (chr - start);
- VTABLE_set_integer_keyed_int(interp, p, n, elem);
- break;
+ case ' ':
+ continue;
+ case '\t':
+ continue;
+ case '(':
+ continue;
+ case ')':
+ break;
+ case ',':
+ n++;
+ break;
+ default:
+ base = 10;
+ if (*chr == '0') {
+ ++chr;
+ --i;
+ if (*chr == 'b' || *chr == 'B') {
+ base = 2;
+ ++chr;
+ --i;
+ }
+ else if (*chr == 'x' || *chr == 'X') {
+ base = 16;
+ ++chr;
+ --i;
+ }
+ }
+ start = chr;
+ elem = strtoul(chr, &chr, base);
+ --chr;
+ i -= (chr - start);
+ VTABLE_set_integer_keyed_int(interp, p, n, elem);
+ break;
}
}
@@ -1848,34 +1852,34 @@
return;
switch (r->set) {
- case 'I':
- r->color = IMCC_int_from_reg(interp, r);
- break;
- case 'S':
- if (r->type & VT_CONSTP)
- r = r->reg;
- r->color = add_const_str(interp, r);
- break;
- case 'N':
- r->color = add_const_num(interp, r->name);
- break;
- case 'K':
- {
+ case 'I':
+ r->color = IMCC_int_from_reg(interp, r);
+ break;
+ case 'S':
+ if (r->type & VT_CONSTP)
+ r = r->reg;
+ r->color = add_const_str(interp, r);
+ break;
+ case 'N':
+ r->color = add_const_num(interp, r->name);
+ break;
+ case 'K':
+ {
SymReg *key = r;
for (r = r->nextkey; r; r = r->nextkey)
if (r->type & VTCONST)
add_1_const(interp, r);
build_key(interp, key);
- }
- break;
- case 'P':
- make_pmc_const(interp, r);
- IMCC_debug(interp, DEBUG_PBC_CONST,
+ }
+ break;
+ case 'P':
+ make_pmc_const(interp, r);
+ IMCC_debug(interp, DEBUG_PBC_CONST,
"PMC const %s\tcolor %d\n", r->name, r->color);
- break;
- default:
- break;
+ break;
+ default:
+ break;
}
if (r)
@@ -2217,18 +2221,18 @@
/* Add annotation. */
switch (ins->symregs[1]->set) {
- case 'I':
- annotation_type = PF_ANNOTATION_KEY_TYPE_INT;
- break;
- case 'N':
- annotation_type = PF_ANNOTATION_KEY_TYPE_NUM;
- break;
- case 'S':
- annotation_type = PF_ANNOTATION_KEY_TYPE_STR;
- break;
- default:
- IMCC_fatal(interp, 1, "e_pbc_emit:"
- "invalid type for annotation value\n");
+ case 'I':
+ annotation_type = PF_ANNOTATION_KEY_TYPE_INT;
+ break;
+ case 'N':
+ annotation_type = PF_ANNOTATION_KEY_TYPE_NUM;
+ break;
+ case 'S':
+ annotation_type = PF_ANNOTATION_KEY_TYPE_STR;
+ break;
+ default:
+ IMCC_fatal(interp, 1, "e_pbc_emit:"
+ "invalid type for annotation value\n");
}
PackFile_Annotations_add_entry(interp, interp->code->annotations,
IMCC_INFO(interp)->pc - interp->code->base.data,
@@ -2276,52 +2280,52 @@
for (i = 0; i < op_info->op_count-1; i++) {
switch (op_info->types[i]) {
- case PARROT_ARG_IC:
- /* branch instruction */
- if (op_info->labels[i]) {
- if (last_label == 1)
- /* we don't have a branch with offset 1 !? */
- IMCC_fatal(interp, 1, "e_pbc_emit: "
+ case PARROT_ARG_IC:
+ /* branch instruction */
+ if (op_info->labels[i]) {
+ if (last_label == 1)
+ /* we don't have a branch with offset 1 !? */
+ IMCC_fatal(interp, 1, "e_pbc_emit: "
"no label offset found\n");
- *(IMCC_INFO(interp)->pc)++ = last_label;
- last_label = 1;
- break;
- /* else fall through */
- }
- case PARROT_ARG_I:
- case PARROT_ARG_N:
- case PARROT_ARG_S:
- case PARROT_ARG_P:
- case PARROT_ARG_K:
- case PARROT_ARG_KI:
- case PARROT_ARG_KIC:
- case PARROT_ARG_SC:
- case PARROT_ARG_NC:
- case PARROT_ARG_PC:
- r = ins->symregs[i];
+ *(IMCC_INFO(interp)->pc)++ = last_label;
+ last_label = 1;
+ break;
+ /* else fall through */
+ }
+ case PARROT_ARG_I:
+ case PARROT_ARG_N:
+ case PARROT_ARG_S:
+ case PARROT_ARG_P:
+ case PARROT_ARG_K:
+ case PARROT_ARG_KI:
+ case PARROT_ARG_KIC:
+ case PARROT_ARG_SC:
+ case PARROT_ARG_NC:
+ case PARROT_ARG_PC:
+ r = ins->symregs[i];
- if (r->type & VT_CONSTP)
- r = r->reg;
+ if (r->type & VT_CONSTP)
+ r = r->reg;
- *(IMCC_INFO(interp)->pc)++ = (opcode_t) r->color;
- IMCC_debug(interp, DEBUG_PBC, " %d", r->color);
- break;
- case PARROT_ARG_KC:
- r = ins->symregs[i];
- if (r->set == 'K') {
- PARROT_ASSERT(r->color >= 0);
- *(IMCC_INFO(interp)->pc)++ = r->color;
- }
- else {
- *(IMCC_INFO(interp)->pc)++ = build_key(interp, r);
- }
- IMCC_debug(interp, DEBUG_PBC, " %d",
+ *(IMCC_INFO(interp)->pc)++ = (opcode_t) r->color;
+ IMCC_debug(interp, DEBUG_PBC, " %d", r->color);
+ break;
+ case PARROT_ARG_KC:
+ r = ins->symregs[i];
+ if (r->set == 'K') {
+ PARROT_ASSERT(r->color >= 0);
+ *(IMCC_INFO(interp)->pc)++ = r->color;
+ }
+ else {
+ *(IMCC_INFO(interp)->pc)++ = build_key(interp, r);
+ }
+ IMCC_debug(interp, DEBUG_PBC, " %d",
IMCC_INFO(interp)->pc[-1]);
- break;
- default:
- IMCC_fatal(interp, 1, "e_pbc_emit:"
+ break;
+ default:
+ IMCC_fatal(interp, 1, "e_pbc_emit:"
"unknown argtype in parrot op\n");
- break;
+ break;
}
}
if (ins->opnum == PARROT_OP_set_args_pc
Modified: trunk/compilers/imcc/pcc.c
==============================================================================
--- trunk/compilers/imcc/pcc.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/imcc/pcc.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -319,12 +319,20 @@
/* TODO verify if const is allowed */
switch (arg->set) {
- case 'I': break;
- case 'S': flags |= PARROT_ARG_STRING; break;
- case 'N': flags |= PARROT_ARG_FLOATVAL; break;
- case 'K':
- case 'P': flags |= PARROT_ARG_PMC; break;
- default : break;
+ case 'I':
+ break;
+ case 'S':
+ flags |= PARROT_ARG_STRING;
+ break;
+ case 'N':
+ flags |= PARROT_ARG_FLOATVAL;
+ break;
+ case 'K':
+ case 'P':
+ flags |= PARROT_ARG_PMC;
+ break;
+ default :
+ break;
}
}
Modified: trunk/compilers/imcc/sets.h
==============================================================================
--- trunk/compilers/imcc/sets.h Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/imcc/sets.h Sun Dec 6 15:03:28 2009 (r42918)
@@ -7,8 +7,8 @@
#define PARROT_IMCC_SETS_H_GUARD
typedef struct _Set {
- unsigned int length;
- unsigned char *bmp;
+ unsigned int length;
+ unsigned char *bmp;
} Set;
/* HEADERIZER BEGIN: compilers/imcc/sets.c */
Modified: trunk/compilers/imcc/symreg.c
==============================================================================
--- trunk/compilers/imcc/symreg.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/imcc/symreg.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -730,14 +730,14 @@
rhs->pmc_type = left->pmc_type;
switch (rhs->pmc_type) {
- case enum_class_Sub:
- case enum_class_Coroutine:
- r[1] = rhs;
- rhs->usage |= U_FIXUP;
- INS(interp, unit, "set_p_pc", "", r, 2, 0, 1);
- return NULL;
- default:
- break;
+ case enum_class_Sub:
+ case enum_class_Coroutine:
+ r[1] = rhs;
+ rhs->usage |= U_FIXUP;
+ INS(interp, unit, "set_p_pc", "", r, 2, 0, 1);
+ return NULL;
+ default:
+ break;
}
r[1] = rhs;
Modified: trunk/compilers/pirc/src/bcgen.c
==============================================================================
--- trunk/compilers/pirc/src/bcgen.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/pirc/src/bcgen.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -883,54 +883,54 @@
while (iter) {
switch (iter->expr->type) {
- case EXPR_CONSTANT: {
- constant *c = iter->expr->expr.c;
- switch (c->type) {
- case INT_VAL:
- *pc++ = PARROT_ARG_IC;
- *pc++ = c->val.ival;
- break;
- case STRING_VAL:
- *pc++ = PARROT_ARG_SC;
- *pc++ = add_string_const(bc, c->val.sval, "ascii");
- break;
- case USTRING_VAL:
- *pc++ = PARROT_ARG_SC;
- *pc++ = add_string_const(bc, c->val.ustr->contents,
- c->val.ustr->charset);
- break;
- default:
- fprintf(stderr, "wrong type of key");
- break;
- }
-
+ case EXPR_CONSTANT: {
+ constant *c = iter->expr->expr.c;
+ switch (c->type) {
+ case INT_VAL:
+ *pc++ = PARROT_ARG_IC;
+ *pc++ = c->val.ival;
+ break;
+ case STRING_VAL:
+ *pc++ = PARROT_ARG_SC;
+ *pc++ = add_string_const(bc, c->val.sval, "ascii");
+ break;
+ case USTRING_VAL:
+ *pc++ = PARROT_ARG_SC;
+ *pc++ = add_string_const(bc, c->val.ustr->contents,
+ c->val.ustr->charset);
+ break;
+ default:
+ fprintf(stderr, "wrong type of key");
break;
}
- case EXPR_TARGET: {
- target *t = iter->expr->expr.t;
- switch (t->info->type) {
- case INT_TYPE:
- *pc++ = PARROT_ARG_I;
- *pc++ = t->info->color;
- break;
- case STRING_TYPE:
- *pc++ = PARROT_ARG_S;
- *pc++ = t->info->color;
- break;
- default:
- fprintf(stderr, "wrong type of key");
- break;
- }
+ break;
+ }
+ case EXPR_TARGET: {
+ target *t = iter->expr->expr.t;
+
+ switch (t->info->type) {
+ case INT_TYPE:
+ *pc++ = PARROT_ARG_I;
+ *pc++ = t->info->color;
break;
- }
- case EXPR_KEY:
- fprintf(stderr, "Nested keys are not supported.");
+ case STRING_TYPE:
+ *pc++ = PARROT_ARG_S;
+ *pc++ = t->info->color;
break;
-
- default:
- fprintf(stderr, "unknown expression type");
+ default:
+ fprintf(stderr, "wrong type of key");
break;
+ }
+ break;
+ }
+ case EXPR_KEY:
+ fprintf(stderr, "Nested keys are not supported.");
+ break;
+
+ default:
+ fprintf(stderr, "unknown expression type");
+ break;
}
Modified: trunk/compilers/pirc/src/pircapi.c
==============================================================================
--- trunk/compilers/pirc/src/pircapi.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/pirc/src/pircapi.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -248,7 +248,7 @@
/* clean up after playing */
release_resources(lexer);
- /* clean up after playing */
+ /* clean up after playing */
yypirlex_destroy(yyscanner);
Modified: trunk/compilers/pirc/src/piremit.c
==============================================================================
--- trunk/compilers/pirc/src/piremit.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/pirc/src/piremit.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -129,24 +129,24 @@
void
print_constant(lexer_state * const lexer, constant * const c) {
switch (c->type) {
- case INT_VAL:
- fprintf(out, "%d", c->val.ival);
- break;
- case NUM_VAL:
- fprintf(out, "%f", c->val.nval);
- break;
- case STRING_VAL:
- fprintf(out, "\"%s\"", c->val.sval);
- break;
- case PMC_VAL:
- fprintf(out, "\"%s\"", c->val.pval);
- break;
- case USTRING_VAL:
- fprintf(out, "%s:\"%s\"", c->val.ustr->charset, c->val.ustr->contents);
- break;
- default:
- panic(lexer, "Unknown type detected in print_constant()");
- break;
+ case INT_VAL:
+ fprintf(out, "%d", c->val.ival);
+ break;
+ case NUM_VAL:
+ fprintf(out, "%f", c->val.nval);
+ break;
+ case STRING_VAL:
+ fprintf(out, "\"%s\"", c->val.sval);
+ break;
+ case PMC_VAL:
+ fprintf(out, "\"%s\"", c->val.pval);
+ break;
+ case USTRING_VAL:
+ fprintf(out, "%s:\"%s\"", c->val.ustr->charset, c->val.ustr->contents);
+ break;
+ default:
+ panic(lexer, "Unknown type detected in print_constant()");
+ break;
}
}
@@ -164,23 +164,23 @@
void
print_expr(lexer_state * const lexer, expression * const expr) {
switch (expr->type) {
- case EXPR_TARGET:
- print_target(lexer, expr->expr.t);
- break;
- case EXPR_CONSTANT:
- print_constant(lexer, expr->expr.c);
- break;
- case EXPR_IDENT:
- fprintf(out, "%s", expr->expr.id);
- break;
- case EXPR_KEY:
- print_key(lexer, expr->expr.k);
- break;
- case EXPR_LABEL:
- fprintf(out, "%d", expr->expr.l->offset);
- break;
- default:
- break;
+ case EXPR_TARGET:
+ print_target(lexer, expr->expr.t);
+ break;
+ case EXPR_CONSTANT:
+ print_constant(lexer, expr->expr.c);
+ break;
+ case EXPR_IDENT:
+ fprintf(out, "%s", expr->expr.id);
+ break;
+ case EXPR_KEY:
+ print_key(lexer, expr->expr.k);
+ break;
+ case EXPR_LABEL:
+ fprintf(out, "%d", expr->expr.l->offset);
+ break;
+ default:
+ break;
}
}
@@ -593,25 +593,25 @@
static void
emit_pbc_expr(lexer_state * const lexer, expression * const operand) {
switch (operand->type) {
- case EXPR_CONSTANT:
- emit_pbc_const_arg(lexer, operand->expr.c);
- break;
- case EXPR_TARGET:
- emit_pbc_target_arg(lexer, operand->expr.t);
- break;
- case EXPR_LABEL:
- emit_pbc_label_arg(lexer, operand->expr.l);
- break;
- case EXPR_KEY:
- emit_pbc_key(lexer->bc, operand->expr.k);
- break;
- /*
- case EXPR_IDENT:
- fprintf(stderr, "expr ident\n");
- break;
- */
- default:
- break;
+ case EXPR_CONSTANT:
+ emit_pbc_const_arg(lexer, operand->expr.c);
+ break;
+ case EXPR_TARGET:
+ emit_pbc_target_arg(lexer, operand->expr.t);
+ break;
+ case EXPR_LABEL:
+ emit_pbc_label_arg(lexer, operand->expr.l);
+ break;
+ case EXPR_KEY:
+ emit_pbc_key(lexer->bc, operand->expr.k);
+ break;
+ /*
+ case EXPR_IDENT:
+ fprintf(stderr, "expr ident\n");
+ break;
+ */
+ default:
+ break;
}
}
@@ -833,22 +833,22 @@
key = add_string_const(lexer->bc, iter->key, "ascii");
switch (iter->value->type) {
- case INT_VAL:
- value = iter->value->val.ival;
- break;
- case NUM_VAL:
- value = add_num_const(lexer->bc, iter->value->val.nval);
- break;
- case STRING_VAL:
- value = add_string_const(lexer->bc, iter->value->val.sval, "ascii");
- break;
- case USTRING_VAL:
- value = add_string_const(lexer->bc, iter->value->val.ustr->contents,
- iter->value->val.ustr->charset);
- break;
- default:
- panic(lexer, "unknown annotation constant type");
- return; /* panic() exits, so this never happens */
+ case INT_VAL:
+ value = iter->value->val.ival;
+ break;
+ case NUM_VAL:
+ value = add_num_const(lexer->bc, iter->value->val.nval);
+ break;
+ case STRING_VAL:
+ value = add_string_const(lexer->bc, iter->value->val.sval, "ascii");
+ break;
+ case USTRING_VAL:
+ value = add_string_const(lexer->bc, iter->value->val.ustr->contents,
+ iter->value->val.ustr->charset);
+ break;
+ default:
+ panic(lexer, "unknown annotation constant type");
+ return; /* panic() exits, so this never happens */
}
Modified: trunk/compilers/pirc/src/pirmacro.c
==============================================================================
--- trunk/compilers/pirc/src/pirmacro.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/pirc/src/pirmacro.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -146,7 +146,7 @@
if (used + length >= macro->buffersize) {
unsigned newsize = macro->buffersize << 1;
char *newbuffer;
- /* double the size (moving all bits left by 1 means doubling) */
+ /* double the size (moving all bits left by 1 means doubling) */
newbuffer = (char *)mem_sys_allocate(sizeof (char) * macro->buffersize);
memcpy(newbuffer, macro->body, macro->buffersize);
mem_sys_free(macro->body);
Modified: trunk/compilers/pirc/src/pirop.c
==============================================================================
--- trunk/compilers/pirc/src/pirop.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/pirc/src/pirop.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -74,29 +74,29 @@
static int
get_signature_length(NOTNULL(expression * const e)) {
switch (e->type) {
- case EXPR_TARGET:
- return 2 + ((e->expr.t->key != NULL) /* if there's a key on this target ... */
- /* ... get its length. */
- ? get_signature_length(e->expr.t->key->head->expr) + 1
- : 0);
- case EXPR_CONSTANT:
- return 3; /* for _, 'k', 'c' */
- case EXPR_IDENT:
- return 3; /* 1 for '_', 1 for 'i', 1 for 'c' */
- case EXPR_KEY: { /* for '_', 'k' */
- int n;
- /* if the key is an integer constant, then signature becomes '_kic', otherwise _kc. */
- if (e->expr.k->head->expr->type == EXPR_CONSTANT
- && e->expr.k->head->expr->expr.c->type == INT_VAL)
- n = 3;
- else
- n = 2;
-
- return n + get_signature_length(e->expr.k->head->expr);
- }
- default:
- fprintf(stderr, "wrong expression typein get_signature_length()\n");
- break;
+ case EXPR_TARGET:
+ return 2 + ((e->expr.t->key != NULL) /* if there's a key on this target ... */
+ /* ... get its length. */
+ ? get_signature_length(e->expr.t->key->head->expr) + 1
+ : 0);
+ case EXPR_CONSTANT:
+ return 3; /* for _, 'k', 'c' */
+ case EXPR_IDENT:
+ return 3; /* 1 for '_', 1 for 'i', 1 for 'c' */
+ case EXPR_KEY: { /* for '_', 'k' */
+ int n;
+ /* if the key is an integer constant, then signature becomes '_kic', otherwise _kc. */
+ if (e->expr.k->head->expr->type == EXPR_CONSTANT
+ && e->expr.k->head->expr->expr.c->type == INT_VAL)
+ n = 3;
+ else
+ n = 2;
+
+ return n + get_signature_length(e->expr.k->head->expr);
+ }
+ default:
+ fprintf(stderr, "wrong expression typein get_signature_length()\n");
+ break;
}
return 0;
}
@@ -125,84 +125,84 @@
static char *
write_signature(NOTNULL(expression * const iter), NOTNULL(char *instr_writer)) {
switch (iter->type) {
- case EXPR_TARGET:
- *instr_writer++ = type_codes[iter->expr.t->info->type];
+ case EXPR_TARGET:
+ *instr_writer++ = type_codes[iter->expr.t->info->type];
- if (iter->expr.t->key) {
- *instr_writer++ = '_';
- *instr_writer++ = 'k';
-
- switch (iter->expr.t->key->head->expr->type) {
- case EXPR_TARGET:
- switch (iter->expr.t->key->head->expr->expr.t->info->type) {
- case PMC_TYPE:
- /* the key is a target, and its type is a PMC. In that
- * case, do not print the signature; 'kp' is not valid.
- */
- break;
- case STRING_TYPE: /* strings become key-constant */
- *instr_writer++ = 'c';
- break;
- case INT_TYPE:
- *instr_writer++ = 'i';
- break;
- default:
- break;
- }
- break;
- case EXPR_CONSTANT:
- /* integer constant key results in '_kic' signature */
- if (iter->expr.c->type == INT_VAL)
- *instr_writer++ = 'i';
-
- *instr_writer++ = 'c';
- break;
- default:
- /* XXX does this ever happen? */
- fprintf(stderr, "write_signature: non-constant key\n");
- instr_writer = write_signature(iter->expr.t->key->head->expr, instr_writer);
- break;
+ if (iter->expr.t->key) {
+ *instr_writer++ = '_';
+ *instr_writer++ = 'k';
+
+ switch (iter->expr.t->key->head->expr->type) {
+ case EXPR_TARGET:
+ switch (iter->expr.t->key->head->expr->expr.t->info->type) {
+ case PMC_TYPE:
+ /* the key is a target, and its type is a PMC. In that
+ * case, do not print the signature; 'kp' is not valid.
+ */
+ break;
+ case STRING_TYPE: /* strings become key-constant */
+ *instr_writer++ = 'c';
+ break;
+ case INT_TYPE:
+ *instr_writer++ = 'i';
+ break;
+ default:
+ break;
}
-
+ break;
+ case EXPR_CONSTANT:
+ /* integer constant key results in '_kic' signature */
+ if (iter->expr.c->type == INT_VAL)
+ *instr_writer++ = 'i';
+
+ *instr_writer++ = 'c';
+ break;
+ default:
+ /* XXX does this ever happen? */
+ fprintf(stderr, "write_signature: non-constant key\n");
+ instr_writer = write_signature(iter->expr.t->key->head->expr, instr_writer);
+ break;
}
- break;
- case EXPR_CONSTANT:
- *instr_writer++ = type_codes[iter->expr.c->type];
- *instr_writer++ = 'c';
- break;
- case EXPR_IDENT: /* used for labels; these will be converted to (i)nteger (c)onstants*/
- *instr_writer++ = 'i';
- *instr_writer++ = 'c';
- break;
- case EXPR_KEY:
- *instr_writer++ = 'p';
- *instr_writer++ = 'c';
- /* XXX figure out what signature is needed. I think 'pc' */
- /*
- else {
- *instr_writer++ = 'k';
- }
- */
- /*instr_writer = write_signature(iter->expr.k->head->expr, instr_writer);*/
+ }
+ break;
+ case EXPR_CONSTANT:
+ *instr_writer++ = type_codes[iter->expr.c->type];
+ *instr_writer++ = 'c';
+ break;
+ case EXPR_IDENT: /* used for labels; these will be converted to (i)nteger (c)onstants*/
+ *instr_writer++ = 'i';
+ *instr_writer++ = 'c';
+ break;
+ case EXPR_KEY:
+ *instr_writer++ = 'p';
+ *instr_writer++ = 'c';
+
+ /* XXX figure out what signature is needed. I think 'pc' */
+ /*
+ else {
+ *instr_writer++ = 'k';
+ }
+ */
+ /*instr_writer = write_signature(iter->expr.k->head->expr, instr_writer);*/
- /*
-
- switch (iter->expr.k->expr->type) {
- case EXPR_CONSTANT:
- *instr_writer++ = 'c';
- break;
- default:
- fprintf(stderr, "write_signature: non-constant key\n");
- instr_writer = write_signature(iter->expr.k->expr, instr_writer);
- break;
- }
- */
+ /*
+ switch (iter->expr.k->expr->type) {
+ case EXPR_CONSTANT:
+ *instr_writer++ = 'c';
break;
- default:
- fprintf(stderr, "wrong expression type in write_signature()\n");
+ default:
+ fprintf(stderr, "write_signature: non-constant key\n");
+ instr_writer = write_signature(iter->expr.k->expr, instr_writer);
break;
+ }
+ */
+
+ break;
+ default:
+ fprintf(stderr, "wrong expression type in write_signature()\n");
+ break;
}
return instr_writer;
}
Modified: trunk/compilers/pirc/src/pirpcc.c
==============================================================================
--- trunk/compilers/pirc/src/pirpcc.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/pirc/src/pirpcc.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -80,20 +80,20 @@
int flag = 0;
switch (arg->value->type) {
- case EXPR_TARGET:
- /* copy the type of the target */
- SET_FLAG(flag, arg->value->expr.t->info->type);
- break;
- case EXPR_CONSTANT:
- /* copy the type of the constant; note that constants store a value_type,
- * not a pir_type, so convert here.
- */
- SET_FLAG(flag, valuetype_pirtype_clut[arg->value->expr.c->type]);
- /* set the flag indicating the argument is a constant literal, not a register. */
- SET_FLAG(flag, PARROT_ARG_CONSTANT);
- break;
- default:
- break;
+ case EXPR_TARGET:
+ /* copy the type of the target */
+ SET_FLAG(flag, arg->value->expr.t->info->type);
+ break;
+ case EXPR_CONSTANT:
+ /* copy the type of the constant; note that constants store a value_type,
+ * not a pir_type, so convert here.
+ */
+ SET_FLAG(flag, valuetype_pirtype_clut[arg->value->expr.c->type]);
+ /* set the flag indicating the argument is a constant literal, not a register. */
+ SET_FLAG(flag, PARROT_ARG_CONSTANT);
+ break;
+ default:
+ break;
}
/* if the argument has a :flat flag, copy that */
@@ -694,17 +694,17 @@
/* check out the type of the method expression; it may be a PMC or a STRING. */
switch (inv->method->type) {
- case EXPR_TARGET:
- new_sub_instr(lexer, PARROT_OP_tailcallmethod_p_p, "tailcallmethod_p_p", 0);
- add_operands(lexer, "%T%E", inv->sub, inv->method); /* XXX test this */
- break;
- case EXPR_CONSTANT:
- new_sub_instr(lexer, PARROT_OP_tailcallmethod_p_sc, "tailcallmethod_p_sc", 0);
- add_operands(lexer, "%T%E", inv->sub, inv->method);
- break;
- default:
- panic(lexer, "unknown expression type in tailcallmethod instruction");
- break;
+ case EXPR_TARGET:
+ new_sub_instr(lexer, PARROT_OP_tailcallmethod_p_p, "tailcallmethod_p_p", 0);
+ add_operands(lexer, "%T%E", inv->sub, inv->method); /* XXX test this */
+ break;
+ case EXPR_CONSTANT:
+ new_sub_instr(lexer, PARROT_OP_tailcallmethod_p_sc, "tailcallmethod_p_sc", 0);
+ add_operands(lexer, "%T%E", inv->sub, inv->method);
+ break;
+ default:
+ panic(lexer, "unknown expression type in tailcallmethod instruction");
+ break;
}
}
@@ -725,30 +725,30 @@
void
convert_inv_to_instr(lexer_state * const lexer, invocation * const inv) {
switch (inv->type) {
- case CALL_PCC:
- convert_pcc_call(lexer, inv);
- break;
- case CALL_RETURN:
- convert_pcc_return(lexer, inv);
- break;
- case CALL_NCI:
- convert_nci_call(lexer, inv);
- break;
- case CALL_YIELD:
- convert_pcc_yield(lexer, inv);
- break;
- case CALL_TAILCALL:
- convert_pcc_tailcall(lexer, inv);
- break;
- case CALL_METHOD:
- convert_pcc_methodcall(lexer, inv);
- break;
- case CALL_METHOD_TAILCALL:
- convert_pcc_methodtailcall(lexer, inv);
- break;
- default:
- panic(lexer, "Unknown invocation type in convert_inv_to_instr()");
- break;
+ case CALL_PCC:
+ convert_pcc_call(lexer, inv);
+ break;
+ case CALL_RETURN:
+ convert_pcc_return(lexer, inv);
+ break;
+ case CALL_NCI:
+ convert_nci_call(lexer, inv);
+ break;
+ case CALL_YIELD:
+ convert_pcc_yield(lexer, inv);
+ break;
+ case CALL_TAILCALL:
+ convert_pcc_tailcall(lexer, inv);
+ break;
+ case CALL_METHOD:
+ convert_pcc_methodcall(lexer, inv);
+ break;
+ case CALL_METHOD_TAILCALL:
+ convert_pcc_methodtailcall(lexer, inv);
+ break;
+ default:
+ panic(lexer, "Unknown invocation type in convert_inv_to_instr()");
+ break;
}
Modified: trunk/compilers/pirc/src/pirregalloc.c
==============================================================================
--- trunk/compilers/pirc/src/pirregalloc.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/compilers/pirc/src/pirregalloc.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -379,10 +379,10 @@
* and parrot register numbering starts at 0, substract 1 here.
* (initializing r to 0 will make the algorithm stop working properly.)
*/
- unsigned reg = lsr->r[type] - 1;
- lsr->r[type]++;
- fprintf(stderr, "get_free_reg(): non-cached: %d\n", reg);
- return reg;
+ unsigned reg = lsr->r[type] - 1;
+ lsr->r[type]++;
+ fprintf(stderr, "get_free_reg(): non-cached: %d\n", reg);
+ return reg;
}
}
Modified: trunk/config/auto/env/test_unsetenv_c.in
==============================================================================
--- trunk/config/auto/env/test_unsetenv_c.in Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/config/auto/env/test_unsetenv_c.in Sun Dec 6 15:03:28 2009 (r42918)
@@ -11,7 +11,7 @@
int main(int argc, char **argv)
{
-/* we have an hand-rolled unsetenv */
+ /* we have an hand-rolled unsetenv */
#ifndef WIN32
unsetenv("PARROT_TEST");
#endif
Modified: trunk/config/auto/readline/readline_c.in
==============================================================================
--- trunk/config/auto/readline/readline_c.in Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/config/auto/readline/readline_c.in Sun Dec 6 15:03:28 2009 (r42918)
@@ -16,8 +16,8 @@
#ifdef __cplusplus
extern "C" {
#endif
-char * readline(const char *);
-void * rl_get_keymap(void);
+ char * readline(const char *);
+ void * rl_get_keymap(void);
#ifdef __cplusplus
}
#endif
Modified: trunk/config/gen/platform/ansi/exec.c
==============================================================================
--- trunk/config/gen/platform/ansi/exec.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/config/gen/platform/ansi/exec.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -66,8 +66,8 @@
void
Parrot_Exec_OS_Comman(PARROT_INTERP, STRING *command)
{
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_NOSPAWN,
- "Exec not implemented");
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_NOSPAWN,
+ "Exec not implemented");
}
/*
Modified: trunk/config/gen/platform/generic/stat.c
==============================================================================
--- trunk/config/gen/platform/generic/stat.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/config/gen/platform/generic/stat.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -75,62 +75,62 @@
}
switch (thing) {
- case STAT_FILESIZE:
- result = statbuf->st_size;
- break;
- case STAT_ISDIR:
- result = S_ISDIR(statbuf->st_mode);
- break;
- case STAT_ISREG:
- result = S_ISREG(statbuf->st_mode);
- break;
- case STAT_ISDEV:
- result = S_ISCHR(statbuf->st_mode) || S_ISBLK(statbuf->st_mode);
- break;
- case STAT_CREATETIME:
- result = -1;
- break;
- case STAT_ACCESSTIME:
- result = statbuf->st_atime;
- break;
- case STAT_MODIFYTIME:
- result = statbuf->st_mtime;
- break;
- case STAT_CHANGETIME:
- result = statbuf->st_ctime;
- break;
- case STAT_BACKUPTIME:
- result = -1;
- break;
- case STAT_UID:
- result = statbuf->st_uid;
- break;
- case STAT_GID:
- result = statbuf->st_gid;
- break;
- case STAT_PLATFORM_DEV:
- result = statbuf->st_dev;
- break;
- case STAT_PLATFORM_INODE:
- result = statbuf->st_ino;
- break;
- case STAT_PLATFORM_MODE:
- result = statbuf->st_mode;
- break;
- case STAT_PLATFORM_NLINKS:
- result = statbuf->st_nlink;
- break;
- case STAT_PLATFORM_DEVTYPE:
- result = statbuf->st_rdev;
- break;
- case STAT_PLATFORM_BLOCKSIZE:
- result = statbuf->st_blksize;
- break;
- case STAT_PLATFORM_BLOCKS:
- result = statbuf->st_blocks;
- break;
- default:
- break;
+ case STAT_FILESIZE:
+ result = statbuf->st_size;
+ break;
+ case STAT_ISDIR:
+ result = S_ISDIR(statbuf->st_mode);
+ break;
+ case STAT_ISREG:
+ result = S_ISREG(statbuf->st_mode);
+ break;
+ case STAT_ISDEV:
+ result = S_ISCHR(statbuf->st_mode) || S_ISBLK(statbuf->st_mode);
+ break;
+ case STAT_CREATETIME:
+ result = -1;
+ break;
+ case STAT_ACCESSTIME:
+ result = statbuf->st_atime;
+ break;
+ case STAT_MODIFYTIME:
+ result = statbuf->st_mtime;
+ break;
+ case STAT_CHANGETIME:
+ result = statbuf->st_ctime;
+ break;
+ case STAT_BACKUPTIME:
+ result = -1;
+ break;
+ case STAT_UID:
+ result = statbuf->st_uid;
+ break;
+ case STAT_GID:
+ result = statbuf->st_gid;
+ break;
+ case STAT_PLATFORM_DEV:
+ result = statbuf->st_dev;
+ break;
+ case STAT_PLATFORM_INODE:
+ result = statbuf->st_ino;
+ break;
+ case STAT_PLATFORM_MODE:
+ result = statbuf->st_mode;
+ break;
+ case STAT_PLATFORM_NLINKS:
+ result = statbuf->st_nlink;
+ break;
+ case STAT_PLATFORM_DEVTYPE:
+ result = statbuf->st_rdev;
+ break;
+ case STAT_PLATFORM_BLOCKSIZE:
+ result = statbuf->st_blksize;
+ break;
+ case STAT_PLATFORM_BLOCKS:
+ result = statbuf->st_blocks;
+ break;
+ default:
+ break;
}
return result;
Modified: trunk/config/gen/platform/win32/env.c
==============================================================================
--- trunk/config/gen/platform/win32/env.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/config/gen/platform/win32/env.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -127,10 +127,10 @@
void
Parrot_unsetenv(PARROT_INTERP, STRING *name)
{
-/* You can remove a variable from the environment by specifying an empty
- string -- in other words, by specifying only varname=.
- -- _putenv, _wputenv (CRT) documentation
-*/
+ /* You can remove a variable from the environment by specifying an empty
+ string -- in other words, by specifying only varname=.
+ -- _putenv, _wputenv (CRT) documentation
+ */
Parrot_setenv(interp, name, Parrot_str_new(interp, "", 0));
}
Modified: trunk/config/gen/platform/win32/stat.c
==============================================================================
--- trunk/config/gen/platform/win32/stat.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/config/gen/platform/win32/stat.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -93,64 +93,64 @@
}
switch (thing) {
- case STAT_FILESIZE:
- result = statbuf->st_size;
- break;
- case STAT_ISDIR:
- result = S_ISDIR(statbuf->st_mode);
- break;
- case STAT_ISREG:
- result = S_ISREG(statbuf->st_mode);
- break;
- case STAT_ISDEV:
- result = S_ISCHR(statbuf->st_mode) || S_ISBLK(statbuf->st_mode);
- break;
- case STAT_CREATETIME:
- result = -1;
- break;
- case STAT_ACCESSTIME:
- result = statbuf->st_atime;
- break;
- case STAT_MODIFYTIME:
- result = statbuf->st_mtime;
- break;
- case STAT_CHANGETIME:
- result = statbuf->st_ctime;
- break;
- case STAT_BACKUPTIME:
- result = -1;
- break;
- case STAT_UID:
- result = statbuf->st_uid;
- break;
- case STAT_GID:
- result = statbuf->st_gid;
- break;
- case STAT_PLATFORM_DEV:
- result = statbuf->st_dev;
- break;
- case STAT_PLATFORM_INODE:
- result = statbuf->st_ino;
- break;
- case STAT_PLATFORM_MODE:
- result = statbuf->st_mode;
- break;
- case STAT_PLATFORM_NLINKS:
- result = statbuf->st_nlink;
- break;
- case STAT_PLATFORM_DEVTYPE:
- result = statbuf->st_rdev;
- break;
- case STAT_PLATFORM_BLOCKSIZE:
- Parrot_ex_throw_from_c_args(interp, NULL, 1,
+ case STAT_FILESIZE:
+ result = statbuf->st_size;
+ break;
+ case STAT_ISDIR:
+ result = S_ISDIR(statbuf->st_mode);
+ break;
+ case STAT_ISREG:
+ result = S_ISREG(statbuf->st_mode);
+ break;
+ case STAT_ISDEV:
+ result = S_ISCHR(statbuf->st_mode) || S_ISBLK(statbuf->st_mode);
+ break;
+ case STAT_CREATETIME:
+ result = -1;
+ break;
+ case STAT_ACCESSTIME:
+ result = statbuf->st_atime;
+ break;
+ case STAT_MODIFYTIME:
+ result = statbuf->st_mtime;
+ break;
+ case STAT_CHANGETIME:
+ result = statbuf->st_ctime;
+ break;
+ case STAT_BACKUPTIME:
+ result = -1;
+ break;
+ case STAT_UID:
+ result = statbuf->st_uid;
+ break;
+ case STAT_GID:
+ result = statbuf->st_gid;
+ break;
+ case STAT_PLATFORM_DEV:
+ result = statbuf->st_dev;
+ break;
+ case STAT_PLATFORM_INODE:
+ result = statbuf->st_ino;
+ break;
+ case STAT_PLATFORM_MODE:
+ result = statbuf->st_mode;
+ break;
+ case STAT_PLATFORM_NLINKS:
+ result = statbuf->st_nlink;
+ break;
+ case STAT_PLATFORM_DEVTYPE:
+ result = statbuf->st_rdev;
+ break;
+ case STAT_PLATFORM_BLOCKSIZE:
+ Parrot_ex_throw_from_c_args(interp, NULL, 1,
"STAT_PLATFORM_BLOCKSIZE not supported");
- break;
- case STAT_PLATFORM_BLOCKS:
- Parrot_ex_throw_from_c_args(interp, NULL, 1,
+ break;
+ case STAT_PLATFORM_BLOCKS:
+ Parrot_ex_throw_from_c_args(interp, NULL, 1,
"STAT_PLATFORM_BLOCKS not supported");
- break;
- default:
- break;
+ break;
+ default:
+ break;
}
return result;
Modified: trunk/examples/benchmarks/primes.c
==============================================================================
--- trunk/examples/benchmarks/primes.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/examples/benchmarks/primes.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -39,36 +39,36 @@
int
main(int argc, char *argv[])
{
- int I1 = 1;
- int I2 = 50000;
- int I3;
- int I4;
- int I5;
- int I6 = 0;
- int I7;
- printf("N primes up to ");
- printf("%d", I2);
- printf(" is: ");
-
- REDO:
- I3 = 2;
- I4 = I1 / 2;
- LOOP:
- I5 = I1 % I3;
- if (I5) {goto OK;}
- goto NEXT;
- OK:
- I3++;
- if (I3 <= I4) {goto LOOP;}
+ int I1 = 1;
+ int I2 = 50000;
+ int I3;
+ int I4;
+ int I5;
+ int I6 = 0;
+ int I7;
+ printf("N primes up to ");
+ printf("%d", I2);
+ printf(" is: ");
+
+ REDO:
+ I3 = 2;
+ I4 = I1 / 2;
+ LOOP:
+ I5 = I1 % I3;
+ if (I5) {goto OK;}
+ goto NEXT;
+ OK:
+ I3++;
+ if (I3 <= I4) {goto LOOP;}
I6++;
I7 = I1;
- NEXT:
- I1++;
- if (I1 <= I2) {goto REDO;}
- printf("%d\n", I6);
- printf("last is: %d\n", I7);
+ NEXT:
+ I1++;
+ if (I1 <= I2) {goto REDO;}
+ printf("%d\n", I6);
+ printf("last is: %d\n", I7);
- return 0;
+ return 0;
}
/*
Modified: trunk/examples/benchmarks/primes2.c
==============================================================================
--- trunk/examples/benchmarks/primes2.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/examples/benchmarks/primes2.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -37,24 +37,24 @@
int
main(int argc, char *argv[])
{
- int i=0, max=500;
- int i6 = 0;
- int i7;
-
- while (1) {
- if (isprime1(i)) {
- i7 = i;
- i6++;
- }
- i++;
- if (i==max){
- break;
- }
+ int i=0, max=500;
+ int i6 = 0;
+ int i7;
+
+ while (1) {
+ if (isprime1(i)) {
+ i7 = i;
+ i6++;
}
+ i++;
+ if (i==max) {
+ break;
+ }
+ }
- printf("N primes calculated to %d is %d\nlast is: %d\n", max, i6, i7);
+ printf("N primes calculated to %d is %d\nlast is: %d\n", max, i6, i7);
- return 0;
+ return 0;
}
/*
@@ -69,18 +69,18 @@
int isprime1(int input)
{
- int n;
+ int n;
- if (input < 1) {
- return 0;
- }
- n = input - 1;
+ if (input < 1) {
+ return 0;
+ }
+ n = input - 1;
- while (n > 1){
- if (input%n == 0) return 0;
- n--;
- }
- return 1;
+ while (n > 1) {
+ if (input%n == 0) return 0;
+ n--;
+ }
+ return 1;
}
/*
Modified: trunk/examples/c/test_main.c
==============================================================================
--- trunk/examples/c/test_main.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/examples/c/test_main.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -131,48 +131,48 @@
}
switch (opt.opt_id) {
- case 'b':
+ case 'b':
setopt(PARROT_BOUNDS_FLAG);
break;
- case 'j':
+ case 'j':
setopt(PARROT_JIT_FLAG);
break;
- case 'o':
+ case 'o':
setopt(PARROT_EXEC_FLAG);
break;
- case 'p':
+ case 'p':
setopt(PARROT_PROFILE_FLAG);
break;
- case 'P':
+ case 'P':
setopt(PARROT_PREDEREF_FLAG);
break;
- case 'S':
+ case 'S':
setopt(PARROT_SWITCH_FLAG);
break;
- case 'g':
+ case 'g':
unsetopt(PARROT_CGOTO_FLAG);
break;
- case 't':
+ case 't':
setopt(PARROT_TRACE_FLAG);
break;
- case 'd':
+ case 'd':
setopt(PARROT_DEBUG_FLAG);
break;
- case 'h':
+ case 'h':
usage();
break;
- case 'v':
+ case 'v':
version();
break;
- case 'w':
+ case 'w':
Parrot_setwarnings(interp, PARROT_WARNINGS_ALL_FLAG);
break;
- case '.': /* Give Windows Parrot hackers an opportunity to
- * attach a debuggger. */
+ case '.': /* Give Windows Parrot hackers an opportunity to
+ * attach a debuggger. */
fgetc(stdin);
break;
- case OPT_GC_DEBUG:
+ case OPT_GC_DEBUG:
#if DISABLE_GC_DEBUG
Parrot_warn(interp, PARROT_WARNINGS_ALL_FLAG,
"PARROT_GC_DEBUG is set but the binary was "
@@ -180,7 +180,7 @@
#endif
setopt(PARROT_GC_DEBUG_FLAG);
break;
- case OPT_DESTROY_FLAG:
+ case OPT_DESTROY_FLAG:
setopt(PARROT_DESTROY_FLAG);
break;
}
Modified: trunk/examples/compilers/japhc.c
==============================================================================
--- trunk/examples/compilers/japhc.c Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/examples/compilers/japhc.c Sun Dec 6 15:03:28 2009 (r42918)
@@ -81,12 +81,12 @@
for (start = p = string ; *string; string++) {
if (*string == '\\' && string[1]) {
switch (*++string) {
- case 'n':
- *p++ = '\n';
- break;
- default:
- *p++ = *string;
- break;
+ case 'n':
+ *p++ = '\n';
+ break;
+ default:
+ *p++ = *string;
+ break;
}
}
else
@@ -191,32 +191,32 @@
pc = cur_cs->base.data;
for (p = program; *p; ++p) {
switch (*p) {
- case 'p': /* print_sc */
- *pc++ = interp->op_lib->op_code("print_sc", 1);
- /* const follows */
- ++p;
- switch (*p) {
- case 'J':
- *pc++ = add_const_str(interp, consts, "Just ");
- break;
- case 'a':
- *pc++ = add_const_str(interp, consts, "another ");
- break;
- case 'P':
- *pc++ = add_const_str(interp, consts, "Parrot ");
- break;
- case 'H':
- *pc++ = add_const_str(interp, consts, "Hacker");
- break;
- case 'n':
- *pc++ = add_const_str(interp, consts, "\n");
- break;
- }
- break;
- case 'e': /* end */
- *pc++ = interp->op_lib->op_code("invoke_p", 1);
- *pc++ = 1;
+ case 'p': /* print_sc */
+ *pc++ = interp->op_lib->op_code("print_sc", 1);
+ /* const follows */
+ ++p;
+ switch (*p) {
+ case 'J':
+ *pc++ = add_const_str(interp, consts, "Just ");
+ break;
+ case 'a':
+ *pc++ = add_const_str(interp, consts, "another ");
+ break;
+ case 'P':
+ *pc++ = add_const_str(interp, consts, "Parrot ");
break;
+ case 'H':
+ *pc++ = add_const_str(interp, consts, "Hacker");
+ break;
+ case 'n':
+ *pc++ = add_const_str(interp, consts, "\n");
+ break;
+ }
+ break;
+ case 'e': /* end */
+ *pc++ = interp->op_lib->op_code("invoke_p", 1);
+ *pc++ = 1;
+ break;
}
}
if (old_cs) {
Modified: trunk/include/parrot/exceptions.h
==============================================================================
--- trunk/include/parrot/exceptions.h Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/include/parrot/exceptions.h Sun Dec 6 15:03:28 2009 (r42918)
@@ -24,77 +24,77 @@
/* &gen_from_enum(except_types.pasm) */
typedef enum {
- EXCEPTION_BAD_BUFFER_SIZE,
- EXCEPTION_MISSING_ENCODING_NAME,
- EXCEPTION_INVALID_STRING_REPRESENTATION,
- EXCEPTION_ICU_ERROR,
- EXCEPTION_UNIMPLEMENTED,
-
- EXCEPTION_NULL_REG_ACCESS,
- EXCEPTION_NO_REG_FRAMES,
- EXCEPTION_SUBSTR_OUT_OF_STRING,
- EXCEPTION_ORD_OUT_OF_STRING,
- EXCEPTION_MALFORMED_UTF8,
- EXCEPTION_MALFORMED_UTF16,
- EXCEPTION_MALFORMED_UTF32,
- EXCEPTION_INVALID_CHARACTER,
- EXCEPTION_INVALID_CHARTYPE,
- EXCEPTION_INVALID_ENCODING,
- EXCEPTION_INVALID_CHARCLASS,
- EXCEPTION_NEG_REPEAT,
- EXCEPTION_NEG_SUBSTR,
- EXCEPTION_NEG_SLEEP,
- EXCEPTION_NEG_CHOP,
- EXCEPTION_INVALID_OPERATION,
- EXCEPTION_ARG_OP_NOT_HANDLED,
- EXCEPTION_KEY_NOT_FOUND,
- EXCEPTION_JIT_UNAVAILABLE,
- EXCEPTION_EXEC_UNAVAILABLE,
- EXCEPTION_INTERP_ERROR,
- EXCEPTION_PREDEREF_LOAD_ERROR,
- EXCEPTION_PARROT_USAGE_ERROR,
- EXCEPTION_PIO_ERROR,
- EXCEPTION_PARROT_POINTER_ERROR,
- EXCEPTION_DIV_BY_ZERO,
- EXCEPTION_PIO_NOT_IMPLEMENTED,
- EXCEPTION_ALLOCATION_ERROR,
- EXCEPTION_INTERNAL_PANIC,
- EXCEPTION_OUT_OF_BOUNDS,
- EXCEPTION_JIT_ERROR,
- EXCEPTION_EXEC_ERROR,
- EXCEPTION_ILL_INHERIT,
- EXCEPTION_NO_PREV_CS,
- EXCEPTION_NO_CLASS,
- EXCEPTION_LEX_NOT_FOUND,
- EXCEPTION_PAD_NOT_FOUND,
- EXCEPTION_ATTRIB_NOT_FOUND,
- EXCEPTION_GLOBAL_NOT_FOUND,
- EXCEPTION_EXTERNAL_ERROR,
- EXCEPTION_METHOD_NOT_FOUND,
- EXCEPTION_VTABLE_NOT_FOUND,
- EXCEPTION_WRITE_TO_CONSTCLASS,
- EXCEPTION_NOSPAWN,
- EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- EXCEPTION_ERR_OVERFLOW,
- EXCEPTION_LOSSY_CONVERSION,
- EXCEPTION_ROLE_COMPOSITION_METHOD_CONFLICT,
- EXCEPTION_UNEXPECTED_NULL,
- EXCEPTION_LIBRARY_ERROR,
- EXCEPTION_LIBRARY_NOT_LOADED,
- EXCEPTION_SYNTAX_ERROR,
- EXCEPTION_MALFORMED_PACKFILE,
-
- CONTROL_RETURN,
- CONTROL_OK,
- CONTROL_BREAK,
- CONTROL_CONTINUE,
- CONTROL_ERROR,
- CONTROL_TAKE,
- CONTROL_LEAVE,
-
- CONTROL_LOOP_NEXT,
- CONTROL_LOOP_LAST,
- CONTROL_LOOP_REDO
+ EXCEPTION_BAD_BUFFER_SIZE,
+ EXCEPTION_MISSING_ENCODING_NAME,
+ EXCEPTION_INVALID_STRING_REPRESENTATION,
+ EXCEPTION_ICU_ERROR,
+ EXCEPTION_UNIMPLEMENTED,
+
+ EXCEPTION_NULL_REG_ACCESS,
+ EXCEPTION_NO_REG_FRAMES,
+ EXCEPTION_SUBSTR_OUT_OF_STRING,
+ EXCEPTION_ORD_OUT_OF_STRING,
+ EXCEPTION_MALFORMED_UTF8,
+ EXCEPTION_MALFORMED_UTF16,
+ EXCEPTION_MALFORMED_UTF32,
+ EXCEPTION_INVALID_CHARACTER,
+ EXCEPTION_INVALID_CHARTYPE,
+ EXCEPTION_INVALID_ENCODING,
+ EXCEPTION_INVALID_CHARCLASS,
+ EXCEPTION_NEG_REPEAT,
+ EXCEPTION_NEG_SUBSTR,
+ EXCEPTION_NEG_SLEEP,
+ EXCEPTION_NEG_CHOP,
+ EXCEPTION_INVALID_OPERATION,
+ EXCEPTION_ARG_OP_NOT_HANDLED,
+ EXCEPTION_KEY_NOT_FOUND,
+ EXCEPTION_JIT_UNAVAILABLE,
+ EXCEPTION_EXEC_UNAVAILABLE,
+ EXCEPTION_INTERP_ERROR,
+ EXCEPTION_PREDEREF_LOAD_ERROR,
+ EXCEPTION_PARROT_USAGE_ERROR,
+ EXCEPTION_PIO_ERROR,
+ EXCEPTION_PARROT_POINTER_ERROR,
+ EXCEPTION_DIV_BY_ZERO,
+ EXCEPTION_PIO_NOT_IMPLEMENTED,
+ EXCEPTION_ALLOCATION_ERROR,
+ EXCEPTION_INTERNAL_PANIC,
+ EXCEPTION_OUT_OF_BOUNDS,
+ EXCEPTION_JIT_ERROR,
+ EXCEPTION_EXEC_ERROR,
+ EXCEPTION_ILL_INHERIT,
+ EXCEPTION_NO_PREV_CS,
+ EXCEPTION_NO_CLASS,
+ EXCEPTION_LEX_NOT_FOUND,
+ EXCEPTION_PAD_NOT_FOUND,
+ EXCEPTION_ATTRIB_NOT_FOUND,
+ EXCEPTION_GLOBAL_NOT_FOUND,
+ EXCEPTION_EXTERNAL_ERROR,
+ EXCEPTION_METHOD_NOT_FOUND,
+ EXCEPTION_VTABLE_NOT_FOUND,
+ EXCEPTION_WRITE_TO_CONSTCLASS,
+ EXCEPTION_NOSPAWN,
+ EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
+ EXCEPTION_ERR_OVERFLOW,
+ EXCEPTION_LOSSY_CONVERSION,
+ EXCEPTION_ROLE_COMPOSITION_METHOD_CONFLICT,
+ EXCEPTION_UNEXPECTED_NULL,
+ EXCEPTION_LIBRARY_ERROR,
+ EXCEPTION_LIBRARY_NOT_LOADED,
+ EXCEPTION_SYNTAX_ERROR,
+ EXCEPTION_MALFORMED_PACKFILE,
+
+ CONTROL_RETURN,
+ CONTROL_OK,
+ CONTROL_BREAK,
+ CONTROL_CONTINUE,
+ CONTROL_ERROR,
+ CONTROL_TAKE,
+ CONTROL_LEAVE,
+
+ CONTROL_LOOP_NEXT,
+ CONTROL_LOOP_LAST,
+ CONTROL_LOOP_REDO
} exception_type_enum;
/* &end_gen */
Modified: trunk/include/parrot/multidispatch.h
==============================================================================
--- trunk/include/parrot/multidispatch.h Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/include/parrot/multidispatch.h Sun Dec 6 15:03:28 2009 (r42918)
@@ -33,9 +33,9 @@
typedef INTVAL (*mmd_f_i_pp)(PARROT_INTERP, PMC *, PMC *);
typedef struct _MMD_init {
- INTVAL func_nr;
- INTVAL left, right;
- funcptr_t func_ptr;
+ INTVAL func_nr;
+ INTVAL left, right;
+ funcptr_t func_ptr;
} MMD_init;
typedef struct _MMD_table {
@@ -45,14 +45,14 @@
} MMD_table;
typedef struct _multi_func_list {
-/* TT #646
- * This STRING ideally must be const but actually can't.
- */
- STRING *multi_name;
- STRING *short_sig;
- STRING *full_sig;
- STRING *ns_name;
- funcptr_t func_ptr;
+ /* TT #646
+ * This STRING ideally must be const but actually can't.
+ */
+ STRING *multi_name;
+ STRING *short_sig;
+ STRING *full_sig;
+ STRING *ns_name;
+ funcptr_t func_ptr;
} multi_func_list;
#define MMD_Cache Hash
Modified: trunk/include/parrot/sub.h
==============================================================================
--- trunk/include/parrot/sub.h Sun Dec 6 14:56:10 2009 (r42917)
+++ trunk/include/parrot/sub.h Sun Dec 6 15:03:28 2009 (r42918)
@@ -21,7 +21,7 @@
* Subroutine flags
*/
typedef enum {
- /* runtime usage flags */
+ /* runtime usage flags */
SUB_FLAG_CORO_FF = PObj_private0_FLAG,
SUB_FLAG_C_HANDLER = PObj_private0_FLAG, /* C exceptions only */
SUB_FLAG_TAILCALL = PObj_private2_FLAG,
More information about the parrot-commits
mailing list