static qcint prog_enterfunction(qc_program *prog, prog_section_function *func)
{
qc_exec_stack st;
- size_t p, parampos;
+ size_t parampos;
+ int32_t p;
/* back up locals */
st.localsp = vec_size(prog->localstack);
#if defined(QCVM_EXECUTOR)
#include <math.h>
+opts_cmd_t opts;
+
const char *type_name[TYPE_COUNT] = {
"void",
"string",
"variant"
};
-bool opts_debug = false;
-bool opts_memchk = false;
-uint32_t opts_warn [1 + (COUNT_WARNINGS / 32)];
-bool opts_werror = false;
-
typedef struct {
int vtype;
const char *value;
return 0;
}
+static int qc_stof(qc_program *prog)
+{
+ qcany *str;
+ qcany num;
+ CheckArgs(1);
+ str = GetArg(0);
+ num._float = strtof(prog_getstring(prog, str->string), NULL);
+ Return(num);
+ return 0;
+}
+
static int qc_vtos(qc_program *prog)
{
char buffer[512];
&qc_vtos, /* 5 */
&qc_error, /* 6 */
&qc_vlen, /* 7 */
- &qc_etos /* 8 */
+ &qc_etos, /* 8 */
+ &qc_stof /* 9 */
};
static size_t qc_builtins_count = sizeof(qc_builtins) / sizeof(qc_builtins[0]);
size_t xflags = VMXF_DEFAULT;
bool opts_printfields = false;
bool opts_printdefs = false;
+ bool opts_printfuns = false;
bool opts_disasm = false;
bool opts_info = false;
++argv;
opts_printdefs = true;
}
+ else if (!strcmp(argv[1], "-printfuns")) {
+ --argc;
+ ++argv;
+ opts_printfuns = true;
+ }
else if (!strcmp(argv[1], "-printfields")) {
--argc;
++argv;
}
if (opts_printdefs) {
for (i = 0; i < vec_size(prog->defs); ++i) {
- printf("Global: %8s %-16s at %u\n",
+ printf("Global: %8s %-16s at %u%s\n",
type_name[prog->defs[i].type & DEF_TYPEMASK],
prog_getstring(prog, prog->defs[i].name),
- (unsigned int)prog->defs[i].offset);
+ (unsigned int)prog->defs[i].offset,
+ ((prog->defs[i].type & DEF_SAVEGLOBAL) ? " [SAVE]" : ""));
}
}
else if (opts_printfields) {
for (i = 0; i < vec_size(prog->fields); ++i) {
- printf("Field: %8s %-16s at %u\n",
+ printf("Field: %8s %-16s at %u%s\n",
type_name[prog->fields[i].type],
prog_getstring(prog, prog->fields[i].name),
- (unsigned int)prog->fields[i].offset);
+ (unsigned int)prog->fields[i].offset,
+ ((prog->fields[i].type & DEF_SAVEGLOBAL) ? " [SAVE]" : ""));
+ }
+ }
+ else if (opts_printfuns) {
+ for (i = 0; i < vec_size(prog->functions); ++i) {
+ int32_t a;
+ printf("Function: %-16s taking %i parameters:(",
+ prog_getstring(prog, prog->functions[i].name),
+ (unsigned int)prog->functions[i].nargs);
+ for (a = 0; a < prog->functions[i].nargs; ++a) {
+ printf(" %i", prog->functions[i].argsize[a]);
+ }
+ printf(") locals: %i + %i\n",
+ prog->functions[i].firstlocal,
+ prog->functions[i].locals);
}
}
else
printf("FUNCTION \"%s\"\n", prog_getstring(prog, fdef->name));
st = prog->code + fdef->entry;
- while (st->opcode != AINSTR_END) {
+ while (st->opcode != INSTR_DONE) {
prog_print_statement(prog, st);
++st;
}