*** empty log message ***
This commit is contained in:
parent
24f1124b8e
commit
f93a7f4345
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.c,v 1.33 2006-03-27 11:43:17 bacon Exp $
|
* $Id: awk.c,v 1.34 2006-03-27 14:14:00 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk.h>
|
#include <xp/awk/awk.h>
|
||||||
@ -9,7 +9,7 @@
|
|||||||
#include <xp/bas/assert.h>
|
#include <xp/bas/assert.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void __free_func (void* func);
|
static void __free_func (xp_awk_t* awk, void* func);
|
||||||
|
|
||||||
xp_awk_t* xp_awk_open (xp_awk_t* awk)
|
xp_awk_t* xp_awk_open (xp_awk_t* awk)
|
||||||
{
|
{
|
||||||
@ -25,7 +25,7 @@ xp_awk_t* xp_awk_open (xp_awk_t* awk)
|
|||||||
return XP_NULL;
|
return XP_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xp_awk_map_open(&awk->tree.funcs, 256, __free_func) == XP_NULL) {
|
if (xp_awk_map_open (&awk->tree.funcs, awk, 256, __free_func) == XP_NULL) {
|
||||||
xp_str_close (&awk->token.name);
|
xp_str_close (&awk->token.name);
|
||||||
if (awk->__dynamic) xp_free (awk);
|
if (awk->__dynamic) xp_free (awk);
|
||||||
return XP_NULL;
|
return XP_NULL;
|
||||||
@ -56,8 +56,7 @@ xp_awk_t* xp_awk_open (xp_awk_t* awk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: initial map size...
|
// TODO: initial map size...
|
||||||
if (xp_awk_map_open(&awk->run.named,
|
if (xp_awk_map_open(&awk->run.named,awk,256,xp_awk_refdownval) == XP_NULL) {
|
||||||
256, (void(*)(void*))xp_awk_refdownval) == XP_NULL) {
|
|
||||||
xp_str_close (&awk->token.name);
|
xp_str_close (&awk->token.name);
|
||||||
xp_awk_map_close (&awk->tree.funcs);
|
xp_awk_map_close (&awk->tree.funcs);
|
||||||
xp_awk_tab_close (&awk->parse.globals);
|
xp_awk_tab_close (&awk->parse.globals);
|
||||||
@ -189,7 +188,7 @@ int xp_awk_detsrc (xp_awk_t* awk)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __free_func (void* func)
|
static void __free_func (xp_awk_t* awk, void* func)
|
||||||
{
|
{
|
||||||
xp_awk_func_t* f = (xp_awk_func_t*) func;
|
xp_awk_func_t* f = (xp_awk_func_t*) func;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: map.c,v 1.7 2006-03-07 16:09:18 bacon Exp $
|
* $Id: map.c,v 1.8 2006-03-27 14:14:00 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk.h>
|
#include <xp/awk/awk.h>
|
||||||
@ -20,12 +20,13 @@ static xp_size_t __hash (const xp_char_t* key);
|
|||||||
{ \
|
{ \
|
||||||
xp_free ((xp_char_t*)(pair)->key); \
|
xp_free ((xp_char_t*)(pair)->key); \
|
||||||
if ((map)->freeval != XP_NULL) \
|
if ((map)->freeval != XP_NULL) \
|
||||||
(map)->freeval ((pair)->val); \
|
(map)->freeval ((map)->awk, (pair)->val); \
|
||||||
xp_free (pair); \
|
xp_free (pair); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
xp_awk_map_t* xp_awk_map_open (
|
xp_awk_map_t* xp_awk_map_open (
|
||||||
xp_awk_map_t* map, xp_size_t capa, void (*freeval) (void*))
|
xp_awk_map_t* map, xp_awk_t* awk,
|
||||||
|
xp_size_t capa, void(*freeval)(xp_awk_t*,void*))
|
||||||
{
|
{
|
||||||
if (map == XP_NULL)
|
if (map == XP_NULL)
|
||||||
{
|
{
|
||||||
@ -43,6 +44,7 @@ xp_awk_map_t* xp_awk_map_open (
|
|||||||
return XP_NULL;
|
return XP_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
map->awk = awk;
|
||||||
map->capa = capa;
|
map->capa = capa;
|
||||||
map->size = 0;
|
map->size = 0;
|
||||||
map->freeval = freeval;
|
map->freeval = freeval;
|
||||||
@ -70,10 +72,8 @@ void xp_awk_map_clear (xp_awk_map_t* map)
|
|||||||
while (pair != XP_NULL)
|
while (pair != XP_NULL)
|
||||||
{
|
{
|
||||||
next = pair->next;
|
next = pair->next;
|
||||||
|
|
||||||
FREE_PAIR (map, pair);
|
FREE_PAIR (map, pair);
|
||||||
map->size--;
|
map->size--;
|
||||||
|
|
||||||
pair = next;
|
pair = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ xp_awk_pair_t* xp_awk_map_setpair (
|
|||||||
{
|
{
|
||||||
if (map->freeval != XP_NULL)
|
if (map->freeval != XP_NULL)
|
||||||
{
|
{
|
||||||
map->freeval (pair->val);
|
map->freeval (map->awk, pair->val);
|
||||||
}
|
}
|
||||||
pair->val = val;
|
pair->val = val;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: map.h,v 1.5 2006-03-07 15:55:14 bacon Exp $
|
* $Id: map.h,v 1.6 2006-03-27 14:14:00 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _XP_AWK_MAP_H_
|
#ifndef _XP_AWK_MAP_H_
|
||||||
@ -28,10 +28,11 @@ struct xp_awk_pair_t
|
|||||||
|
|
||||||
struct xp_awk_map_t
|
struct xp_awk_map_t
|
||||||
{
|
{
|
||||||
|
xp_awk_t* awk;
|
||||||
xp_size_t size;
|
xp_size_t size;
|
||||||
xp_size_t capa;
|
xp_size_t capa;
|
||||||
xp_awk_pair_t** buck;
|
xp_awk_pair_t** buck;
|
||||||
void (*freeval) (void*);
|
void (*freeval) (xp_awk_t*,void*);
|
||||||
xp_bool_t __dynamic;
|
xp_bool_t __dynamic;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -40,7 +41,8 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
xp_awk_map_t* xp_awk_map_open (
|
xp_awk_map_t* xp_awk_map_open (
|
||||||
xp_awk_map_t* map, xp_size_t capa, void (*freeval) (void*));
|
xp_awk_map_t* map, xp_awk_t* awk,
|
||||||
|
xp_size_t capa, void(*freeval)(xp_awk_t*,void*));
|
||||||
void xp_awk_map_close (xp_awk_map_t* map);
|
void xp_awk_map_close (xp_awk_map_t* map);
|
||||||
|
|
||||||
void xp_awk_map_clear (xp_awk_map_t* map);
|
void xp_awk_map_clear (xp_awk_map_t* map);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: run.c,v 1.21 2006-03-27 11:43:17 bacon Exp $
|
* $Id: run.c,v 1.22 2006-03-27 14:14:00 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk.h>
|
#include <xp/awk/awk.h>
|
||||||
@ -481,7 +481,9 @@ static xp_awk_val_t* __eval_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* somthing wrong */
|
/* somthing wrong. internal error */
|
||||||
|
/* TODO: set the error code instead of assertion below */
|
||||||
|
xp_assert (XP_TEXT("should never happen") == XP_NULL);
|
||||||
return XP_NULL;
|
return XP_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user