mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 21:35:49 +00:00
A cleanup of the bytecode stuff.
Estimated hours taken: 2 A cleanup of the bytecode stuff. bytecode/*: Various changes to make it conform to our C coding standard. In particular: - fix indentation and layout, particularly of switch statements; - use `#include "..."' rather than `#include <...>' for user-defined header files bytecode/Mmakefile: Avoid the use of `$^' in hard-coded rules, since it is not portable to non-GNU makes (many makes only allow the use of variables such as $*, $^, etc. in suffix rules), and since it is easy to avoid. Also add an XXX comment, since the header dependency handling is done twice. bytecode/bytecode.c: s/BIG_ENDING/MR_BIG_ENDIAN/ and s/LITTLE_ENDING/MR_LITTLE_ENDIAN/, to match my recent change to runtime/conf.h.in. In fact every identifier in the bytecode directory ought to be prefixed with `MB_', but I haven't done that in this change.
This commit is contained in:
@@ -32,12 +32,15 @@ HDRS = bytecode.h disasm.h getopt.h mbi.h mem.h machine.h \
|
||||
ORIG_CS = bytecode.c disasm.c machine.c mbi.c mdis.c mem.c \
|
||||
static_data.c template.c util.c
|
||||
OBJS = $(ORIG_CS:.c=.o)
|
||||
PIC_OBJS = $(OBJS:.o=.pic_o)
|
||||
|
||||
LIBS = -lmer -lgc
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
||||
$(OBJS) $(PIC_OBJS): $(HDRS) $(MACHHDRS)
|
||||
# XXX if we're using makedepend, this line shouldn't be needed
|
||||
|
||||
$(OBJS) $(PIC_OBJS): $(HDRS)
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
||||
@@ -45,11 +48,15 @@ $(OBJS) $(PIC_OBJS): $(HDRS) $(MACHHDRS)
|
||||
|
||||
all: mdis mbi
|
||||
|
||||
mdis: bytecode.o disasm.o mdis.o mem.o util.o
|
||||
$(MGNUC) $(CFLAGS) -o mdis $^ $(LIBPATH) $(LIBS)
|
||||
MDIS_OBJS = bytecode.o disasm.o mdis.o mem.o util.o
|
||||
mdis: $(MDIS_OBJS)
|
||||
$(MGNUC) $(CFLAGS) -o mdis $(MDIS_OBJS) $(LIBPATH) $(LIBS)
|
||||
|
||||
mbi: bytecode.o mbi.o mem.o util.o
|
||||
$(MGNUC) $(CFLAGS) -o mbi $^ $(LIBPATH) $(LIBS)
|
||||
MBI_OBJS = bytecode.o mbi.o mem.o util.o
|
||||
mbi: $(MBI_OBJS)
|
||||
$(MGNUC) $(CFLAGS) -o mbi $(MBI_OBJS) $(LIBPATH) $(LIBS)
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
|
||||
tags: $(ORIG_CS)
|
||||
ctags $(ORIG_CS)
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
** This file may only be copied under the terms of the GNU Library General
|
||||
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
**
|
||||
** $Id: bytecode.h,v 1.9 1997-04-24 05:30:38 aet Exp $
|
||||
** $Id: bytecode.h,v 1.10 1997-04-26 03:16:04 fjh Exp $
|
||||
*/
|
||||
|
||||
#if ! defined(BYTECODE_H)
|
||||
#ifndef BYTECODE_H
|
||||
#define BYTECODE_H
|
||||
|
||||
#include <conf.h>
|
||||
#include <mercury_types.h>
|
||||
#include <mercury_float.h>
|
||||
#include <gc.h>
|
||||
#include "conf.h"
|
||||
#include "mercury_types.h"
|
||||
#include "mercury_float.h"
|
||||
#include "gc.h"
|
||||
|
||||
/*
|
||||
* XXX: We should make bytecode portable from platform to platform.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
** This file may only be copied under the terms of the GNU Library General
|
||||
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
**
|
||||
** $Id: disasm.c,v 1.11 1997-04-24 05:30:42 aet Exp $
|
||||
** $Id: disasm.c,v 1.12 1997-04-26 03:16:05 fjh Exp $
|
||||
*/
|
||||
|
||||
/* Imports */
|
||||
@@ -13,15 +13,15 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <util.h>
|
||||
#include <mem.h>
|
||||
#include <bytecode.h>
|
||||
#include <disasm.h>
|
||||
#include "util.h"
|
||||
#include "mem.h"
|
||||
#include "bytecode.h"
|
||||
#include "disasm.h"
|
||||
|
||||
/* Local declarations */
|
||||
|
||||
static char
|
||||
rcs_id[] = "$Id: disasm.c,v 1.11 1997-04-24 05:30:42 aet Exp $";
|
||||
rcs_id[] = "$Id: disasm.c,v 1.12 1997-04-26 03:16:05 fjh Exp $";
|
||||
|
||||
static void
|
||||
print_bytecode(Bytecode bytecode);
|
||||
@@ -66,22 +66,18 @@ disassemble(FILE* fp)
|
||||
Bytecode bytecode;
|
||||
|
||||
/* Read two-byte version number */
|
||||
if (read_bytecode_version_number(fp, &bytecode_version_number))
|
||||
{
|
||||
if (read_bytecode_version_number(fp, &bytecode_version_number)) {
|
||||
printf("bytecode_version %d\n", bytecode_version_number);
|
||||
/* XXX: We should check the version number is
|
||||
** what we expect. Should use major and minor version
|
||||
** numbers? Should use a magic number?
|
||||
** Should have the module name in the bytecode.
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fatal("Failed to read bytecode version number");
|
||||
}
|
||||
|
||||
while (read_bytecode(fp, &bytecode))
|
||||
{
|
||||
while (read_bytecode(fp, &bytecode)) {
|
||||
print_bytecode(bytecode);
|
||||
/*
|
||||
** XXX: should free any heap data in the bytecode here
|
||||
@@ -97,149 +93,103 @@ print_bytecode(Bytecode bc)
|
||||
{
|
||||
printf("%s", bytecode_to_name(bc.id));
|
||||
|
||||
switch (bc.id)
|
||||
{
|
||||
case BC_enter_pred:
|
||||
printf(" %s %d", bc.opt.enter_pred.pred_name,
|
||||
bc.opt.enter_pred.proc_count);
|
||||
break;
|
||||
case BC_endof_pred:
|
||||
{
|
||||
switch (bc.id) {
|
||||
case BC_enter_pred:
|
||||
printf(" %s %d", bc.opt.enter_pred.pred_name,
|
||||
bc.opt.enter_pred.proc_count);
|
||||
break;
|
||||
case BC_endof_pred:
|
||||
/* No args */
|
||||
}
|
||||
break;
|
||||
case BC_enter_proc:
|
||||
{
|
||||
Short i;
|
||||
Short len;
|
||||
break;
|
||||
case BC_enter_proc: {
|
||||
Short i;
|
||||
Short len;
|
||||
|
||||
printf(" %d %s %d %d %d",
|
||||
bc.opt.enter_proc.proc_id,
|
||||
determinism_to_name(bc.opt.enter_proc.det),
|
||||
bc.opt.enter_proc.label_count,
|
||||
bc.opt.enter_proc.temp_count,
|
||||
bc.opt.enter_proc.list_length);
|
||||
len = bc.opt.enter_proc.list_length;
|
||||
for (i=0; i < len; i++)
|
||||
{
|
||||
printf(" %s",
|
||||
bc.opt.enter_proc.
|
||||
var_info_list[i]);
|
||||
printf(" %d %s %d %d %d",
|
||||
bc.opt.enter_proc.proc_id,
|
||||
determinism_to_name(bc.opt.enter_proc.det),
|
||||
bc.opt.enter_proc.label_count,
|
||||
bc.opt.enter_proc.temp_count,
|
||||
bc.opt.enter_proc.list_length);
|
||||
len = bc.opt.enter_proc.list_length;
|
||||
for (i = 0; i < len; i++) {
|
||||
printf(" %s",
|
||||
bc.opt.enter_proc.
|
||||
var_info_list[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BC_endof_proc:
|
||||
{
|
||||
case BC_endof_proc:
|
||||
/* No args */
|
||||
}
|
||||
break;
|
||||
case BC_label:
|
||||
{
|
||||
break;
|
||||
case BC_label:
|
||||
printf(" %d", bc.opt.label.label);
|
||||
}
|
||||
break;
|
||||
case BC_enter_disjunction:
|
||||
{
|
||||
break;
|
||||
case BC_enter_disjunction:
|
||||
printf(" %d", bc.opt.enter_disjunction.end_label);
|
||||
}
|
||||
break;
|
||||
case BC_endof_disjunction:
|
||||
{
|
||||
break;
|
||||
case BC_endof_disjunction:
|
||||
/* No args */
|
||||
}
|
||||
break;
|
||||
case BC_enter_disjunct:
|
||||
{
|
||||
break;
|
||||
case BC_enter_disjunct:
|
||||
printf(" %d", bc.opt.enter_disjunct.next_label);
|
||||
}
|
||||
break;
|
||||
case BC_endof_disjunct:
|
||||
{
|
||||
break;
|
||||
case BC_endof_disjunct:
|
||||
printf(" %d", bc.opt.endof_disjunct.label);
|
||||
}
|
||||
break;
|
||||
case BC_enter_switch:
|
||||
{
|
||||
break;
|
||||
case BC_enter_switch:
|
||||
printf(" %d %d", bc.opt.enter_switch.var,
|
||||
bc.opt.enter_switch.end_label
|
||||
);
|
||||
}
|
||||
break;
|
||||
case BC_endof_switch:
|
||||
{
|
||||
break;
|
||||
case BC_endof_switch:
|
||||
/* No args */
|
||||
}
|
||||
break;
|
||||
case BC_enter_switch_arm:
|
||||
{
|
||||
break;
|
||||
case BC_enter_switch_arm:
|
||||
printf(" ");
|
||||
print_cons_id(bc.opt.enter_switch_arm.cons_id);
|
||||
printf(" %d", bc.opt.enter_switch_arm.next_label);
|
||||
}
|
||||
break;
|
||||
case BC_endof_switch_arm:
|
||||
{
|
||||
break;
|
||||
case BC_endof_switch_arm:
|
||||
printf(" %d", bc.opt.endof_switch_arm.label);
|
||||
}
|
||||
break;
|
||||
case BC_enter_if:
|
||||
{
|
||||
break;
|
||||
case BC_enter_if:
|
||||
printf(" %d %d %d",
|
||||
bc.opt.enter_if.else_label,
|
||||
bc.opt.enter_if.end_label,
|
||||
bc.opt.enter_if.frame_ptr_tmp);
|
||||
}
|
||||
break;
|
||||
case BC_enter_then:
|
||||
{
|
||||
break;
|
||||
case BC_enter_then:
|
||||
printf(" %d", bc.opt.enter_then.frame_ptr_tmp);
|
||||
}
|
||||
break;
|
||||
case BC_endof_then:
|
||||
{
|
||||
break;
|
||||
case BC_endof_then:
|
||||
printf(" %d", bc.opt.endof_then.follow_label);
|
||||
}
|
||||
break;
|
||||
case BC_endof_if:
|
||||
{
|
||||
break;
|
||||
case BC_endof_if:
|
||||
/* No args */
|
||||
}
|
||||
break;
|
||||
case BC_enter_negation:
|
||||
{
|
||||
break;
|
||||
case BC_enter_negation:
|
||||
printf(" %d", bc.opt.enter_negation.end_label);
|
||||
}
|
||||
break;
|
||||
case BC_endof_negation:
|
||||
{
|
||||
break;
|
||||
case BC_endof_negation:
|
||||
/* No args */
|
||||
}
|
||||
break;
|
||||
case BC_enter_commit:
|
||||
{
|
||||
break;
|
||||
case BC_enter_commit:
|
||||
printf(" %d", bc.opt.enter_commit.temp);
|
||||
}
|
||||
break;
|
||||
case BC_endof_commit:
|
||||
{
|
||||
break;
|
||||
case BC_endof_commit:
|
||||
printf(" %d", bc.opt.endof_commit.temp);
|
||||
}
|
||||
break;
|
||||
case BC_assign:
|
||||
{
|
||||
break;
|
||||
case BC_assign:
|
||||
printf(" %d %d", bc.opt.assign.to_var,
|
||||
bc.opt.assign.from_var);
|
||||
}
|
||||
break;
|
||||
case BC_test:
|
||||
{
|
||||
break;
|
||||
case BC_test:
|
||||
printf(" %d %d",
|
||||
bc.opt.test.var1,
|
||||
bc.opt.test.var2);
|
||||
}
|
||||
break;
|
||||
case BC_construct:
|
||||
{
|
||||
break;
|
||||
case BC_construct: {
|
||||
Short len;
|
||||
Short i;
|
||||
|
||||
@@ -247,16 +197,14 @@ print_bytecode(Bytecode bc)
|
||||
print_cons_id(bc.opt.construct.consid);
|
||||
len = bc.opt.construct.list_length;
|
||||
printf(" %d", len);
|
||||
for (i=0; i < len; i++)
|
||||
{
|
||||
for (i = 0; i < len; i++) {
|
||||
printf(" %d",
|
||||
bc.opt.construct.var_list[i]);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case BC_deconstruct:
|
||||
{
|
||||
case BC_deconstruct: {
|
||||
Short len;
|
||||
Short i;
|
||||
|
||||
@@ -264,16 +212,14 @@ print_bytecode(Bytecode bc)
|
||||
print_cons_id(bc.opt.deconstruct.consid);
|
||||
len = bc.opt.deconstruct.list_length;
|
||||
printf(" %d", len);
|
||||
for (i=0; i < len; i++)
|
||||
{
|
||||
for (i = 0; i < len; i++) {
|
||||
printf(" %d",
|
||||
bc.opt.deconstruct.var_list[i]);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case BC_complex_construct:
|
||||
{
|
||||
case BC_complex_construct: {
|
||||
Short len;
|
||||
Short i;
|
||||
|
||||
@@ -281,16 +227,14 @@ print_bytecode(Bytecode bc)
|
||||
print_cons_id(bc.opt.complex_construct.consid);
|
||||
len = bc.opt.complex_construct.list_length;
|
||||
printf(" %d", len);
|
||||
for (i=0; i < len; i++)
|
||||
{
|
||||
for (i = 0; i < len; i++) {
|
||||
printf(" ");
|
||||
print_var_dir(bc.opt.complex_construct.
|
||||
var_dir_list[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case BC_complex_deconstruct:
|
||||
{
|
||||
case BC_complex_deconstruct: {
|
||||
Short len;
|
||||
Short i;
|
||||
|
||||
@@ -298,137 +242,101 @@ print_bytecode(Bytecode bc)
|
||||
print_cons_id(bc.opt.complex_deconstruct.consid);
|
||||
len = bc.opt.complex_deconstruct.list_length;
|
||||
printf(" %d", len);
|
||||
for (i=0; i < len; i++)
|
||||
{
|
||||
for (i = 0; i < len; i++) {
|
||||
printf(" ");
|
||||
print_var_dir(bc.opt.complex_deconstruct.
|
||||
var_dir_list[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case BC_place_arg:
|
||||
{
|
||||
case BC_place_arg:
|
||||
printf(" %d %d", bc.opt.place_arg.to_reg,
|
||||
bc.opt.place_arg.from_var);
|
||||
}
|
||||
break;
|
||||
case BC_pickup_arg:
|
||||
{
|
||||
break;
|
||||
case BC_pickup_arg:
|
||||
printf(" %d %d", bc.opt.pickup_arg.from_reg,
|
||||
bc.opt.pickup_arg.to_var);
|
||||
}
|
||||
break;
|
||||
case BC_call:
|
||||
{
|
||||
break;
|
||||
case BC_call:
|
||||
printf(" %s %s %d %d",
|
||||
bc.opt.call.module_id,
|
||||
bc.opt.call.pred_id,
|
||||
bc.opt.call.arity,
|
||||
bc.opt.call.proc_id);
|
||||
}
|
||||
break;
|
||||
case BC_higher_order_call:
|
||||
{
|
||||
break;
|
||||
case BC_higher_order_call:
|
||||
printf(" %d %d %d %s",
|
||||
bc.opt.higher_order_call.pred_var,
|
||||
bc.opt.higher_order_call.in_var_count,
|
||||
bc.opt.higher_order_call.out_var_count,
|
||||
determinism_to_name(bc.opt.
|
||||
higher_order_call.det));
|
||||
}
|
||||
break;
|
||||
case BC_builtin_binop:
|
||||
{
|
||||
break;
|
||||
case BC_builtin_binop:
|
||||
printf(" %s ",
|
||||
binop_to_name(bc.opt.builtin_binop.binop));
|
||||
print_op_arg(bc.opt.builtin_binop.arg1);
|
||||
printf(" ");
|
||||
print_op_arg(bc.opt.builtin_binop.arg2);
|
||||
printf(" %d", bc.opt.builtin_binop.to_var);
|
||||
}
|
||||
break;
|
||||
case BC_builtin_unop:
|
||||
{
|
||||
break;
|
||||
case BC_builtin_unop:
|
||||
printf(" %s ",
|
||||
unop_to_name(bc.opt.builtin_unop.unop));
|
||||
print_op_arg(bc.opt.builtin_unop.arg);
|
||||
printf(" %d", bc.opt.builtin_unop.to_var);
|
||||
}
|
||||
break;
|
||||
case BC_builtin_bintest:
|
||||
{
|
||||
break;
|
||||
case BC_builtin_bintest:
|
||||
printf(" %s ",
|
||||
binop_to_name(bc.opt.builtin_bintest.binop));
|
||||
print_op_arg(bc.opt.builtin_binop.arg1);
|
||||
printf(" ");
|
||||
print_op_arg(bc.opt.builtin_binop.arg2);
|
||||
}
|
||||
break;
|
||||
case BC_builtin_untest:
|
||||
{
|
||||
break;
|
||||
case BC_builtin_untest:
|
||||
printf(" %s ",
|
||||
unop_to_name(bc.opt.builtin_untest.unop));
|
||||
print_op_arg(bc.opt.builtin_unop.arg);
|
||||
}
|
||||
break;
|
||||
case BC_semidet_succeed:
|
||||
{
|
||||
break;
|
||||
case BC_semidet_succeed:
|
||||
/* No args */
|
||||
}
|
||||
break;
|
||||
case BC_semidet_success_check:
|
||||
{
|
||||
break;
|
||||
case BC_semidet_success_check:
|
||||
/* No args */
|
||||
}
|
||||
break;
|
||||
case BC_fail:
|
||||
{
|
||||
break;
|
||||
case BC_fail:
|
||||
/* No args */
|
||||
}
|
||||
break;
|
||||
case BC_context:
|
||||
{
|
||||
break;
|
||||
case BC_context:
|
||||
printf(" %d", bc.opt.context.line_number);
|
||||
}
|
||||
break;
|
||||
case BC_not_supported:
|
||||
{
|
||||
break;
|
||||
case BC_not_supported:
|
||||
/* No args */
|
||||
}
|
||||
break;
|
||||
case BC_noop:
|
||||
{
|
||||
break;
|
||||
case BC_noop:
|
||||
/* No args */
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
break;
|
||||
default:
|
||||
assert(FALSE); /*XXX*/
|
||||
}
|
||||
break;
|
||||
break;
|
||||
} /* switch */
|
||||
|
||||
putchar('\n');
|
||||
|
||||
return;
|
||||
} /* print_bytecode */
|
||||
|
||||
|
||||
static void
|
||||
print_cons_id(Cons_id cons_id)
|
||||
{
|
||||
switch (cons_id.id)
|
||||
{
|
||||
case CONSID_CONS:
|
||||
{
|
||||
switch (cons_id.id) {
|
||||
case CONSID_CONS:
|
||||
printf("functor %s %s ", cons_id.opt.cons.module_id,
|
||||
cons_id.opt.cons.string);
|
||||
printf("%d ", cons_id.opt.cons.arity);
|
||||
print_tag(cons_id.opt.cons.tag);
|
||||
}
|
||||
break;
|
||||
case CONSID_INT_CONST:
|
||||
{
|
||||
break;
|
||||
case CONSID_INT_CONST:
|
||||
/*
|
||||
** (This comment is labelled "CAST COMMENT".
|
||||
** If you remove this comment, also
|
||||
@@ -443,39 +351,29 @@ print_cons_id(Cons_id cons_id)
|
||||
** format string for Integer in conf.h.
|
||||
*/
|
||||
printf("int_const %ld", (long) cons_id.opt.int_const);
|
||||
}
|
||||
break;
|
||||
case CONSID_STRING_CONST:
|
||||
{
|
||||
break;
|
||||
case CONSID_STRING_CONST:
|
||||
printf("string_const \"%s\"",
|
||||
quote_cstring(cons_id.opt.string_const));
|
||||
}
|
||||
break;
|
||||
case CONSID_FLOAT_CONST:
|
||||
{
|
||||
break;
|
||||
case CONSID_FLOAT_CONST:
|
||||
printf("float_const %.15g", cons_id.opt.float_const);
|
||||
}
|
||||
break;
|
||||
case CONSID_PRED_CONST:
|
||||
{
|
||||
break;
|
||||
case CONSID_PRED_CONST:
|
||||
printf("%s", "pred_const ");
|
||||
printf("%s ", cons_id.opt.pred_const.module_id);
|
||||
printf("%s ", cons_id.opt.pred_const.pred_id);
|
||||
printf("%d ", cons_id.opt.pred_const.arity);
|
||||
printf("%d ", cons_id.opt.pred_const.proc_id);
|
||||
}
|
||||
break;
|
||||
case CONSID_CODE_ADDR_CONST:
|
||||
{
|
||||
break;
|
||||
case CONSID_CODE_ADDR_CONST:
|
||||
printf("%s", "code_addr_const ");
|
||||
printf("%s ", cons_id.opt.code_addr_const.module_id);
|
||||
printf("%s ", cons_id.opt.code_addr_const.pred_id);
|
||||
printf("%d ", cons_id.opt.code_addr_const.arity);
|
||||
printf("%d ", cons_id.opt.code_addr_const.proc_id);
|
||||
}
|
||||
break;
|
||||
case CONSID_BASE_TYPE_INFO_CONST:
|
||||
{
|
||||
break;
|
||||
case CONSID_BASE_TYPE_INFO_CONST:
|
||||
printf("%s", "base_type_info_const ");
|
||||
printf("%s ", cons_id.opt.base_type_info_const
|
||||
.module_id);
|
||||
@@ -483,122 +381,90 @@ print_cons_id(Cons_id cons_id)
|
||||
type_name);
|
||||
printf("%d ", cons_id.opt.base_type_info_const.
|
||||
type_arity);
|
||||
}
|
||||
break;
|
||||
case CONSID_CHAR_CONST:
|
||||
{
|
||||
break;
|
||||
case CONSID_CHAR_CONST:
|
||||
printf("%s", "char_const ");
|
||||
/* XXX : fix so that char is printed sensibly */
|
||||
printf("'%c'", cons_id.opt.char_const.ch);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
break;
|
||||
default:
|
||||
assert(FALSE); /*XXX*/
|
||||
}
|
||||
break;
|
||||
} /* switch */
|
||||
return;
|
||||
} /* print_cons_id */
|
||||
break;
|
||||
} /* end switch */
|
||||
} /* end print_cons_id() */
|
||||
|
||||
static void
|
||||
print_tag(Tag tag)
|
||||
{
|
||||
switch (tag.id)
|
||||
{
|
||||
case TAG_SIMPLE:
|
||||
{
|
||||
switch (tag.id) {
|
||||
case TAG_SIMPLE:
|
||||
printf("%s %d", "simple_tag", tag.opt.primary);
|
||||
}
|
||||
break;
|
||||
case TAG_COMPLICATED:
|
||||
{
|
||||
break;
|
||||
case TAG_COMPLICATED:
|
||||
/*
|
||||
** See comment labelled "CAST COMMENT".
|
||||
*/
|
||||
printf("%s %d %ld", "complicated_tag",
|
||||
tag.opt.pair.primary,
|
||||
(long) tag.opt.pair.secondary);
|
||||
}
|
||||
break;
|
||||
case TAG_COMPLICATED_CONSTANT:
|
||||
{
|
||||
break;
|
||||
case TAG_COMPLICATED_CONSTANT:
|
||||
/*
|
||||
** See comment labelled "CAST COMMENT".
|
||||
*/
|
||||
printf("%s %d %ld", "complicated_constant_tag",
|
||||
tag.opt.pair.primary,
|
||||
(long) tag.opt.pair.secondary);
|
||||
}
|
||||
break;
|
||||
case TAG_ENUM:
|
||||
{
|
||||
break;
|
||||
case TAG_ENUM:
|
||||
printf("%s %d", "enum_tag", tag.opt.enum_tag);
|
||||
}
|
||||
break;
|
||||
case TAG_NONE:
|
||||
{
|
||||
break;
|
||||
case TAG_NONE:
|
||||
printf("%s", "no_tag");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "ERROR: invalid tag: %d\n",
|
||||
tag.id);
|
||||
assert(FALSE); /*XXX*/
|
||||
}
|
||||
break;
|
||||
} /* switch */
|
||||
return;
|
||||
} /* print_tag */
|
||||
break;
|
||||
} /* end switch */
|
||||
} /* end print_tag() */
|
||||
|
||||
static void
|
||||
print_var_dir(Var_dir var_dir)
|
||||
{
|
||||
printf("<<var_dir>>"); /* XXX */
|
||||
return;
|
||||
} /* print_var_dir */
|
||||
} /* end print_var_dir() */
|
||||
|
||||
static void
|
||||
print_op_arg(Op_arg op_arg)
|
||||
{
|
||||
switch (op_arg.id)
|
||||
{
|
||||
case ARG_VAR:
|
||||
{
|
||||
switch (op_arg.id) {
|
||||
case ARG_VAR:
|
||||
printf("var %d", op_arg.opt.var);
|
||||
}
|
||||
break;
|
||||
case ARG_INT_CONST:
|
||||
{
|
||||
break;
|
||||
case ARG_INT_CONST:
|
||||
/*
|
||||
** See comment labelled "CAST COMMENT".
|
||||
*/
|
||||
printf("int %ld", (long) op_arg.opt.int_const);
|
||||
}
|
||||
break;
|
||||
case ARG_FLOAT_CONST:
|
||||
{
|
||||
break;
|
||||
case ARG_FLOAT_CONST:
|
||||
printf("float %f", op_arg.opt.float_const);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
break;
|
||||
default:
|
||||
assert(FALSE); /*XXX*/
|
||||
}
|
||||
break;
|
||||
} /* switch */
|
||||
|
||||
return;
|
||||
} /* print_op_arg */
|
||||
break;
|
||||
} /* end switch */
|
||||
} /* end print_op_arg() */
|
||||
|
||||
|
||||
/*
|
||||
** XXX: Currently we depend on the order of elements in the table.
|
||||
*/
|
||||
static const char*
|
||||
bytecode_table[] =
|
||||
{
|
||||
bytecode_table[] = {
|
||||
"enter_pred",
|
||||
"endof_pred",
|
||||
"enter_proc",
|
||||
@@ -639,17 +505,14 @@ bytecode_table[] =
|
||||
"fail",
|
||||
"context",
|
||||
"not_supported"
|
||||
};
|
||||
};
|
||||
|
||||
static const char*
|
||||
bytecode_to_name(Byte bytecode_id)
|
||||
{
|
||||
if (bytecode_id >= sizeof(bytecode_table) / sizeof(CString))
|
||||
{
|
||||
if (bytecode_id >= sizeof(bytecode_table) / sizeof(CString)) {
|
||||
return "<<unknown bytecode>>"; /*XXX*/
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return bytecode_table[bytecode_id];
|
||||
}
|
||||
}
|
||||
@@ -658,8 +521,7 @@ bytecode_to_name(Byte bytecode_id)
|
||||
** XXX: Currently we depend on the order of elements in the table.
|
||||
*/
|
||||
static const char*
|
||||
determinism_table[] =
|
||||
{
|
||||
determinism_table[] = {
|
||||
"det",
|
||||
"semidet",
|
||||
"multidet",
|
||||
@@ -668,7 +530,7 @@ determinism_table[] =
|
||||
"cc_nondet",
|
||||
"erroneous",
|
||||
"failure"
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
** Return a const string
|
||||
@@ -676,12 +538,9 @@ determinism_table[] =
|
||||
static const char*
|
||||
determinism_to_name(Byte determinism_id)
|
||||
{
|
||||
if (determinism_id >= sizeof(determinism_table) / sizeof(CString))
|
||||
{
|
||||
if (determinism_id >= sizeof(determinism_table) / sizeof(CString)) {
|
||||
return "<<unknown determinism>>"; /*XXX*/
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return determinism_table[determinism_id];
|
||||
}
|
||||
}
|
||||
@@ -732,12 +591,9 @@ static const char*
|
||||
binop_to_name(Byte binop)
|
||||
{
|
||||
/* bounds check */
|
||||
if (binop >= sizeof(binop_table) / sizeof(CString))
|
||||
{
|
||||
if (binop >= sizeof(binop_table) / sizeof(CString)) {
|
||||
return "<<unknown binop>>"; /*XXX*/
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return binop_table[binop];
|
||||
}
|
||||
} /* binop_to_name */
|
||||
@@ -763,12 +619,9 @@ static const char*
|
||||
unop_to_name(Byte unop)
|
||||
{
|
||||
/* bounds check */
|
||||
if (unop >= sizeof(unop_table) / sizeof(CString))
|
||||
{
|
||||
if (unop >= sizeof(unop_table) / sizeof(CString)) {
|
||||
return "<<unknown unop>>"; /*XXX*/
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return unop_table[unop];
|
||||
}
|
||||
} /* unop_to_name */
|
||||
@@ -789,17 +642,14 @@ quote_cstring(CString str)
|
||||
int j; /* index into str_s */
|
||||
|
||||
/* Allocate initial static string */
|
||||
if (NULL == str_s)
|
||||
{
|
||||
if (NULL == str_s) {
|
||||
str_s = malloc(sizeof(char) * str_size_s);
|
||||
}
|
||||
|
||||
i = j = 0;
|
||||
for (;;)
|
||||
{
|
||||
for (;;) {
|
||||
/* Check our static string is big enough */
|
||||
if (i+2 > str_size_s)
|
||||
{
|
||||
if (i+2 > str_size_s) {
|
||||
str_size_s *= 2; /* Double buffer size */
|
||||
str_s = realloc(str_s, str_size_s * sizeof(char));
|
||||
assert(str_s != NULL); /* XXX */
|
||||
@@ -812,28 +662,22 @@ quote_cstring(CString str)
|
||||
** quoted. There is no mention of other limitations
|
||||
** on what characters may be within a string literal.
|
||||
*/
|
||||
switch(str[i])
|
||||
{
|
||||
/* following two cases are identical */
|
||||
case '\\':
|
||||
case '\"':
|
||||
{
|
||||
switch(str[i]) {
|
||||
/* following two cases are identical */
|
||||
case '\\':
|
||||
case '\"':
|
||||
str_s[j] = '\\';
|
||||
str_s[j+1] = str[i];
|
||||
j += 2;
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
case '\n':
|
||||
{
|
||||
break;
|
||||
case '\n':
|
||||
str_s[j] = '\\';
|
||||
str_s[j+1] = 'n';
|
||||
j += 2;
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
case '\0':
|
||||
{
|
||||
break;
|
||||
case '\0': {
|
||||
CString ret_str;
|
||||
|
||||
str_s[j] = '\0';
|
||||
@@ -842,16 +686,13 @@ quote_cstring(CString str)
|
||||
strcpy(ret_str, str_s);
|
||||
return ret_str;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
default:
|
||||
str_s[j] = str[i];
|
||||
j++;
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
} /* switch */
|
||||
} /* for */
|
||||
} /* quote_cstring */
|
||||
break;
|
||||
} /* end switch */
|
||||
} /* end for */
|
||||
} /* end quote_cstring() */
|
||||
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
** This file may only be copied under the terms of the GNU Library General
|
||||
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
**
|
||||
** $Id: disasm.h,v 1.4 1997-04-24 05:30:46 aet Exp $
|
||||
** $Id: disasm.h,v 1.5 1997-04-26 03:16:07 fjh Exp $
|
||||
*/
|
||||
|
||||
#if ! defined(DISASM_H)
|
||||
#ifndef DISASM_H
|
||||
#define DISASM_H
|
||||
|
||||
|
||||
|
||||
@@ -3,24 +3,21 @@
|
||||
** This file may only be copied under the terms of the GNU Library General
|
||||
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
**
|
||||
** $Id: machine.c,v 1.3 1997-04-24 05:30:49 aet Exp $
|
||||
** $Id: machine.c,v 1.4 1997-04-26 03:16:08 fjh Exp $
|
||||
*/
|
||||
|
||||
/* Imports */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <util.h>
|
||||
#include <mem.h>
|
||||
#include <bytecode.h>
|
||||
#include <machine.h>
|
||||
#include "machine.h"
|
||||
|
||||
/* Exported definitions */
|
||||
|
||||
/* Local declarations */
|
||||
|
||||
static char
|
||||
rcs_id[] = "$Id: machine.c,v 1.3 1997-04-24 05:30:49 aet Exp $";
|
||||
rcs_id[] = "$Id: machine.c,v 1.4 1997-04-26 03:16:08 fjh Exp $";
|
||||
|
||||
/* Implementation */
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
** This file may only be copied under the terms of the GNU Library General
|
||||
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
**
|
||||
** $Id: machine.h,v 1.3 1997-04-24 05:30:52 aet Exp $
|
||||
** $Id: machine.h,v 1.4 1997-04-26 03:16:08 fjh Exp $
|
||||
*/
|
||||
|
||||
#if ! defined(MACHINE_H)
|
||||
#ifndef MACHINE_H
|
||||
#define MACHINE_H
|
||||
|
||||
#define MAX_REGISTERS 40
|
||||
|
||||
@@ -3,23 +3,24 @@
|
||||
** This file may only be copied under the terms of the GNU Library General
|
||||
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
**
|
||||
** $Id: mbi.c,v 1.5 1997-04-24 05:30:54 aet Exp $
|
||||
** $Id: mbi.c,v 1.6 1997-04-26 03:16:09 fjh Exp $
|
||||
*/
|
||||
|
||||
/* Imports */
|
||||
|
||||
/*
|
||||
** Interface to Mercury runtime must be included first.
|
||||
*/
|
||||
#include <imp.h>
|
||||
#include "imp.h"
|
||||
|
||||
/* Imports */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include <util.h>
|
||||
#include <mem.h>
|
||||
#include <mbi.h>
|
||||
#include "util.h"
|
||||
#include "mem.h"
|
||||
#include "mbi.h"
|
||||
|
||||
|
||||
/* Exports */
|
||||
@@ -28,7 +29,7 @@
|
||||
/* Local declarations */
|
||||
|
||||
static char
|
||||
rcs_id[] = "$Id: mbi.c,v 1.5 1997-04-24 05:30:54 aet Exp $";
|
||||
rcs_id[] = "$Id: mbi.c,v 1.6 1997-04-26 03:16:09 fjh Exp $";
|
||||
|
||||
static void
|
||||
usage(void);
|
||||
@@ -40,7 +41,7 @@ program_name = NULL;
|
||||
|
||||
#if ! defined(UNIT_TESTING)
|
||||
|
||||
void
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
int c;
|
||||
@@ -52,37 +53,31 @@ main(int argc, char* argv[])
|
||||
opterr = 0;
|
||||
|
||||
/* Read options */
|
||||
while ((c = getopt(argc,argv,"h")) != EOF)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'h':
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
exit(EXIT_FAILURE);
|
||||
break;
|
||||
while ((c = getopt(argc,argv,"h")) != EOF) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
exit(EXIT_FAILURE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* We _must_ have a file argument */
|
||||
if (optind == argc)
|
||||
{
|
||||
if (optind == argc) {
|
||||
usage();
|
||||
}
|
||||
else /* Process each bytecode file in order */
|
||||
{
|
||||
} else {
|
||||
/* Process each bytecode file in order */
|
||||
int i;
|
||||
char *filename;
|
||||
FILE *fp;
|
||||
|
||||
for (i=optind; i < argc; i++)
|
||||
{
|
||||
for (i = optind; i < argc; i++) {
|
||||
filename = argv[i];
|
||||
if ((fp = fopen(filename, "r")) != NULL)
|
||||
{
|
||||
if ((fp = fopen(filename, "r")) != NULL) {
|
||||
#if 0
|
||||
if (is bytecode file) /* file ext = .mb */
|
||||
{
|
||||
@@ -94,39 +89,32 @@ main(int argc, char* argv[])
|
||||
{
|
||||
do a dlopen and add to list
|
||||
of shlibs.
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
error: wrong file extension
|
||||
}
|
||||
|
||||
#endif /* 0 */
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* XXX: Give better error message */
|
||||
util_error("can not open file \"%s\"",
|
||||
filename);
|
||||
}
|
||||
} /* for */
|
||||
} /* end for */
|
||||
|
||||
/*
|
||||
* XXX: Now start the bytecode interpreter
|
||||
* Fire up the read-eval-print loop?
|
||||
*/
|
||||
|
||||
} /* else */
|
||||
} /* end else */
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
} /* main */
|
||||
} /* end main() */
|
||||
|
||||
#endif /* ! UNIT_TESTING */
|
||||
|
||||
void
|
||||
usage()
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [-h] files\n", program_name
|
||||
);
|
||||
return;
|
||||
fprintf(stderr, "Usage: %s [-h] files\n", program_name);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
** This file may only be copied under the terms of the GNU Library General
|
||||
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
**
|
||||
** $Id: mbi.h,v 1.3 1997-04-24 05:30:57 aet Exp $
|
||||
** $Id: mbi.h,v 1.4 1997-04-26 03:16:10 fjh Exp $
|
||||
*/
|
||||
|
||||
#if ! defined(MBI_H)
|
||||
#ifndef MBI_H
|
||||
#define MBI_H
|
||||
|
||||
#endif /* ! MBI_H */
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
** This file may only be copied under the terms of the GNU Library General
|
||||
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
**
|
||||
** $Id: mdis.c,v 1.4 1997-04-24 05:31:01 aet Exp $
|
||||
** $Id: mdis.c,v 1.5 1997-04-26 03:16:11 fjh Exp $
|
||||
*/
|
||||
|
||||
/* Imports */
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <mdis.h>
|
||||
|
||||
static char
|
||||
rcs_id[] = "$Id: mdis.c,v 1.4 1997-04-24 05:31:01 aet Exp $";
|
||||
rcs_id[] = "$Id: mdis.c,v 1.5 1997-04-26 03:16:11 fjh Exp $";
|
||||
|
||||
/* Local declarations */
|
||||
static void
|
||||
@@ -31,7 +31,7 @@ program_name = NULL;
|
||||
|
||||
#if ! defined(UNIT_TESTING)
|
||||
|
||||
void
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
int c;
|
||||
@@ -43,58 +43,47 @@ main(int argc, char* argv[])
|
||||
opterr = 0;
|
||||
|
||||
/* Read options */
|
||||
while ((c = getopt(argc,argv,"h")) != EOF)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'h':
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
exit(EXIT_FAILURE);
|
||||
break;
|
||||
while ((c = getopt(argc,argv,"h")) != EOF) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
usage();
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
exit(EXIT_FAILURE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If no arguments, then assume bytecode stream is on stdin */
|
||||
if (optind == argc)
|
||||
{
|
||||
if (optind == argc) {
|
||||
disassemble(stdin);
|
||||
}
|
||||
else /* Process each bytecode file in order */
|
||||
{
|
||||
} else {
|
||||
/* Process each bytecode file in order */
|
||||
int i;
|
||||
char *filename;
|
||||
FILE *fp;
|
||||
|
||||
for (i=optind; i < argc; i++)
|
||||
{
|
||||
for (i = optind; i < argc; i++) {
|
||||
filename = argv[i];
|
||||
if ((fp = fopen(filename, "r")) != NULL)
|
||||
{
|
||||
if ((fp = fopen(filename, "r")) != NULL) {
|
||||
disassemble(fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* XXX: Give better error message */
|
||||
util_error("can not open bytecode file \"%s\"",
|
||||
filename);
|
||||
}
|
||||
}
|
||||
} /* else */
|
||||
} /* end else */
|
||||
|
||||
exit(EXIT_SUCCESS);
|
||||
} /* main */
|
||||
} /* end main() */
|
||||
|
||||
#endif /* UNIT_TESTING */
|
||||
|
||||
void
|
||||
usage()
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: %s [-h] [files]\n",
|
||||
program_name);
|
||||
return;
|
||||
fprintf(stderr, "usage: %s [-h] [files]\n", program_name);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
** This file may only be copied under the terms of the GNU Library General
|
||||
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
**
|
||||
** $Id: mdis.h,v 1.3 1997-04-24 05:31:04 aet Exp $
|
||||
** $Id: mdis.h,v 1.4 1997-04-26 03:16:12 fjh Exp $
|
||||
*/
|
||||
|
||||
|
||||
#if ! defined(MDIS_H)
|
||||
#ifndef MDIS_H
|
||||
#define MDIS_H
|
||||
|
||||
#endif /* ! MDIS_H */
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
|
||||
/*
|
||||
** Copyright (C) 1997 University of Melbourne.
|
||||
** This file may only be copied under the terms of the GNU Library General
|
||||
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
**
|
||||
** $Id: mem.c,v 1.3 1997-04-24 05:31:09 aet Exp $
|
||||
** $Id: mem.c,v 1.4 1997-04-26 03:16:13 fjh Exp $
|
||||
*/
|
||||
|
||||
/* Imports */
|
||||
@@ -12,15 +11,15 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <util.h>
|
||||
#include <mem.h>
|
||||
#include "util.h"
|
||||
#include "mem.h"
|
||||
|
||||
/* Exported definitions */
|
||||
|
||||
/* Local declarations */
|
||||
|
||||
static char
|
||||
rcs_id[] = "$Id: mem.c,v 1.3 1997-04-24 05:31:09 aet Exp $";
|
||||
rcs_id[] = "$Id: mem.c,v 1.4 1997-04-26 03:16:13 fjh Exp $";
|
||||
|
||||
/*
|
||||
* Make sure the size of guard_bytes is a multiple of 8 to ensure we
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
** This file may only be copied under the terms of the GNU Library General
|
||||
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
**
|
||||
** $Id: mem.h,v 1.3 1997-04-24 05:31:14 aet Exp $
|
||||
** $Id: mem.h,v 1.4 1997-04-26 03:16:14 fjh Exp $
|
||||
*/
|
||||
|
||||
#if ! defined(MEMALLOC_H)
|
||||
#ifndef MEMALLOC_H
|
||||
#define MEMALLOC_H
|
||||
|
||||
void*
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
** This file may only be copied under the terms of the GNU Library General
|
||||
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
**
|
||||
** $Id: static_data.h,v 1.3 1997-04-24 05:31:25 aet Exp $
|
||||
** $Id: static_data.h,v 1.4 1997-04-26 03:16:15 fjh Exp $
|
||||
*/
|
||||
|
||||
|
||||
#if ! defined(STATIC_DATA_H)
|
||||
#ifndef STATIC_DATA_H
|
||||
#define STATIC_DATA_H
|
||||
|
||||
/*
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
** This file may only be copied under the terms of the GNU Library General
|
||||
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
**
|
||||
** $Id: template.h,v 1.4 1997-04-24 05:31:36 aet Exp $
|
||||
** $Id: template.h,v 1.5 1997-04-26 03:16:16 fjh Exp $
|
||||
*/
|
||||
|
||||
|
||||
#if ! defined(TEMPLATE_H)
|
||||
#ifndef TEMPLATE_H
|
||||
#define TEMPLATE_H
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
** This file may only be copied under the terms of the GNU Library General
|
||||
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
**
|
||||
** $Id: util.c,v 1.5 1997-04-24 05:31:41 aet Exp $
|
||||
** $Id: util.c,v 1.6 1997-04-26 03:16:17 fjh Exp $
|
||||
*/
|
||||
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <util.h>
|
||||
#include "util.h"
|
||||
|
||||
|
||||
/* Local declarations */
|
||||
|
||||
static char
|
||||
rcs_id[] = "$Id: util.c,v 1.5 1997-04-24 05:31:41 aet Exp $";
|
||||
rcs_id[] = "$Id: util.c,v 1.6 1997-04-26 03:16:17 fjh Exp $";
|
||||
|
||||
/* Implementation */
|
||||
|
||||
@@ -34,8 +34,6 @@ util_error(const char *fmt, ...)
|
||||
vfprintf(stderr, fmt, arg_p);
|
||||
va_end(argp);
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +61,7 @@ strdup(char* str)
|
||||
|
||||
size = strlen(str) + 1;
|
||||
str2 = malloc(size); /* XXX: use mem_malloc */
|
||||
for (c_p=str2; *str != '\0'; str++, c_p++)
|
||||
for (c_p = str2; *str != '\0'; str++, c_p++)
|
||||
{
|
||||
*c_p = *str;
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
** This file may only be copied under the terms of the GNU Library General
|
||||
** Public License - see the file COPYING.LIB in the Mercury distribution.
|
||||
**
|
||||
** $Id: util.h,v 1.7 1997-04-24 05:31:48 aet Exp $
|
||||
** $Id: util.h,v 1.8 1997-04-26 03:16:18 fjh Exp $
|
||||
*/
|
||||
|
||||
|
||||
#if ! defined(UTIL_H)
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
typedef int
|
||||
@@ -30,13 +30,13 @@ typedef unsigned int
|
||||
* XXX: For some bizzare reason TRUE and FALSE are often defined by the C
|
||||
* libraries! Are they defined in pure POSIX or pure ANSI?
|
||||
*/
|
||||
#if ! defined(TRUE)
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif /* ! TRUE */
|
||||
#endif
|
||||
|
||||
#if ! defined(FALSE)
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif /* ! FALSE */
|
||||
#endif
|
||||
|
||||
#define INT_SIZE (sizeof(int))
|
||||
#define FLOAT_SIZE (sizeof(float))
|
||||
|
||||
Reference in New Issue
Block a user