Beispiel #1
0
/*
 * Write all normal global variables to an output file.
 * Note: Currently only simple types are saved.
 * Returns nonzero on error.
 */
int
writeglobals(char *name)
{
	FILE *fp;
	GLOBAL **hp;			/* hash table head address */
	register GLOBAL *sp;		/* current global symbol pointer */
	int savemode;			/* saved output mode */
	E_FUNC void math_setfp(FILE *fp);

	fp = f_open(name, "w");
	if (fp == NULL)
		return 1;
	math_setfp(fp);
	for (hp = &globalhash[HASHSIZE-1]; hp >= globalhash; hp--) {
		for (sp = *hp; sp; sp = sp->g_next) {
			switch (sp->g_value.v_type) {
			case V_NUM:
			case V_COM:
			case V_STR:
				break;
			default:
				continue;
			}
			math_fmt("%s = ", sp->g_name);
			savemode = math_setmode(MODE_HEX);
			printvalue(&sp->g_value, PRINT_UNAMBIG);
			math_setmode(savemode);
			math_str(";\n");
		}
	}
	math_setfp(stdout);
	if (fclose(fp))
		return 1;
	return 0;
}
Beispiel #2
0
/*
 * Print the elements of an object in short and unambiguous format.
 * This is the default routine if the user's is not defined.
 *
 * given:
 *	op		object being printed
 */
S_FUNC void
objprint(OBJECT *op)
{
	int count;		/* number of elements */
	int i;			/* index */

	count = op->o_actions->oa_count;
	math_fmt("obj %s {", namestr(&objectnames, op->o_actions->oa_index));
	for (i = 0; i < count; i++) {
		if (i)
			math_str(", ");
		printvalue(&op->o_table[i], PRINT_SHORT | PRINT_UNAMBIG);
	}
	math_chr('}');
}
Beispiel #3
0
/*
 * Show the list of user defined functions.
 */
void
showfunctions(void)
{
    FUNC *fp;		/* current function */
    long count;
    long index;

    count = 0;
    if (funccount > 0) {
        if (conf->resource_debug & RSCDBG_FUNC_INFO)
            math_str("Index\tName        \tArgs\tOpcodes\n"
                     "-----\t------     \t---- \t------\n");
        else
            math_str("Name\tArguments\n"
                     "----\t---------\n");
        for (index = 0; index < funccount; index++) {
            fp = functions[index];
            if (conf->resource_debug & RSCDBG_FUNC_INFO) {

                math_fmt("%5ld\t%-12s\t", index,
                         namestr(&funcnames,index));
                if (fp) {
                    count++;
                    math_fmt("%-5d\t%-5ld\n",
                             fp->f_paramcount, fp->f_opcodecount);
                } else {
                    math_str("null\t0\n");
                }
            } else {
                if (fp == NULL)
                    continue;
                count++;
                math_fmt("%-12s\t%-2d\n", namestr(&funcnames,
                                                  index), fp->f_paramcount);
            }
        }
    }
    if (conf->resource_debug & RSCDBG_FUNC_INFO) {
        math_fmt("\nNumber non-null: %ld\n", count);
        math_fmt("Number null: %ld\n", funccount - count);
        math_fmt("Total number: %ld\n", funccount);
    } else {
        if (count > 0)
            math_fmt("\nNumber: %ld\n", count);
        else
            math_str("No user functions defined\n");
    }
}