*** empty log message ***

This commit is contained in:
hyung-hwan 2006-10-28 05:24:08 +00:00
parent 8094a78543
commit 67c78232b2
11 changed files with 101 additions and 66 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c,v 1.87 2006-10-26 09:27:15 bacon Exp $
* $Id: awk.c,v 1.88 2006-10-28 05:24:07 bacon Exp $
*/
#if defined(__BORLANDC__)
@ -35,6 +35,7 @@ ase_awk_t* ase_awk_open (const ase_awk_syscas_t* syscas)
syscas->to_lower == ASE_NULL) return ASE_NULL;
if (syscas->sprintf == ASE_NULL ||
syscas->aprintf == ASE_NULL ||
syscas->dprintf == ASE_NULL ||
syscas->abort == ASE_NULL) return ASE_NULL;

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h,v 1.135 2006-10-26 09:27:15 bacon Exp $
* $Id: awk.h,v 1.136 2006-10-28 05:24:07 bacon Exp $
*/
#ifndef _ASE_AWK_AWK_H_
@ -76,7 +76,8 @@ struct ase_awk_syscas_t
void* (*memset) (void* dst, int val, ase_size_t n);
int (*sprintf) (ase_char_t* buf, ase_size_t size, ase_char_t* fmt, ...);
int (*dprintf) (ase_char_t* fmt, ...);
int (*aprintf) (ase_char_t* fmt, ...); /* assertion */
int (*dprintf) (ase_char_t* fmt, ...); /* debug */
void (*abort) (void);
void* custom_data;

View File

@ -1,5 +1,5 @@
/*
* $Id: func.c,v 1.71 2006-10-27 13:49:43 bacon Exp $
* $Id: func.c,v 1.72 2006-10-28 05:24:07 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -240,7 +240,7 @@ static int __bfn_fflush (ase_awk_run_t* run)
int n;
nargs = ase_awk_getnargs (run);
ASE_AWK_ASSERT (run->awk, nargs >= 0 && nargs <= 1);
ASE_AWK_ASSERT (run->awk, nargs == 0 || nargs == 1);
if (nargs == 0)
{

View File

@ -4,7 +4,10 @@ OBJS = $(SRCS:.c=.obj)
OUT = aseawk.lib
CC = bcc32
CFLAGS = -O2 -WM -w -w-inl -w-sig -w-spa -w-hid -RT- -I../..
CFLAGS_COMMON = -O2 -WM -w -w-inl -w-sig -w-spa -w-hid -RT- -I../..
CFLAGS_RELEASE = $(CFLAGS_COMMON) -DNDEBUG
CFLAGS_DEBUG = $(CFLAGS_COMMON) -D_DEBUG
CFLAGS = $(CFLAGS_DEBUG)
all: $(OBJS)
tlib $(OUT) @&&!

View File

@ -1,5 +1,5 @@
/*
* $Id: misc.c,v 1.33 2006-10-26 09:27:15 bacon Exp $
* $Id: misc.c,v 1.34 2006-10-28 05:24:07 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -1063,7 +1063,7 @@ exit_loop:
int ase_awk_assertfail (ase_awk_t* awk,
const ase_char_t* expr, const ase_char_t* file, int line)
{
awk->syscas.dprintf (
awk->syscas.aprintf (
ASE_T("ASSERTION FAILURE AT FILE %s, LINE %d\n%s\n"),
file, line, expr);
awk->syscas.abort ();

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c,v 1.247 2006-10-27 13:52:25 bacon Exp $
* $Id: run.c,v 1.248 2006-10-28 05:24:07 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -200,14 +200,16 @@ typedef ase_awk_val_t* (*binop_func_t) (
ase_awk_run_t* run, ase_awk_val_t* left, ase_awk_val_t* right);
typedef ase_awk_val_t* (*eval_expr_t) (ase_awk_run_t* run, ase_awk_nde_t* nde);
/* TODO: remove this function */
#ifdef _DEBUG
static int __printval (ase_awk_pair_t* pair, void* arg)
{
xp_printf (ASE_T("%s = "), (const ase_char_t*)pair->key);
ase_awk_printval ((ase_awk_val_t*)pair->val);
xp_printf (ASE_T("\n"));
ase_awk_run_t* run = (ase_awk_run_t*)arg;
run->awk->syscas.dprintf (ASE_T("%s = "), (const ase_char_t*)pair->key);
ase_awk_dprintval (run, (ase_awk_val_t*)pair->val);
run->awk->syscas.dprintf (ASE_T("\n"));
return 0;
}
#endif
ase_size_t ase_awk_getnargs (ase_awk_run_t* run)
{
@ -1152,9 +1154,13 @@ static int __run_main (ase_awk_run_t* run, ase_awk_runarg_t* runarg)
}
v = STACK_RETVAL(run);
xp_printf (ASE_T("Return Value - "));
ase_awk_printval (v);
xp_printf (ASE_T("\n"));
#ifdef _DEBUG
run->awk->syscas.dprintf (ASE_T("[RETURN] - "));
ase_awk_dprintval (run, v);
run->awk->syscas.dprintf (ASE_T("\n"));
#endif
/* the life of the global return value is over here
* unlike the return value of each function */
/*ase_awk_refdownval_nofree (awk, v);*/
@ -1178,9 +1184,11 @@ xp_printf (ASE_T("\n"));
/* just reset the exit level */
run->exit_level = EXIT_NONE;
xp_printf (ASE_T("-[VARIABLES]------------------------\n"));
ase_awk_map_walk (&run->named, __printval, ASE_NULL);
xp_printf (ASE_T("-[END VARIABLES]--------------------------\n"));
#ifdef _DEBUG
run->awk->syscas.dprintf (ASE_T("[VARIABLES]\n"));
ase_awk_map_walk (&run->named, __printval, run);
run->awk->syscas.dprintf (ASE_T("[END VARIABLES]\n"));
#endif
return n;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: val.c,v 1.77 2006-10-26 09:27:16 bacon Exp $
* $Id: val.c,v 1.78 2006-10-28 05:24:08 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -180,7 +180,7 @@ static void __free_map_val (void* run, void* v)
{
/*
xp_printf (ASE_T("refdown in map free..."));
ase_awk_printval (v);
ase_awk_dprintval (v);
xp_printf (ASE_T("\n"));
*/
ase_awk_refdownval (run, v);
@ -244,7 +244,7 @@ void ase_awk_freeval (ase_awk_run_t* run, ase_awk_val_t* val, ase_bool_t cache)
if (ase_awk_isbuiltinval(val)) return;
/*xp_printf (ASE_T("freeing [cache=%d] ... "), cache);
ase_awk_printval (val);
ase_awk_dprintval (val);
xp_printf (ASE_T("\n"));*/
if (val->type == ASE_AWK_VAL_NIL)
{
@ -308,7 +308,7 @@ void ase_awk_refupval (ase_awk_val_t* val)
if (ase_awk_isbuiltinval(val)) return;
/*
xp_printf (ASE_T("ref up "));
ase_awk_printval (val);
ase_awk_dprintval (val);
xp_printf (ASE_T("\n"));
*/
val->ref++;
@ -321,7 +321,7 @@ void ase_awk_refdownval (ase_awk_run_t* run, ase_awk_val_t* val)
/*
xp_printf (ASE_T("%p, %p, %p\n"), ase_awk_val_nil, &__awk_nil, val);
xp_printf (ASE_T("ref down [count=>%d]\n"), (int)val->ref);
ase_awk_printval (val);
ase_awk_dprintval (val);
xp_printf (ASE_T("\n"));
*/
@ -331,7 +331,7 @@ xp_printf (ASE_T("\n"));
{
/*
xp_printf (ASE_T("**FREEING ["));
ase_awk_printval (val);
ase_awk_dprintval (val);
xp_printf (ASE_T("]\n"));
*/
ase_awk_freeval(run, val, ase_true);
@ -648,65 +648,67 @@ xp_printf (ASE_T("*** ERROR: WRONG VALUE TYPE [%d] in ase_awk_valtonum v=> %p***
return -1; /* error */
}
#define __DPRINTF run->awk->syscas.dprintf
static int __print_pair (ase_awk_pair_t* pair, void* arg)
{
xp_printf (ASE_T(" %s=>"), pair->key);
ase_awk_printval (pair->val);
xp_printf (ASE_T(" "));
ase_awk_run_t* run = (ase_awk_run_t*)arg;
__DPRINTF (ASE_T(" %s=>"), pair->key);
ase_awk_dprintval ((ase_awk_run_t*)arg, pair->val);
__DPRINTF (ASE_T(" "));
return 0;
}
void ase_awk_printval (ase_awk_val_t* val)
void ase_awk_dprintval (ase_awk_run_t* run, ase_awk_val_t* val)
{
/* TODO: better value printing...................... */
/* TODO: better value printing ... */
switch (val->type)
{
case ASE_AWK_VAL_NIL:
xp_printf (ASE_T("nil"));
__DPRINTF (ASE_T("nil"));
break;
case ASE_AWK_VAL_INT:
#if defined(__LCC__)
xp_printf (ASE_T("%lld"),
(long long)((ase_awk_val_int_t*)val)->val);
#elif defined(__BORLANDC__) || defined(_MSC_VER)
xp_printf (ASE_T("%I64d"),
#if defined(__BORLANDC__) || defined(_MSC_VER)
__DPRINTF (ASE_T("%I64d"),
(__int64)((ase_awk_nde_int_t*)val)->val);
#elif defined(vax) || defined(__vax) || defined(_SCO_DS)
xp_printf (ASE_T("%ld"),
__DPRINTF (ASE_T("%ld"),
(long)((ase_awk_val_int_t*)val)->val);
#else
xp_printf (ASE_T("%lld"),
__DPRINTF (ASE_T("%lld"),
(long long)((ase_awk_val_int_t*)val)->val);
#endif
break;
case ASE_AWK_VAL_REAL:
xp_printf (ASE_T("%Lf"),
__DPRINTF (ASE_T("%Lf"),
(long double)((ase_awk_val_real_t*)val)->val);
break;
case ASE_AWK_VAL_STR:
xp_printf (ASE_T("%s"), ((ase_awk_val_str_t*)val)->buf);
__DPRINTF (ASE_T("%s"), ((ase_awk_val_str_t*)val)->buf);
break;
case ASE_AWK_VAL_REX:
xp_printf (ASE_T("REX[%s]"), ((ase_awk_val_rex_t*)val)->buf);
__DPRINTF (ASE_T("REX[%s]"), ((ase_awk_val_rex_t*)val)->buf);
break;
case ASE_AWK_VAL_MAP:
xp_printf (ASE_T("MAP["));
ase_awk_map_walk (((ase_awk_val_map_t*)val)->map, __print_pair, ASE_NULL);
xp_printf (ASE_T("]"));
__DPRINTF (ASE_T("MAP["));
ase_awk_map_walk (((ase_awk_val_map_t*)val)->map, __print_pair, run);
__DPRINTF (ASE_T("]"));
break;
case ASE_AWK_VAL_REF:
xp_printf (ASE_T("REF[id=%d,val="), ((ase_awk_val_ref_t*)val)->id);
ase_awk_printval (*((ase_awk_val_ref_t*)val)->adr);
xp_printf (ASE_T("]"));
__DPRINTF (ASE_T("REF[id=%d,val="), ((ase_awk_val_ref_t*)val)->id);
ase_awk_dprintval (run, *((ase_awk_val_ref_t*)val)->adr);
__DPRINTF (ASE_T("]"));
break;
default:
xp_printf (ASE_T("**** INTERNAL ERROR - INVALID VALUE TYPE ****\n"));
__DPRINTF (ASE_T("**** INTERNAL ERROR - INVALID VALUE TYPE ****\n"));
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: val.h,v 1.48 2006-10-24 04:10:12 bacon Exp $
* $Id: val.h,v 1.49 2006-10-28 05:24:08 bacon Exp $
*/
#ifndef _ASE_AWK_VAL_H_
@ -174,7 +174,7 @@ ase_char_t* ase_awk_valtostr (
int ase_awk_valtonum (
ase_awk_run_t* run, ase_awk_val_t* v, ase_long_t* l, ase_real_t* r);
void ase_awk_printval (ase_awk_val_t* val);
void ase_awk_dprintval (ase_awk_run_t* run, ase_awk_val_t* val);
#ifdef __cplusplus
}

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c,v 1.106 2006-10-27 11:06:09 bacon Exp $
* $Id: awk.c,v 1.107 2006-10-28 05:24:08 bacon Exp $
*/
#include <ase/awk/awk.h>
@ -27,6 +27,7 @@
#define xp_vsprintf _vsntprintf
#define xp_sprintf _sntprintf
#define xp_frintf _ftprintf
#define xp_printf _tprintf
#define xp_assert assert
@ -83,7 +84,7 @@ static FILE* fopen_t (const ase_char_t* path, const ase_char_t* mode)
#endif
}
static int __dprintf (const ase_char_t* fmt, ...)
static int __aprintf (const ase_char_t* fmt, ...)
{
int n;
va_list ap;
@ -108,6 +109,23 @@ static int __dprintf (const ase_char_t* fmt, ...)
return n;
}
static int __dprintf (const ase_char_t* fmt, ...)
{
int n;
va_list ap;
va_start (ap, fmt);
#ifdef _WIN32
n = _vftprintf (stderr, fmt, ap);
#else
n = xp_vfprintf (stderr, fmt, ap);
#endif
va_end (ap);
return n;
}
static FILE* popen_t (const ase_char_t* cmd, const ase_char_t* mode)
{
#ifdef _WIN32
@ -561,7 +579,8 @@ static void __on_run_start (ase_awk_t* awk, void* handle, void* arg)
{
app_awk = awk;
app_run = handle;
xp_printf (ASE_T("AWK PRORAM ABOUT TO START...\n"));
xp_printf (ASE_T("AWK PRORAM ABOUT TO START...\n"));
}
static void __on_run_end (ase_awk_t* awk, void* handle, int errnum, void* arg)
@ -705,6 +724,7 @@ static int __main (int argc, ase_char_t* argv[])
syscas.memcpy = memcpy;
syscas.memset = memset;
syscas.sprintf = xp_sprintf;
syscas.aprintf = __aprintf;
syscas.dprintf = __dprintf;
syscas.abort = abort;

View File

@ -1,6 +1,5 @@
function sum(i, k, y)
{
y = 0;
for (k = i; k; k = k - 1)
{
@ -15,6 +14,7 @@ function sum(i, k, y)
BEGIN {
/*s = sum(10000000);*/
s = sum (100);
return s;
}

View File

@ -3,7 +3,7 @@
{
#print (("%f", 1.0)); # syntax error
print ((((10) + 20)));
#print ("%f", 1.0);
print ("%f", 1.0);
print ((10) + 20, 50);
}