*** empty log message ***

This commit is contained in:
hyung-hwan 2006-01-18 15:16:01 +00:00
parent 41853d7f20
commit 6626b3a414
6 changed files with 21 additions and 108 deletions

View File

@ -1,9 +1,10 @@
SRCS = awk.c parse.c tree.c
SRCS = awk.c parse.c tree.c sa.c
OBJS = $(SRCS:.c=.obj)
OUT = xpawk.lib
CC = cl
CFLAGS = /nologo /MT /W3 /GR- /D_WIN32_WINNT=0x0400 -I../..
#CFLAGS = /nologo /MT /W3 /GR- /D_WIN32_WINNT=0x0400 -I../..
CFLAGS = /nologo /MT /W3 /GR- /D_WIN32_WINNT=0x0400 -I../.. -D__STAND_ALONE
all: $(OBJS)
link -lib @<<

View File

@ -1,10 +1,13 @@
/*
* $Id: awk.c,v 1.7 2006-01-09 16:03:55 bacon Exp $
* $Id: awk.c,v 1.8 2006-01-18 15:16:01 bacon Exp $
*/
#include <xp/awk/awk.h>
#ifndef __STAND_ALONE
#include <xp/bas/memory.h>
#include <xp/bas/assert.h>
#endif
xp_awk_t* xp_awk_open (xp_awk_t* awk)
{

View File

@ -1,13 +1,18 @@
/*
* $Id: awk.h,v 1.12 2006-01-14 16:09:57 bacon Exp $
* $Id: awk.h,v 1.13 2006-01-18 15:16:01 bacon Exp $
*/
#ifndef _XP_AWK_AWK_H_
#define _XP_AWK_AWK_H_
#ifdef __STAND_ALONE
#include <xp/awk/sa.h>
#else
#include <xp/types.h>
#include <xp/macros.h>
#include <xp/bas/str.h>
#endif
#include <xp/awk/tree.h>
enum

View File

@ -1,98 +0,0 @@
/*
* $Id: mem.c,v 1.2 2005-12-05 15:11:29 bacon Exp $
*/
#include <xp/sce/mem.h>
#include <xp/sce/misc.h>
xp_sce_mem_t* xp_sce_mem_open (
xp_sce_mem_t* mem, xp_word_t capacity)
{
xp_sce_obj_t** slots;
xp_word_t n;
xp_assert (capacity > 0);
if (mem == XP_NULL) {
mem = (xp_sce_mem_t*)xp_malloc(xp_sizeof(xp_sce_mem_t));
if (mem == XP_NULL) return XP_NULL;
mem->__dynamic = xp_true;
}
else mem->__dynamic = xp_false;
slots = (xp_sce_obj_t**)xp_malloc (
capacity * xp_sizeof(xp_sce_obj_t*));
if (slots == XP_NULL) {
if (mem->__dynamic) xp_free (mem);
mem = XP_NULL;
}
mem->capacity = capacity;
mem->slots = slots;
/* weave the free slot list */
mem->free = &slots[0];
for (n = 0; n < capacity - 1; n++) {
mem->slots[n] = (xp_sce_obj_t*)&mem->slots[n + 1];
}
mem->slots[n] = XP_NULL;
return mem;
}
void xp_sce_mem_close (xp_sce_mem_t* mem)
{
/* TODO: free all linked objs... */
xp_free (mem->slots);
mem->capacity = 0;
mem->slots = XP_NULL;
mem->free = XP_NULL;
if (mem->__dynamic) xp_free (mem);
}
void xp_sce_mem_gc (xp_sce_mem_t* mem)
{
/* TODO: implement this function */
}
xp_word_t xp_sce_mem_alloc (xp_sce_mem_t* mem, xp_word_t nbytes)
{
xp_sce_obj_t** slot;
xp_sce_obj_t* obj;
/* find the free obj slot */
if (mem->free == XP_NULL) {
xp_sce_mem_gc (mem);
if (mem->free == XP_NULL) return mem->capacity;;
}
obj = (xp_sce_obj_t*)xp_malloc (nbytes);
if (obj == XP_NULL) {
xp_sce_mem_gc (mem);
obj = (xp_sce_obj_t*)xp_malloc (nbytes);
/*if (obj == XP_NULL) return mem->capacity;*/
if (obj == XP_NULL) {
xp_assert (XP_TEXT("MEMORY ALLOCATION ERROR\n") == XP_NULL);
exit (1);
}
}
slot = mem->free;
mem->free = (xp_sce_obj_t**)*slot;
*slot = obj;
return (xp_word_t)(slot - mem->slots);
}
void xp_sce_mem_dealloc (xp_sce_mem_t* mem, xp_word_t obj_index)
{
/*
* THIS IS PRIMITIVE LOW-LEVEL DEALLOC. THIS WILL NOT
* DEALLOCATE MEMORY ALLOCATED FOR ITS INSTANCE VARIABLES.
*/
xp_free (mem->slots[obj_index]);
mem->slots[obj_index] = (xp_sce_obj_t*)mem->free;
mem->free = &mem->slots[obj_index];
}

View File

@ -1,13 +1,15 @@
/*
* $Id: parse.c,v 1.21 2006-01-15 06:11:22 bacon Exp $
* $Id: parse.c,v 1.22 2006-01-18 15:16:01 bacon Exp $
*/
#include <xp/awk/awk.h>
#include <xp/awk/tree.h>
#ifndef __STAND_ALONE
#include <xp/bas/memory.h>
#include <xp/bas/ctype.h>
#include <xp/bas/string.h>
#include <xp/bas/assert.h>
#endif
enum
{
@ -156,9 +158,6 @@ static struct __kwent __kwtab[] =
#define PANIC(awk,code) do { (awk)->errnum = (code); return XP_NULL; } while (0);
// TODO remove stdio.h
#include <xp/bas/stdio.h>
int xp_awk_parse (xp_awk_t* awk)
{
xp_awk_node_t* node;

View File

@ -1,11 +1,14 @@
/*
* $Id: tree.c,v 1.3 2006-01-15 06:51:35 bacon Exp $
* $Id: tree.c,v 1.4 2006-01-18 15:16:01 bacon Exp $
*/
#include <xp/awk/awk.h>
#ifndef __STAND_ALONE
#include <xp/bas/memory.h>
#include <xp/bas/assert.h>
#include <xp/bas/stdio.h>
#endif
static xp_char_t __binop_char[] =
{