diff --git a/ase/awk/run.c b/ase/awk/run.c index 0ea08322..6dbc0bce 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.118 2006-06-30 16:46:34 bacon Exp $ + * $Id: run.c,v 1.119 2006-06-30 17:07:52 bacon Exp $ */ #include @@ -1104,7 +1104,7 @@ static int __run_delete (xp_awk_run_t* run, xp_awk_nde_delete_t* nde) var->type == XP_AWK_NDE_LOCALIDX || var->type == XP_AWK_NDE_ARGIDX); -xp_printf (XP_T("hello....... map...\n")); +xp_printf (XP_T("********** __run_delete **************\n")); if (var->type == XP_AWK_NDE_NAMED) { xp_awk_pair_t* pair; @@ -1138,7 +1138,6 @@ xp_printf (XP_T("hello....... map...\n")); { xp_printf (XP_T("clearing map...\n")); xp_awk_map_clear (((xp_awk_val_map_t*)val)->map); - /* should not ismply clear it... */ } else { @@ -1150,10 +1149,24 @@ xp_printf (XP_T("clearing map...\n")); { xp_awk_val_t* val; +xp_printf (XP_T("clearing global...\n")); val = STACK_GLOBAL (run,var->id.idxa); - if (val == XP_NULL) + xp_assert (val != XP_NULL); + + if (val->type == XP_AWK_VAL_NIL) { - /* TODO: */ + xp_awk_val_t* tmp; + + /* value not set for the named variable. + * create a map and assign it to the variable */ + + tmp = xp_awk_makemapval (run); + if (tmp == XP_NULL) PANIC_I (run, XP_AWK_ENOMEM); + + /* no need to reduce the reference count of + * the previous value because it was nil. */ + STACK_GLOBAL (run,var->id.idxa) = tmp; + xp_awk_refupval (tmp); } else { @@ -1168,6 +1181,43 @@ xp_printf (XP_TEXT("clearning....\n")); } } } + else if (var->type == XP_AWK_NDE_LOCAL) + { + xp_awk_val_t* val; + +xp_printf (XP_T("clearing lcoal...\n")); + val = STACK_LOCAL (run,var->id.idxa); + xp_assert (val != XP_NULL); + + if (val->type == XP_AWK_VAL_NIL) + { + xp_awk_val_t* tmp; + + /* value not set for the named variable. + * create a map and assign it to the variable */ + + tmp = xp_awk_makemapval (run); + if (tmp == XP_NULL) PANIC_I (run, XP_AWK_ENOMEM); + + /* no need to reduce the reference count of + * the previous value because it was nil. */ + STACK_LOCAL (run,var->id.idxa) = tmp; + xp_awk_refupval (tmp); + } + else + { + if (val->type == XP_AWK_VAL_MAP) + { +xp_printf (XP_TEXT("clearning....\n")); + xp_awk_map_clear (((xp_awk_val_map_t*)val)->map); + } + else + { + PANIC_I (run, XP_AWK_ENOTDELETABLE); + } + } + + } else { xp_printf (XP_T("**** delete NOT IMPLEMENTED not implemented for this type of variable...\n")); diff --git a/ase/test/awk/t13.awk b/ase/test/awk/t13.awk index 222e6e1e..3a47728f 100644 --- a/ase/test/awk/t13.awk +++ b/ase/test/awk/t13.awk @@ -1,9 +1,16 @@ -//global a; +global a; BEGIN { + local b; + //a = 20; - a[1] = 20; - a[2] = 30; + //a[1] = 20; + //a[2] = 30; + + b["xxx"] = 20; + b["yyy"] = 30; + delete a; + delete b; } diff --git a/ase/test/awk/xptestawk.dsp b/ase/test/awk/xptestawk.dsp index 0946d46f..27e2f290 100644 --- a/ase/test/awk/xptestawk.dsp +++ b/ase/test/awk/xptestawk.dsp @@ -50,7 +50,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 xpawk.lib /nologo /subsystem:console /machine:I386 /out:"..\..\..\release\awk.exe" /libpath:"..\..\awk\release" +# ADD LINK32 xpawk.lib /nologo /subsystem:console /machine:I386 /out:"..\..\..\release\awk.exe" /libpath:"..\..\..\release" !ELSEIF "$(CFG)" == "xptestawk - Win32 Debug" @@ -74,7 +74,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 xpawk.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"..\..\..\debug\awk.exe" /pdbtype:sept /libpath:"..\..\awk\debug" +# ADD LINK32 xpawk.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"..\..\..\debug\awk.exe" /pdbtype:sept /libpath:"..\..\..\debug" !ENDIF @@ -97,6 +97,10 @@ SOURCE=.\awk.c # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=..\..\..\debug\xpawk.lib +# End Source File # End Group # End Target # End Project