*** empty log message ***

This commit is contained in:
hyung-hwan 2007-03-22 11:21:59 +00:00
parent dc0fcaeeab
commit 1e877d9529
6 changed files with 131 additions and 125 deletions

View File

@ -1,22 +1,28 @@
SRCS = stx.c memory.c object.c symbol.c class.c array.c \ OUT = asestx
C_SRCS = stx.c memory.c object.c symbol.c class.c array.c \
dict.c misc.c context.c name.c token.c parser.c bootstrp.c \ dict.c misc.c context.c name.c token.c parser.c bootstrp.c \
bytecode.c interp.c bytecode.c interp.c
OBJS = $(SRCS:.c=.o)
OUT = libxpstx.a C_OBJS = $(C_SRCS:.c=.o)
CC = @CC@ CC = @CC@
AR = ar
RANLIB = @RANLIB@ RANLIB = @RANLIB@
CFLAGS = @CFLAGS@ -I@abs_top_builddir@/.. CFLAGS = @CFLAGS@ -I@abs_top_builddir@/..
LDFLAGS = @LDFLAGS@ LDFLAGS = @LDFLAGS@
LIBS = @LIBS@ LIBS = @LIBS@
all: $(OBJS) all: lib
ar cr $(OUT) $(OBJS)
ranlib $(OUT) lib: $(C_OBJS)
$(AR) cr lib$(OUT).a $(C_OBJS)
if [ "$(RANLIB)" = "ranlib" ]; then ranlib lib$(OUT).a; fi
clean: clean:
rm -rf $(OBJS) $(OUT) *.o rm -rf $(OBJS) lib$(OUT).a *.o
.SUFFIXES: .c .o .SUFFIXES: .c .o
.c.o: .c.o:
$(CC) $(CFLAGS) -c $< $(CC) $(CFLAGS) -c $<

View File

@ -1,12 +1,12 @@
/* /*
* $Id: stx.h,v 1.46 2007-03-22 11:19:28 bacon Exp $ * $Id: stx.h,v 1.47 2007-03-22 11:21:59 bacon Exp $
*/ */
#ifndef _ASE_STX_STX_H_ #ifndef _ASE_STX_STX_H_
#define _ASE_STX_STX_H_ #define _ASE_STX_STX_H_
#include <ase/types.h> #include <ase/cmn/types.h>
#include <ase/macros.h> #include <ase/cmn/macros.h>
typedef struct ase_stx_objhdr_t ase_stx_objhdr_t; typedef struct ase_stx_objhdr_t ase_stx_objhdr_t;
typedef struct ase_stx_object_t ase_stx_object_t; typedef struct ase_stx_object_t ase_stx_object_t;

View File

@ -1,30 +1,30 @@
/* /*
* $Id: symbol.c,v 1.21 2005-08-11 09:57:54 bacon Exp $ * $Id: symbol.c,v 1.22 2007-03-22 11:19:28 bacon Exp $
*/ */
#include <xp/stx/symbol.h> #include <ase/stx/symbol.h>
#include <xp/stx/object.h> #include <ase/stx/object.h>
#include <xp/stx/misc.h> #include <ase/stx/misc.h>
static void __grow_symtab (xp_stx_t* stx) static void __grow_symtab (ase_stx_t* stx)
{ {
xp_word_t capa, ncapa, i, j; ase_word_t capa, ncapa, i, j;
xp_word_t* nspace; ase_word_t* nspace;
capa = stx->symtab.capacity; capa = stx->symtab.capacity;
ncapa = capa << 1; ncapa = capa << 1;
nspace = (xp_word_t*)xp_malloc(xp_sizeof(xp_word_t) * ncapa); nspace = (ase_word_t*)ase_malloc(ase_sizeof(ase_word_t) * ncapa);
if (nspace == XP_NULL) { if (nspace == ASE_NULL) {
/* TODO: handle memory error */ /* TODO: handle memory error */
} }
for (i = 0; i < capa; i++) { for (i = 0; i < capa; i++) {
xp_word_t x = stx->symtab.datum[i]; ase_word_t x = stx->symtab.datum[i];
if (x == stx->nil) continue; if (x == stx->nil) continue;
j = xp_stx_strxhash ( j = ase_stx_strxhash (
XP_STX_DATA(stx,x), XP_STX_SIZE(stx,x)) % ncapa; ASE_STX_DATA(stx,x), ASE_STX_SIZE(stx,x)) % ncapa;
while (1) { while (1) {
if (nspace[j] == stx->nil) { if (nspace[j] == stx->nil) {
@ -36,19 +36,19 @@ static void __grow_symtab (xp_stx_t* stx)
} }
stx->symtab.capacity = ncapa; stx->symtab.capacity = ncapa;
xp_free (stx->symtab.datum); ase_free (stx->symtab.datum);
stx->symtab.datum = nspace; stx->symtab.datum = nspace;
} }
xp_word_t xp_stx_new_symbol (xp_stx_t* stx, const xp_char_t* name) ase_word_t ase_stx_new_symbol (ase_stx_t* stx, const ase_char_t* name)
{ {
return xp_stx_new_symbolx (stx, name, xp_strlen(name)); return ase_stx_new_symbolx (stx, name, ase_strlen(name));
} }
xp_word_t xp_stx_new_symbolx ( ase_word_t ase_stx_new_symbolx (
xp_stx_t* stx, const xp_char_t* name, xp_word_t len) ase_stx_t* stx, const ase_char_t* name, ase_word_t len)
{ {
xp_word_t capa, hash, index, size, x; ase_word_t capa, hash, index, size, x;
capa = stx->symtab.capacity; capa = stx->symtab.capacity;
size = stx->symtab.size; size = stx->symtab.size;
@ -58,22 +58,22 @@ xp_word_t xp_stx_new_symbolx (
capa = stx->symtab.capacity; capa = stx->symtab.capacity;
} }
hash = xp_stx_strxhash(name,len); hash = ase_stx_strxhash(name,len);
index = hash % stx->symtab.capacity; index = hash % stx->symtab.capacity;
while (1) { while (1) {
x = stx->symtab.datum[index]; x = stx->symtab.datum[index];
if (x == stx->nil) { if (x == stx->nil) {
/* insert a new item into an empty slot */ /* insert a new item into an empty slot */
x = xp_stx_alloc_char_objectx (stx, name, len); x = ase_stx_alloc_char_objectx (stx, name, len);
XP_STX_CLASS(stx,x) = stx->class_symbol; ASE_STX_CLASS(stx,x) = stx->class_symbol;
stx->symtab.datum[index] = x; stx->symtab.datum[index] = x;
stx->symtab.size++; stx->symtab.size++;
break; break;
} }
if (xp_strxncmp(name, len, if (ase_strxncmp(name, len,
XP_STX_DATA(stx,x), XP_STX_SIZE(stx,x)) == 0) break; ASE_STX_DATA(stx,x), ASE_STX_SIZE(stx,x)) == 0) break;
index = (index % stx->symtab.capacity) + 1; index = (index % stx->symtab.capacity) + 1;
} }
@ -81,10 +81,10 @@ xp_word_t xp_stx_new_symbolx (
return x; return x;
} }
void xp_stx_traverse_symbol_table ( void ase_stx_traverse_symbol_table (
xp_stx_t* stx, void (*func) (xp_stx_t*,xp_word_t,void*), void* data) ase_stx_t* stx, void (*func) (ase_stx_t*,ase_word_t,void*), void* data)
{ {
xp_word_t index, x; ase_word_t index, x;
for (index = 0; index < stx->symtab.capacity; index++) { for (index = 0; index < stx->symtab.capacity; index++) {
x = stx->symtab.datum[index]; x = stx->symtab.datum[index];

View File

@ -1,37 +1,37 @@
/* /*
* $Id: symbol.h,v 1.8 2005-07-17 15:55:01 bacon Exp $ * $Id: symbol.h,v 1.9 2007-03-22 11:19:28 bacon Exp $
*/ */
#ifndef _XP_STX_SYMBOL_H_ #ifndef _ASE_STX_SYMBOL_H_
#define _XP_STX_SYMBOL_H_ #define _ASE_STX_SYMBOL_H_
#include <xp/stx/stx.h> #include <ase/stx/stx.h>
#define XP_STX_SYMLINK_SIZE 2 #define ASE_STX_SYMLINK_SIZE 2
#define XP_STX_SYMLINK_LINK 0 #define ASE_STX_SYMLINK_LINK 0
#define XP_STX_SYMLINK_SYMBOL 1 #define ASE_STX_SYMLINK_SYMBOL 1
struct xp_stx_symlink_t struct ase_stx_symlink_t
{ {
xp_stx_objhdr_t header; ase_stx_objhdr_t header;
xp_word_t link; ase_word_t link;
xp_word_t symbol; ase_word_t symbol;
}; };
typedef struct xp_stx_symlink_t xp_stx_symlink_t; typedef struct ase_stx_symlink_t ase_stx_symlink_t;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
xp_word_t xp_stx_new_symbol_link (xp_stx_t* stx, xp_word_t sym); ase_word_t ase_stx_new_symbol_link (ase_stx_t* stx, ase_word_t sym);
xp_word_t xp_stx_new_symbol ( ase_word_t ase_stx_new_symbol (
xp_stx_t* stx, const xp_char_t* name); ase_stx_t* stx, const ase_char_t* name);
xp_word_t xp_stx_new_symbolx ( ase_word_t ase_stx_new_symbolx (
xp_stx_t* stx, const xp_char_t* name, xp_word_t len); ase_stx_t* stx, const ase_char_t* name, ase_word_t len);
void xp_stx_traverse_symbol_table ( void ase_stx_traverse_symbol_table (
xp_stx_t* stx, void (*func) (xp_stx_t*,xp_word_t,void*), void* data); ase_stx_t* stx, void (*func) (ase_stx_t*,ase_word_t,void*), void* data);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,77 +1,77 @@
/* /*
* $Id: token.c,v 1.10 2005-12-05 15:11:29 bacon Exp $ * $Id: token.c,v 1.11 2007-03-22 11:19:28 bacon Exp $
*/ */
#include <xp/stx/token.h> #include <ase/stx/token.h>
#include <xp/stx/misc.h> #include <ase/stx/misc.h>
xp_stx_token_t* xp_stx_token_open ( ase_stx_token_t* ase_stx_token_open (
xp_stx_token_t* token, xp_word_t capacity) ase_stx_token_t* token, ase_word_t capacity)
{ {
if (token == XP_NULL) { if (token == ASE_NULL) {
token = (xp_stx_token_t*) token = (ase_stx_token_t*)
xp_malloc (xp_sizeof(xp_stx_token_t)); ase_malloc (ase_sizeof(ase_stx_token_t));
if (token == XP_NULL) return XP_NULL; if (token == ASE_NULL) return ASE_NULL;
token->__dynamic = xp_true; token->__dynamic = ase_true;
} }
else token->__dynamic = xp_false; else token->__dynamic = ase_false;
if (xp_stx_name_open(&token->name, capacity) == XP_NULL) { if (ase_stx_name_open(&token->name, capacity) == ASE_NULL) {
if (token->__dynamic) xp_free (token); if (token->__dynamic) ase_free (token);
return XP_NULL; return ASE_NULL;
} }
/* /*
token->ivalue = 0; token->ivalue = 0;
token->fvalue = .0; token->fvalue = .0;
*/ */
token->type = XP_STX_TOKEN_END; token->type = ASE_STX_TOKEN_END;
return token; return token;
} }
void xp_stx_token_close (xp_stx_token_t* token) void ase_stx_token_close (ase_stx_token_t* token)
{ {
xp_stx_name_close (&token->name); ase_stx_name_close (&token->name);
if (token->__dynamic) xp_free (token); if (token->__dynamic) ase_free (token);
} }
int xp_stx_token_addc (xp_stx_token_t* token, xp_cint_t c) int ase_stx_token_addc (ase_stx_token_t* token, ase_cint_t c)
{ {
return xp_stx_name_addc (&token->name, c); return ase_stx_name_addc (&token->name, c);
} }
int xp_stx_token_adds (xp_stx_token_t* token, const xp_char_t* s) int ase_stx_token_adds (ase_stx_token_t* token, const ase_char_t* s)
{ {
return xp_stx_name_adds (&token->name, s); return ase_stx_name_adds (&token->name, s);
} }
void xp_stx_token_clear (xp_stx_token_t* token) void ase_stx_token_clear (ase_stx_token_t* token)
{ {
/* /*
token->ivalue = 0; token->ivalue = 0;
token->fvalue = .0; token->fvalue = .0;
*/ */
token->type = XP_STX_TOKEN_END; token->type = ASE_STX_TOKEN_END;
xp_stx_name_clear (&token->name); ase_stx_name_clear (&token->name);
} }
xp_char_t* xp_stx_token_yield (xp_stx_token_t* token, xp_word_t capacity) ase_char_t* ase_stx_token_yield (ase_stx_token_t* token, ase_word_t capacity)
{ {
xp_char_t* p; ase_char_t* p;
p = xp_stx_name_yield (&token->name, capacity); p = ase_stx_name_yield (&token->name, capacity);
if (p == XP_NULL) return XP_NULL; if (p == ASE_NULL) return ASE_NULL;
/* /*
token->ivalue = 0; token->ivalue = 0;
token->fvalue = .0; token->fvalue = .0;
*/ */
token->type = XP_STX_TOKEN_END; token->type = ASE_STX_TOKEN_END;
return p; return p;
} }
int xp_stx_token_compare_name (xp_stx_token_t* token, const xp_char_t* str) int ase_stx_token_compare_name (ase_stx_token_t* token, const ase_char_t* str)
{ {
return xp_stx_name_compare (&token->name, str); return ase_stx_name_compare (&token->name, str);
} }

View File

@ -1,63 +1,63 @@
/* /*
* $Id: token.h,v 1.18 2005-12-05 15:11:29 bacon Exp $ * $Id: token.h,v 1.19 2007-03-22 11:19:28 bacon Exp $
*/ */
#ifndef _XP_STX_TOKEN_H_ #ifndef _ASE_STX_TOKEN_H_
#define _XP_STX_TOKEN_H_ #define _ASE_STX_TOKEN_H_
#include <xp/stx/stx.h> #include <ase/stx/stx.h>
#include <xp/stx/name.h> #include <ase/stx/name.h>
enum enum
{ {
XP_STX_TOKEN_END, ASE_STX_TOKEN_END,
XP_STX_TOKEN_CHARLIT, ASE_STX_TOKEN_CHARLIT,
XP_STX_TOKEN_STRLIT, ASE_STX_TOKEN_STRLIT,
XP_STX_TOKEN_SYMLIT, ASE_STX_TOKEN_SYMLIT,
XP_STX_TOKEN_NUMLIT, ASE_STX_TOKEN_NUMLIT,
XP_STX_TOKEN_IDENT, ASE_STX_TOKEN_IDENT,
XP_STX_TOKEN_BINARY, ASE_STX_TOKEN_BINARY,
XP_STX_TOKEN_KEYWORD, ASE_STX_TOKEN_KEYWORD,
XP_STX_TOKEN_PRIMITIVE, ASE_STX_TOKEN_PRIMITIVE,
XP_STX_TOKEN_ASSIGN, ASE_STX_TOKEN_ASSIGN,
XP_STX_TOKEN_COLON, ASE_STX_TOKEN_COLON,
XP_STX_TOKEN_RETURN, ASE_STX_TOKEN_RETURN,
XP_STX_TOKEN_LBRACKET, ASE_STX_TOKEN_LBRACKET,
XP_STX_TOKEN_RBRACKET, ASE_STX_TOKEN_RBRACKET,
XP_STX_TOKEN_LPAREN, ASE_STX_TOKEN_LPAREN,
XP_STX_TOKEN_RPAREN, ASE_STX_TOKEN_RPAREN,
XP_STX_TOKEN_APAREN, ASE_STX_TOKEN_APAREN,
XP_STX_TOKEN_PERIOD, ASE_STX_TOKEN_PERIOD,
XP_STX_TOKEN_SEMICOLON ASE_STX_TOKEN_SEMICOLON
}; };
struct xp_stx_token_t struct ase_stx_token_t
{ {
int type; int type;
/* /*
xp_stx_int_t ivalue; ase_stx_int_t ivalue;
xp_stx_real_t fvalue; ase_stx_real_t fvalue;
*/ */
xp_stx_name_t name; ase_stx_name_t name;
xp_bool_t __dynamic; ase_bool_t __dynamic;
}; };
typedef struct xp_stx_token_t xp_stx_token_t; typedef struct ase_stx_token_t ase_stx_token_t;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
xp_stx_token_t* xp_stx_token_open ( ase_stx_token_t* ase_stx_token_open (
xp_stx_token_t* token, xp_word_t capacity); ase_stx_token_t* token, ase_word_t capacity);
void xp_stx_token_close (xp_stx_token_t* token); void ase_stx_token_close (ase_stx_token_t* token);
int xp_stx_token_addc (xp_stx_token_t* token, xp_cint_t c); int ase_stx_token_addc (ase_stx_token_t* token, ase_cint_t c);
int xp_stx_token_adds (xp_stx_token_t* token, const xp_char_t* s); int ase_stx_token_adds (ase_stx_token_t* token, const ase_char_t* s);
void xp_stx_token_clear (xp_stx_token_t* token); void ase_stx_token_clear (ase_stx_token_t* token);
xp_char_t* xp_stx_token_yield (xp_stx_token_t* token, xp_word_t capacity); ase_char_t* ase_stx_token_yield (ase_stx_token_t* token, ase_word_t capacity);
int xp_stx_token_compare_name (xp_stx_token_t* token, const xp_char_t* str); int ase_stx_token_compare_name (ase_stx_token_t* token, const ase_char_t* str);
#ifdef __cplusplus #ifdef __cplusplus
} }