rev 542 - in trunk: . include/prothon modules/File modules/OS modules/Prosist modules/Re pr/test src
SVN User <[email protected]> Mon, 24 May 2004 16:44:57 -0400
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-05-24 16:44:53 -0400 (Mon, 24 May 2004)
New Revision: 542
Modified:
trunk/STATUS.txt
trunk/include/prothon/prothon.h
trunk/include/prothon/prothon_dll.h
trunk/modules/File/File.c
trunk/modules/OS/OS.c
trunk/modules/Prosist/Prosist.c
trunk/modules/Re/Re.c
trunk/pr/test/test.pr
trunk/src/builtins-attrdict.c
trunk/src/builtins-core.c
trunk/src/builtins-dict.c
trunk/src/builtins-float.c
trunk/src/builtins-int.c
trunk/src/builtins-list.c
trunk/src/builtins-string.c
trunk/src/builtins-tuple.c
trunk/src/bytecodes.h
trunk/src/getline.c
trunk/src/getline.h
trunk/src/interp.c
trunk/src/memory_mgr.c
trunk/src/object.c
trunk/src/object.h
trunk/src/parser.h
trunk/src/parser_routines.c
trunk/src/prothon.y
trunk/src/symbol.c
trunk/src/sys.c
Log:
changed ante to super, fixed attrs_, removed attrs()
Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/STATUS.txt 2004-05-24 20:44:53 UTC (rev 542)
@@ -54,7 +54,7 @@
----------------------- TUTORIAL TO-DO ------------------------
attrs_
- ante
+ super
modules
Inheriting from binary objects, uninitialized objects
print statement
Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/include/prothon/prothon.h 2004-05-24 20:44:53 UTC (rev 542)
@@ -284,7 +284,7 @@
SLICE_PROTO, // 17 Slice
LOCAL_PROTO, // 18
OUTER_PROTO, // 19
- ANTE_PROTO, // 20
+ SUPER_PROTO, // 20
GEN_PROTO, // 21
THREAD_PROTO, // 22 Thread
MUTEX_PROTO, // 23 Mutex
@@ -428,6 +428,8 @@
ACCLEVEL_,
CONT_,
NAME_,
+ ATTRS_,
+ PROTOS_,
SYM_ENUM_COUNT
} sym_enum_t;
@@ -587,13 +589,13 @@
// HAS_PROTO: Returns TRUE if second object is in reachable proto list of first object
// The ist param may return an exception object if proto pointers are missing
// or have a circular reference. See section "INTERPRETER STATE" below.
-int has_proto_QUES(isp ist, obj_p obj, obj_p obj_proto);
+int has_proto(isp ist, obj_p obj, obj_p obj_proto);
// CHECK_TYPE_EXC: Convenience macro for type validation of objects
// (usually parms[1])
#define CHECK_TYPE_EXC(__obj, __proto_obj, name) \
do { \
- if (!has_proto_QUES(ist, __obj, __proto_obj)) { \
+ if (!has_proto(ist, __obj, __proto_obj)) { \
raise_exception(ist, OBJ(TYPE_EXC), \
"object is not of type " #name); \
return NULL; \
@@ -859,13 +861,13 @@
// in an object. In this case the data is an local variable with no prefix.
obj_p new_local_obj(isp ist, obj_p symbol);
-// NEW_ANTE_OBJ: This represents the reference of an ante variable like "ante.var"
+// NEW_SUPER_OBJ: This represents the reference of an super variable like "super.var"
// This is much like a slice in that it indicates how data is to be referenced
-// in an object. In this case the data is an ante prefixed variable like "ante.var".
-// An Ante reference is the same as "self" with lookup of the var happening on the
+// in an object. In this case the data is an super prefixed variable like "super.var".
+// An Super reference is the same as "self" with lookup of the var happening on the
// prototype of "self" except that all matches are ignored until the prototype
// "container" is passed by on the prototype chain of "self".
-obj_p new_ante_obj(isp ist, obj_p container, obj_p symbol) ;
+obj_p new_super_obj(isp ist, obj_p container, obj_p symbol) ;
//************************* Prothon C FUNCTION ********************************
// This is the type of C function that the dll author must provide to implement
@@ -917,7 +919,7 @@
#define ITEM (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index))
#define INT_32_PARAM(index, var) /* int var; */ \
-{ if (!has_proto_QUES(ist, (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)), OBJ(INT_PROTO))) { \
+{ if (!has_proto(ist, (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)), OBJ(INT_PROTO))) { \
raise_exception(ist, OBJ(TYPE_EXC), \
"expected a integer in parameter " #index); \
return NULL; \
@@ -925,7 +927,7 @@
(var) = (int) (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index))->data.i64; }
#define INT_64_PARAM(index, var) /* i64_t var; */ \
-{ if (!has_proto_QUES(ist, (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)), OBJ(INT_PROTO))) { \
+{ if (!has_proto(ist, (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)), OBJ(INT_PROTO))) { \
raise_exception(ist, OBJ(TYPE_EXC), \
"expected a integer in parameter " #index); \
return (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)); \
@@ -933,7 +935,7 @@
(var) = (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index))->data.i64; }
#define STRING_PARAM(index, var) \
-{ if (!has_proto_QUES(ist, (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)), OBJ(STRING_PROTO))) { \
+{ if (!has_proto(ist, (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)), OBJ(STRING_PROTO))) { \
raise_exception(ist, OBJ(TYPE_EXC), \
"expected a string in parameter " #index); \
return NULL; \
@@ -941,7 +943,7 @@
#define FUNC___PARAM(index, var) /* obj_p var; */ \
-{ if (!has_proto_QUES(ist, (index > 0 ? parms[((index)-1)*2+1] : \
+{ if (!has_proto(ist, (index > 0 ? parms[((index)-1)*2+1] : \
list_item(ist, parms[1], -index)) , \
OBJ(FUNC_PROTO))) { \
raise_exception(ist, OBJ(TYPE_EXC), \
@@ -951,7 +953,7 @@
(var) = (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)); }
#define FLOAT__PARAM(index, var) /* double var; */ \
-{ if (!has_proto_QUES(ist, (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)) , OBJ(FLOAT_PROTO))) { \
+{ if (!has_proto(ist, (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)) , OBJ(FLOAT_PROTO))) { \
raise_exception(ist, OBJ(TYPE_EXC), \
"expected a float in parameter " #index); \
return NULL; \
@@ -959,7 +961,7 @@
(var) = (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index))->data.f64; }
#define STRBIN_PARAM(index, var) /* apr_datum_t var; */ \
-{ if (!has_proto_QUES(ist, (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)), OBJ(STRING_PROTO))) { \
+{ if (!has_proto(ist, (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)), OBJ(STRING_PROTO))) { \
raise_exception(ist, OBJ(TYPE_EXC), \
"expected a string in parameter " #index); \
return NULL; \
@@ -968,8 +970,8 @@
(var).dsize = pr_strlen((index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index))); }
#define SEQ_NS_PARAM(index, var) /* obj_p var; */ \
-{ if ( has_proto_QUES(ist, (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)), OBJ(STRING_PROTO)) || \
- !has_proto_QUES(ist, (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)), OBJ(SEQ_PROTO))) { \
+{ if ( has_proto(ist, (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)), OBJ(STRING_PROTO)) || \
+ !has_proto(ist, (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, parms[1], -index)), OBJ(SEQ_PROTO))) { \
raise_exception(ist, OBJ(TYPE_EXC), \
"expected a Tuple or List in parameter " #index); \
return NULL; \
@@ -978,8 +980,8 @@
#define SEQ_OR_PARAM(index, var) /* obj_p var; */ \
- if ( has_proto_QUES(ist, ITEM, OBJ(STRING_PROTO)) || \
- !has_proto_QUES(ist, ITEM, OBJ(SEQ_PROTO))) { \
+ if ( has_proto(ist, ITEM, OBJ(STRING_PROTO)) || \
+ !has_proto(ist, ITEM, OBJ(SEQ_PROTO))) { \
list = NEW_LIST(1); \
list_append(ist, list, ITEM); \
(var) = list; \
Modified: trunk/include/prothon/prothon_dll.h
===================================================================
--- trunk/include/prothon/prothon_dll.h 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/include/prothon/prothon_dll.h 2004-05-24 20:44:53 UTC (rev 542)
@@ -72,7 +72,7 @@
int (*del_attr)(isp ist, obj_p obj, obj_p key);
int (*ins_proto)(isp ist, obj_p obj, obj_p proto, int pos);
int (*del_proto)(isp ist, obj_p obj, obj_p proto);
- int (*has_proto_QUES)(isp ist, obj_p obj, obj_p obj_proto);
+ int (*has_proto)(isp ist, obj_p obj, obj_p obj_proto);
void (*switch_proto)(isp ist, obj_p obj, obj_p new_proto);
obj_p (*list_append)(isp ist, obj_p list_obj, obj_p item);
obj_p (*list_item)(isp ist, obj_p list, int i);
@@ -272,7 +272,7 @@
#define del_attr (*services->del_attr)
#define ins_proto (*services->ins_proto)
#define del_proto (*services->del_proto)
-#define has_proto_QUES (*services->has_proto_QUES)
+#define has_proto (*services->has_proto)
#define switch_proto (*services->switch_proto)
#define list_append (*services->list_append)
#define list_item (*services->list_item)
Modified: trunk/modules/File/File.c
===================================================================
--- trunk/modules/File/File.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/modules/File/File.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -200,7 +200,7 @@
DEF(File, closed_QUES, NULL) {
BIN_CONTENT_CHK(File);
- if (!has_proto_QUES(ist, self, File_OBJ)) {
+ if (!has_proto(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "closed can only be called on a File object");
return NULL;
}
@@ -210,7 +210,7 @@
DEF(File, flush, NULL) {
BIN_CONTENT_CHK(File);
- if (!has_proto_QUES(ist, self, File_OBJ)) {
+ if (!has_proto(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "flush can only be called on a File object");
return NULL;
}
@@ -227,7 +227,7 @@
#if 0
DEF(File, fileNo, NULL) {
BIN_CONTENT_CHK(File);
- if (!has_proto_QUES(ist, self, File_OBJ)) {
+ if (!has_proto(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "fileNo can only be called on a File object");
return NULL;
}
@@ -261,7 +261,7 @@
BIN_CONTENT_CHK(File);
INT_64_PARAM(1, size_in);
- if (!has_proto_QUES(ist, self, File_OBJ)) {
+ if (!has_proto(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "read can only be called on a File object");
return NULL;
}
@@ -339,7 +339,7 @@
BIN_CONTENT_CHK(File);
INT_64_PARAM(1, size_in);
- if (!has_proto_QUES(ist, self, File_OBJ)) {
+ if (!has_proto(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "readLine can only be called on a File object");
return NULL;
}
@@ -415,7 +415,7 @@
BIN_CONTENT_CHK(File);
INT_64_PARAM(1, size_in);
- if (!has_proto_QUES(ist, self, File_OBJ)) {
+ if (!has_proto(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "readLines can only be called on a File object");
return NULL;
}
@@ -498,7 +498,7 @@
INT_64_PARAM(1, pos_in);
INT_64_PARAM(2, how);
- if (!has_proto_QUES(ist, self, File_OBJ)) {
+ if (!has_proto(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "seek can only be called on a File object");
return NULL;
}
@@ -543,7 +543,7 @@
BIN_CONTENT_CHK(File);
INT_64_PARAM(1, size_in);
- if (!has_proto_QUES(ist, self, File_OBJ)) {
+ if (!has_proto(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "truncate can only be called on a File object");
return NULL;
}
@@ -579,7 +579,7 @@
STRING_PARAM(1, str);
size = pr_strlen(parms[1]);
- if (!has_proto_QUES(ist, self, File_OBJ)) {
+ if (!has_proto(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "write can only be called from a File object");
return NULL;
}
@@ -607,11 +607,11 @@
apr_status_t aprerr;
char err_buf[1024];
- if (!has_proto_QUES(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
+ if (!has_proto(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto(ist, parms[1], OBJ(STRING_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "file writeLines parameter must be a sequence or a string");
return NULL;
}
- if (!has_proto_QUES(ist, self, File_OBJ)) {
+ if (!has_proto(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "writeLines can only be called on a File object");
return NULL;
}
@@ -623,7 +623,7 @@
raise_exception(ist, OBJ(IOEXCEPTION), "writeLines called on file opened without write perms");
return NULL;
}
- if (has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
+ if (has_proto(ist, parms[1], OBJ(STRING_PROTO))) {
str = pr_strptr(parms[1]);
size = pr_strlen(parms[1]);
aprerr = apr_file_write(STREAM(self), str, &size);
@@ -636,7 +636,7 @@
int i, llen = (int) list_len(ist, parms[1]);
for(i = 0; i < llen; i++) {
obj_p item = list_item(ist, parms[1], i);
- if (!has_proto_QUES(ist, item, OBJ(STRING_PROTO))) {
+ if (!has_proto(ist, item, OBJ(STRING_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "file writeLines lst item must be a string");
return NULL;
}
@@ -655,7 +655,7 @@
DEF(File, setStdOut, FORM_RPARAM) {
int i;
- if (!has_proto_QUES(ist, parms[1], File_OBJ)) {
+ if (!has_proto(ist, parms[1], File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "stdout can only be assigned to a file object");
return NULL;
}
Modified: trunk/modules/OS/OS.c
===================================================================
--- trunk/modules/OS/OS.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/modules/OS/OS.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -68,7 +68,7 @@
}
DEF(OS, system, FPARM1(cmd, NULL)) {
- if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
+ if (!has_proto(ist, parms[1], OBJ(STRING_PROTO))) {
ist->exception_obj = NEW_OBJ(OBJ(TYPE_EXC));
ist->exception_obj->wr_access = ACC_GUEST;
set_obj_doc(ist->exception_obj, "object is not of type string");
Modified: trunk/modules/Prosist/Prosist.c
===================================================================
--- trunk/modules/Prosist/Prosist.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/modules/Prosist/Prosist.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -327,10 +327,10 @@
ADD_CHR(':');
ADD_MEM(&(proxy_obj->data), 8);
}
- if (has_proto_QUES(ist, proxy_obj, OBJ(STRING_PROTO))) {
+ if (has_proto(ist, proxy_obj, OBJ(STRING_PROTO))) {
ADD_CHR('s');
ADD_MEM(pr_strptr(proxy_obj), (int) pr_strlen(proxy_obj));
- } else if (has_proto_QUES(ist, proxy_obj, OBJ(TUPLE_PROTO))) {
+ } else if (has_proto(ist, proxy_obj, OBJ(TUPLE_PROTO))) {
int llen = (int) list_len(ist, proxy_obj);
ADD_CHR('l');
for (i=0; i < llen; i++) {
@@ -362,7 +362,7 @@
for(i=0; i < llen; i++) {
obj_p item = list_item(ist, olst, i);
if (item != PSNONE) {
- if (has_proto_QUES(ist, item, MutWrap_OBJ))
+ if (has_proto(ist, item, MutWrap_OBJ))
item = (obj_p) item->data.ptr;
read_unlock(ist, item);
}
@@ -376,7 +376,7 @@
for(i=0; i < llen; i++) {
obj_p item = list_item(ist, olst, i);
if (item != PSNONE) {
- if (has_proto_QUES(ist, item, MutWrap_OBJ))
+ if (has_proto(ist, item, MutWrap_OBJ))
item = (obj_p) item->data.ptr;
read_unlock(ist, item);
}
@@ -507,8 +507,8 @@
return;
}
if (proxy_obj->data_type == DATA_TYPE_DATAPTR) {
- tuple_type = has_proto_QUES(ist, proxy_obj, OBJ(TUPLE_PROTO));
- if (!tuple_type && !has_proto_QUES(ist, proxy_obj, OBJ(STRING_PROTO))) {
+ tuple_type = has_proto(ist, proxy_obj, OBJ(TUPLE_PROTO));
+ if (!tuple_type && !has_proto(ist, proxy_obj, OBJ(STRING_PROTO))) {
raise_exception(ist, ProsistExc_OBJ, "unstorable object (data ptr) found in tree");
del_unlock(mw_obj);
del_unlock(id_obj);
Modified: trunk/modules/Re/Re.c
===================================================================
--- trunk/modules/Re/Re.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/modules/Re/Re.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -391,8 +391,8 @@
int i, last_index=0, repl_is_func=FALSE, count, err, ngrps = numgrps(self);
BIN_CONTENT_CHK(ReCompiled);
- if ( !has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO)) &&
- !(repl_is_func=has_proto_QUES(ist, parms[1], OBJ(FUNC_PROTO))) ) {
+ if ( !has_proto(ist, parms[1], OBJ(STRING_PROTO)) &&
+ !(repl_is_func=has_proto(ist, parms[1], OBJ(FUNC_PROTO))) ) {
raise_exception(ist, OBJ(TYPE_EXC), "sub repl parameter must be a string or function");
return NULL;
}
@@ -453,7 +453,7 @@
if_exc_return NULL;
if (repl_obj == OBJ(NONE)) repl = "";
else {
- if (!has_proto_QUES(ist, repl_obj, OBJ(STRING_PROTO))) {
+ if (!has_proto(ist, repl_obj, OBJ(STRING_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "repl callback function must return a string");
return NULL;
}
@@ -593,7 +593,7 @@
int llen = (int)list_len(ist, parms[3]);
for (i=0; i < llen; i++) {
obj_p item = list_item(ist, parms[3], i);
- if (!has_proto_QUES(ist, item, OBJ(INT_PROTO))) {
+ if (!has_proto(ist, item, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "groupid parameters must be integers");
return NULL;
}
Modified: trunk/pr/test/test.pr
===================================================================
--- trunk/pr/test/test.pr 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/pr/test/test.pr 2004-05-24 20:44:53 UTC (rev 542)
@@ -1,8 +1,8 @@
#!/usr/bin/env prothon
-gen foo():
- for i in 10:
- yield i
-
-for n in foo():
- print n
+x = 1
+
+x.attrs_ = {`a:1, `b:2}
+print x.attrs_, x.a, x.b
+x.attrs_.clear!()
+print x.attrs_
Modified: trunk/src/builtins-attrdict.c
===================================================================
--- trunk/src/builtins-attrdict.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/builtins-attrdict.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -66,7 +66,7 @@
MODULE_DECLARE(AttrDict);
-// ***************************** attr2dict ************************************
+// ***************************** new_attrdict_obj *****************************
obj_p new_attrdict_obj(isp ist, obj_p obj) {
obj_p self = new_object(ist, AttrDict_OBJ);
self->data_type = DATA_TYPE_DATAPTR;
@@ -99,6 +99,37 @@
return dict_obj;
}
+// ***************************** dict2attr ************************************
+void dict2attr(isp ist, obj_p dict, obj_p obj) {
+ obj_p dict_list = dict_keys_values(ist, dict, 2 /*list*/);
+ int i, llen = (int) list_len(ist, dict_list);
+ if_exc_return;
+
+ write_lock(ist, obj);
+ if (obj->has_attrs) {
+ attr_p attrp = obj->attr_proto.attrs;
+ memset(attr_ap(attrp, 0), 0, attr_asize(attrp) * sizeof(attr_t));
+ attr_alen(attrp) = 0;
+ } else if (llen) {
+ add_attrs(obj);
+ } else {
+ write_unlock(ist, obj);
+ return;
+ }
+ write_unlock(ist, obj);
+ for (i = 0; i < llen; i += 2) {
+ obj_p key = list_item(ist, dict_list, i);
+ if (has_proto(ist, key, OBJ(STRING_PROTO)))
+ key = sym(ist, pr_strptr(key));
+ if (!has_proto(ist, key, OBJ(SYMBOL_PROTO))) {
+ raise_exception(ist, OBJ(TYPE_EXC), "attrs_ key must be a string or symbol");
+ return;
+ }
+ set_attr(ist, obj, key, list_item(ist, dict_list, i+1));
+ }
+ return ;
+}
+
// ***************************** ATTRDICT *************************************
MODULE_START(AttrDict)
@@ -178,10 +209,10 @@
return NULL;
}
index = list_item(ist, parms[1], 0);
- if (has_proto_QUES(ist, index, OBJ(SYMBOL_PROTO)))
- res = call_func1(ist, self->data.ptr, SYM(GETITEM_), index);
- else if (has_proto_QUES(ist, index, OBJ(STRING_PROTO))) {
- res = call_func1(ist, self->data.ptr, SYM(GETITEM_), sym(ist, pr_strptr(index)));
+ if (has_proto(ist, index, OBJ(SYMBOL_PROTO)))
+ res = get_attr(ist, self->data.ptr, index);
+ else if (has_proto(ist, index, OBJ(STRING_PROTO))) {
+ res = get_attr(ist, self->data.ptr, sym(ist, pr_strptr(index)));
} else
raise_exception(ist, OBJ(TYPE_EXC), "attrs_ index must be a string or symbol");
return res;
@@ -195,10 +226,10 @@
return NULL;
}
index = list_item(ist, parms[1], 0);
- if (has_proto_QUES(ist, index, OBJ(SYMBOL_PROTO)))
- call_func2(ist, self->data.ptr, SYM(SETITEM_), index, parms[3]);
- else if (has_proto_QUES(ist, index, OBJ(STRING_PROTO))) {
- call_func2(ist, self->data.ptr, SYM(SETITEM_), sym(ist, pr_strptr(index)), parms[3]);
+ if (has_proto(ist, index, OBJ(SYMBOL_PROTO)))
+ set_attr(ist, self->data.ptr, index, parms[3]);
+ else if (has_proto(ist, index, OBJ(STRING_PROTO))) {
+ set_attr(ist, self->data.ptr, sym(ist, pr_strptr(index)), parms[3]);
} else
raise_exception(ist, OBJ(TYPE_EXC), "attrs_ index must be a string or symbol");
return NULL;
@@ -212,10 +243,10 @@
return NULL;
}
index = list_item(ist, parms[1], 0);
- if (has_proto_QUES(ist, index, OBJ(SYMBOL_PROTO)))
- call_func1(ist, self->data.ptr, SYM(DELITEM_), index);
- else if (has_proto_QUES(ist, index, OBJ(STRING_PROTO))) {
- call_func1(ist, self->data.ptr, SYM(DELITEM_), sym(ist, pr_strptr(index)));
+ if (has_proto(ist, index, OBJ(SYMBOL_PROTO)))
+ del_attr(ist, self->data.ptr, index);
+ else if (has_proto(ist, index, OBJ(STRING_PROTO))) {
+ del_attr(ist, self->data.ptr, sym(ist, pr_strptr(index)));
} else
raise_exception(ist, OBJ(TYPE_EXC), "attrs_ index must be a string or symbol");
return NULL;
Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/builtins-core.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -72,7 +72,7 @@
MODULE_DECLARE(Exception);
MODULE_DECLARE(Gen);
MODULE_DECLARE(Local);
-MODULE_DECLARE(Ante);
+MODULE_DECLARE(Super);
MODULE_DECLARE(Seq);
MODULE_DECLARE(Func);
MODULE_DECLARE(Method);
@@ -90,7 +90,7 @@
set_obj_doc(OBJ(SLICE_PROTO), "Slice object prototype");
set_obj_doc(OBJ(LOCAL_PROTO), "Local object prototype");
set_obj_doc(OBJ(OUTER_PROTO), "Outer object prototype");
- set_obj_doc(OBJ(ANTE_PROTO), "Ante object prototype");
+ set_obj_doc(OBJ(SUPER_PROTO), "Super object prototype");
set_obj_doc(OBJ(ROOT_GLOBALS), "Root_Globals: recursive container of all objects");
set_obj_doc(OBJ(MODULES), "Modules: container of all modules");
@@ -113,6 +113,10 @@
return OBJ(NONE);
}
+DEF(Object, del_, NULL) {
+ return OBJ(NONE);
+}
+
DEF(Object, objId_, NULL) {
return NEW_INT((intptr_t) self);
}
@@ -159,7 +163,7 @@
}
DEF(Object, hasProto_QUES, FORM_RPARAM) {
- if (has_proto_QUES(ist, self, parms[1]))
+ if (has_proto(ist, self, parms[1]))
return OBJ(PR_TRUE);
else
return OBJ(PR_FALSE);
@@ -352,10 +356,6 @@
return call_func1(ist, parms[1], SYM(RNOTIN__QUES), self);
}
-DEF(Object, attrs, NULL) {
- return new_attrdict_obj(ist, self);
-}
-
DEF(Object, CurrentThread, NULL) {
return os_thread_2_obj(apr_os_thread_current());
}
@@ -540,19 +540,21 @@
}
DEF(Local, str_, NULL) {
+ BIN_STR_CHK(Local);
return call_func0(ist, self->data.ptr, SYM(STR_));
}
-// ***************************** ANTE ******************************************
-MODULE_START(Ante)
+// ***************************** SUPER ******************************************
+MODULE_START(Super)
{
- Ante_OBJ = OBJ(ANTE_PROTO);
- MODULE_SET_DOC(Ante, "ante object prototype");
- set_attr(ist, OBJ(OBJECT), sym(ist, "Ante"), Ante_OBJ);
- set_obj_id(Ante_OBJ, *, Ante);
+ Super_OBJ = OBJ(SUPER_PROTO);
+ MODULE_SET_DOC(Super, "super object prototype");
+ set_attr(ist, OBJ(OBJECT), sym(ist, "Super"), Super_OBJ);
+ set_obj_id(Super_OBJ, *, Super);
}
-DEF(Ante, str_, NULL) {
+DEF(Super, str_, NULL) {
+ BIN_STR_CHK(Super);
return call_func0(ist, self->data.ptr, SYM(STR_));
}
@@ -584,7 +586,7 @@
if (item) {
if ((uintptr_t) item > 10) {
- is_str = has_proto_QUES(ist, item, OBJ(STRING_PROTO));
+ is_str = has_proto(ist, item, OBJ(STRING_PROTO));
item_str = as_str(ist, item);
} else {
apr_snprintf(msg, sizeof(msg), "<objptr:%lx>", (unsigned long)(uintptr_t)item);
@@ -805,6 +807,7 @@
MODULE_SUB_INIT(Object);
MODULE_ADD_SYM(Object, call_);
MODULE_ADD_SYM(Object, init_);
+ MODULE_ADD_SYM(Object, del_);
MODULE_ADD_SYM(Object, objId_);
MODULE_ADD_SYM(Object, debug_);
MODULE_ADD_SYM(Object, Proto);
@@ -840,7 +843,6 @@
MODULE_ADD_SYM(Object, ge__QUES);
MODULE_ADD_SYM(Object, in__QUES);
MODULE_ADD_SYM(Object, notIn__QUES);
- MODULE_ADD_SYM(Object, attrs);
MODULE_ADD_SYM(Object, CurrentThread);
MODULE_ADD_SYM(Object, Sleep);
MODULE_ADD_SYM(Object, toStorProxy_);
@@ -878,8 +880,8 @@
MODULE_SUB_INIT(Local);
MODULE_ADD_SYM(Local, str_);
- MODULE_SUB_INIT(Ante);
- MODULE_ADD_SYM(Ante, str_);
+ MODULE_SUB_INIT(Super);
+ MODULE_ADD_SYM(Super, str_);
MODULE_SUB_INIT(Func);
MODULE_ADD_SYM(Func, init_);
Modified: trunk/src/builtins-dict.c
===================================================================
--- trunk/src/builtins-dict.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/builtins-dict.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -113,7 +113,7 @@
//********************************* hash_value ********************************
i32_t hash_value(isp ist, obj_p key_in) {
- if (has_proto_QUES(ist, key_in, OBJ(INT_PROTO)))
+ if (has_proto(ist, key_in, OBJ(INT_PROTO)))
return ((i32_t) key_in->data.i64);
else {
obj_p hash_obj = call_func0(ist, key_in, SYM(HASH_));
@@ -310,8 +310,8 @@
obj_p item2 = list_item(ist, vals,i);
char* str1 = as_str(ist, item1);
char* str2 = as_str(ist, item2);
- int is_str1 = has_proto_QUES(ist, item1, OBJ(STRING_PROTO));
- int is_str2 = has_proto_QUES(ist, item2, OBJ(STRING_PROTO));
+ int is_str1 = has_proto(ist, item1, OBJ(STRING_PROTO));
+ int is_str2 = has_proto(ist, item2, OBJ(STRING_PROTO));
if (str1 == NULL)
str1 = "(null)";
Modified: trunk/src/builtins-float.c
===================================================================
--- trunk/src/builtins-float.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/builtins-float.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -68,7 +68,7 @@
#define FLOAT_DATA_SIZE 8
-#define is_Float(objid) (has_proto_QUES(ist, objid, Float_OBJ))
+#define is_Float(objid) (has_proto(ist, objid, Float_OBJ))
#define Float_value(objid) (objid->data.f64)
//********************************* new_float_obj *****************************
@@ -159,7 +159,7 @@
BIN_CONTENT_CHK(Float);
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
+ if (has_proto(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
if (covers(other, self))
@@ -177,7 +177,7 @@
BIN_CONTENT_CHK(Float);
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
+ if (has_proto(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
if (covers(other, self))
@@ -199,7 +199,7 @@
BIN_CONTENT_CHK(Float);
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
+ if (has_proto(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
raise_exception(ist, OBJ(TYPE_EXC), "Float cannot be divided into this object");
@@ -219,7 +219,7 @@
BIN_CONTENT_CHK(Float);
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
+ if (has_proto(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
if (covers(other, self))
@@ -237,7 +237,7 @@
BIN_CONTENT_CHK(Float);
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
+ if (has_proto(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
if (covers(other, self))
@@ -254,7 +254,7 @@
obj_p other = parms[1];
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
+ if (has_proto(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
raise_exception(ist, OBJ(TYPE_EXC), "this object cannot be subtracted from a float");
@@ -270,7 +270,7 @@
BIN_CONTENT_CHK(Float);
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
+ if (has_proto(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
if (covers(other, self))
@@ -288,7 +288,7 @@
BIN_CONTENT_CHK(Float);
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
+ if (has_proto(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
raise_exception(ist, OBJ(TYPE_EXC), "this object cannot be in a pow function with a float");
@@ -305,7 +305,7 @@
BIN_CONTENT_CHK(Float);
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
+ if (has_proto(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
if (covers(other, self))
@@ -328,7 +328,7 @@
BIN_CONTENT_CHK(Float);
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
+ if (has_proto(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
raise_exception(ist, OBJ(TYPE_EXC), "this object cannot compared to a float");
@@ -349,7 +349,7 @@
BIN_CONTENT_CHK(Float);
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
+ if (has_proto(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
if (covers(other, self))
@@ -370,15 +370,15 @@
DEF(Float, covers__QUES, FORM_RPARAM) {
BIN_CONTENT_CHK(Float);
- if (has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) return OBJ(PR_TRUE);
+ if (has_proto(ist, parms[1], OBJ(INT_PROTO))) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
DEF(Float, coerce_, FORM_RPARAM) {
BIN_CONTENT_CHK(Float);
- if (has_proto_QUES(ist, parms[1], OBJ(INT_PROTO)))
+ if (has_proto(ist, parms[1], OBJ(INT_PROTO)))
return NEW_FLOAT((double)(parms[1]->data.i64));
- else if (has_proto_QUES(ist, parms[1], Float_OBJ))
+ else if (has_proto(ist, parms[1], Float_OBJ))
return NEW_FLOAT(parms[1]->data.f64);
else
raise_exception(ist, OBJ(TYPE_EXC), "This object cannot be coerced to a Float");
Modified: trunk/src/builtins-int.c
===================================================================
--- trunk/src/builtins-int.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/builtins-int.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -81,7 +81,7 @@
// ***************************** INT *******************************************
#define INT_DATA_SIZE 8
-#define is_Int(objid) (has_proto_QUES(ist, objid, Int_OBJ))
+#define is_Int(objid) (has_proto(ist, objid, Int_OBJ))
#define Int_value(objid) (objid->data.i64)
static obj_p SYM_LIMIT;
Modified: trunk/src/builtins-list.c
===================================================================
--- trunk/src/builtins-list.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/builtins-list.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -67,14 +67,14 @@
MODULE_DECLARE(List);
static int seq_len(isp ist, obj_p seq) {
- if (has_proto_QUES(ist, seq, OBJ(STRING_PROTO)))
+ if (has_proto(ist, seq, OBJ(STRING_PROTO)))
return (int) strlen(pr_strptr(seq));
else return (int) list_len(ist, seq);
}
static obj_p seq_item(isp ist, obj_p seq, int i) {
char s[2];
- if (has_proto_QUES(ist, seq, OBJ(STRING_PROTO))) {
+ if (has_proto(ist, seq, OBJ(STRING_PROTO))) {
s[0] = pr_strptr(seq)[i];
s[1] = 0;
return NEW_STRING(s);
@@ -345,7 +345,7 @@
if (slice_item1 == SLICEPARAM_EMPTY || slice_item1 == OBJ(NONE))
slice1_empty=TRUE;
else {
- if (!has_proto_QUES(ist, slice_item1, OBJ(INT_PROTO))) {
+ if (!has_proto(ist, slice_item1, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "List slice index must be an integer");
def_write_unlock(self);
return NULL;
@@ -364,9 +364,9 @@
return NULL;
}
}
- if ( !has_proto_QUES(ist, value, List_OBJ) &&
- !has_proto_QUES(ist, value, OBJ(TUPLE_PROTO)) &&
- !has_proto_QUES(ist, value, OBJ(STRING_PROTO)) ) {
+ if ( !has_proto(ist, value, List_OBJ) &&
+ !has_proto(ist, value, OBJ(TUPLE_PROTO)) &&
+ !has_proto(ist, value, OBJ(STRING_PROTO)) ) {
raise_exception(ist, OBJ(TYPE_EXC), "list slices may only be replaced with a sequence");
def_write_unlock(self);
return NULL;
@@ -375,7 +375,7 @@
slice_item3 = list_item(ist, slice,2);
if (slice_item3 == SLICEPARAM_EMPTY || slice_item3 == OBJ(NONE)) index3 = 1;
else {
- if (!has_proto_QUES(ist, slice_item3, OBJ(INT_PROTO))) {
+ if (!has_proto(ist, slice_item3, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "sequence slice index must be an integer");
def_write_unlock(self);
return NULL;
@@ -392,7 +392,7 @@
if (slice_item2 == SLICEPARAM_EMPTY || slice_item2 == OBJ(NONE))
slice2_empty=TRUE;
else {
- if (!has_proto_QUES(ist, slice_item2, OBJ(INT_PROTO))) {
+ if (!has_proto(ist, slice_item2, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "sequence slice index must be an integer");
def_write_unlock(self);
return NULL;
@@ -460,7 +460,7 @@
if (slice_item1 == SLICEPARAM_EMPTY || slice_item1 == OBJ(NONE))
slice1_empty=TRUE;
else {
- if (!has_proto_QUES(ist, slice_item1, OBJ(INT_PROTO))) {
+ if (!has_proto(ist, slice_item1, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "List slice index must be an integer");
def_write_unlock(self);
return NULL;
@@ -487,7 +487,7 @@
slice_item3 = list_item(ist, slice,2);
if (slice_item3 == SLICEPARAM_EMPTY || slice_item3 == OBJ(NONE)) index3 = 1;
else {
- if (!has_proto_QUES(ist, slice_item3, OBJ(INT_PROTO))) {
+ if (!has_proto(ist, slice_item3, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "sequence slice index must be an integer");
def_write_unlock(self);
return NULL;
@@ -504,7 +504,7 @@
if (slice_item2 == SLICEPARAM_EMPTY || slice_item2 == OBJ(NONE))
slice2_empty=TRUE;
else {
- if (!has_proto_QUES(ist, slice_item2, OBJ(INT_PROTO))) {
+ if (!has_proto(ist, slice_item2, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "sequence slice index must be an integer");
def_write_unlock(self);
return NULL;
@@ -560,7 +560,7 @@
int i;
obj_p res = copy_list_obj(ist, self);
BIN_CONTENT_CHK(List);
- if (has_proto_QUES(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO)))
+ if (has_proto(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto(ist, parms[1], OBJ(STRING_PROTO)))
for(i=0; i < (int) list_len(ist, parms[1]); i++)
list_append(ist, res, list_item(ist, parms[1], i));
else
@@ -573,7 +573,7 @@
list_p lstp, selfp = (list_p)(self->data.ptr);
int i, size, times, len = (int) list_len(ist, self);
BIN_CONTENT_CHK(List);
- if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "multiply times parameter must be an integer");
return NULL;
}
@@ -615,7 +615,7 @@
size_t self_len, other_len;
BIN_CONTENT_CHK(List);
def_write_lock(self);
- if (!has_proto_QUES(ist, parms[1], OBJ(TUPLE_PROTO)) && !has_proto_QUES(ist, parms[1], List_OBJ)) {
+ if (!has_proto(ist, parms[1], OBJ(TUPLE_PROTO)) && !has_proto(ist, parms[1], List_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "extend parameter must be a tuple or list");
return NULL;
}
@@ -639,7 +639,7 @@
size_t self_len;
list_p selfp;
BIN_CONTENT_CHK(List);
- if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "index (i) parameter must be an integer");
return NULL;
}
@@ -697,7 +697,7 @@
list_p selfp;
obj_p res;
BIN_CONTENT_CHK(List);
- if (parms[1] != OBJ(NONE) && !has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
+ if (parms[1] != OBJ(NONE) && !has_proto(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "pop index (i) parameter must be an integer");
return NULL;
}
Modified: trunk/src/builtins-string.c
===================================================================
--- trunk/src/builtins-string.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/builtins-string.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -67,7 +67,7 @@
#include "pr_snprintf.h"
-#define is_String(objid) (has_proto_QUES(ist, objid, String_OBJ))
+#define is_String(objid) (has_proto(ist, objid, String_OBJ))
MODULE_DECLARE(String);
MODULE_DECLARE(StringGen);
@@ -213,7 +213,7 @@
s = "";
else {
obj_p obj = list_item(ist, parms[1], 0);
- if (has_proto_QUES(ist, obj, OBJ(SYMBOL_PROTO)))
+ if (has_proto(ist, obj, OBJ(SYMBOL_PROTO)))
s = symch(ist, obj);
else
s = as_str(ist, obj);
@@ -293,7 +293,7 @@
pr_str_p obj_str;
size_t i, times, tlen, len = pr_strlen(self);
BIN_CONTENT_CHK(String);
- if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "multiply times parameter must be an integer");
return NULL;
}
@@ -332,8 +332,8 @@
apr_status_t aprerr;
BIN_CONTENT_CHK(String);
- if ( has_proto_QUES(ist, argv_obj, OBJ(STRING_PROTO)) ||
- !has_proto_QUES(ist, argv_obj, OBJ(SEQ_PROTO)) ) {
+ if ( has_proto(ist, argv_obj, OBJ(STRING_PROTO)) ||
+ !has_proto(ist, argv_obj, OBJ(SEQ_PROTO)) ) {
argv_obj = NEW_LIST(1);
list_append(ist, argv_obj, parms[1]);
}
@@ -341,13 +341,13 @@
argv = pr_malloc((argc+1) * sizeof(pr_arg_t));
for (i=0; i < argc; i++) {
obj_p arg_obj = list_item(ist, argv_obj, (int) i);
- if (has_proto_QUES(ist, arg_obj, OBJ(INT_PROTO))) {
+ if (has_proto(ist, arg_obj, OBJ(INT_PROTO))) {
argv[i].arg.i64 = arg_obj->data.i64;
argv[i].type = ARG_TYPE_INT;
- } else if (has_proto_QUES(ist, arg_obj, OBJ(FLOAT_PROTO))) {
+ } else if (has_proto(ist, arg_obj, OBJ(FLOAT_PROTO))) {
argv[i].arg.f64 = arg_obj->data.f64;
argv[i].type = ARG_TYPE_FLOAT;
- } else if (has_proto_QUES(ist, arg_obj, OBJ(STRING_PROTO))) {
+ } else if (has_proto(ist, arg_obj, OBJ(STRING_PROTO))) {
argv[i].arg.str = pr_strptr(arg_obj);
argv[i].type = ARG_TYPE_STRING;
} else {
@@ -388,7 +388,7 @@
int i, llen;
size_t ofs, self_len, tlen;
BIN_CONTENT_CHK(String);
- if (!has_proto_QUES(ist, parms[1], OBJ(LIST_PROTO))) {
+ if (!has_proto(ist, parms[1], OBJ(LIST_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "join function parameter must be a list");
return NULL;
}
@@ -437,7 +437,7 @@
DEF(String, in__QUES, FORM_RPARAM) {
BIN_CONTENT_CHK(String);
- if (!has_proto_QUES(ist, parms[1], String_OBJ))
+ if (!has_proto(ist, parms[1], String_OBJ))
return call_func1(ist, parms[1], SYM(RIN__QUES), self);
if (strstr(pr_strptr(parms[1]), pr_strptr(self))) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
@@ -445,7 +445,7 @@
DEF(String, notIn__QUES, FORM_RPARAM) {
BIN_CONTENT_CHK(String);
- if (!has_proto_QUES(ist, parms[1], String_OBJ))
+ if (!has_proto(ist, parms[1], String_OBJ))
return call_func1(ist, parms[1], SYM(RNOTIN__QUES), self);
if (strstr(pr_strptr(parms[1]), pr_strptr(self))) return OBJ(PR_FALSE);
else return OBJ(PR_TRUE);
@@ -492,11 +492,11 @@
BIN_CONTENT_CHK(String);
- if (!has_proto_QUES(ist, parms[1], String_OBJ)) {
+ if (!has_proto(ist, parms[1], String_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "find function parameter 1 must be a string");
return NULL;
}
- if (!has_proto_QUES(ist, parms[3], OBJ(INT_PROTO))) {
+ if (!has_proto(ist, parms[3], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "find function parameter 2 must be an integer");
return NULL;
} else {
@@ -535,11 +535,11 @@
BIN_CONTENT_CHK(String);
- if (!has_proto_QUES(ist, parms[1], String_OBJ)) {
+ if (!has_proto(ist, parms[1], String_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "replace function parameter 1 must be a string");
return NULL;
}
- if (!has_proto_QUES(ist, parms[3], String_OBJ)) {
+ if (!has_proto(ist, parms[3], String_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "replace function parameter 2 must be a string");
return NULL;
}
@@ -698,7 +698,7 @@
obj_p next_frag, list_obj = new_list_obj(ist,0);
BIN_CONTENT_CHK(String);
- if (!has_proto_QUES(ist, parms[1], String_OBJ)) {
+ if (!has_proto(ist, parms[1], String_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "split function parameter 1 must be a string");
return NULL;
}
Modified: trunk/src/builtins-tuple.c
===================================================================
--- trunk/src/builtins-tuple.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/builtins-tuple.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -134,7 +134,7 @@
obj_p res;
obj_p self_item, tgt_item, tgt_list;
BIN_CONTENT_CHK(Tuple);
- if (!has_proto_QUES(ist, parms[1], OBJ(SEQ_PROTO))) {
+ if (!has_proto(ist, parms[1], OBJ(SEQ_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "sequence can only be compared to a sequence");
return NULL;
}
@@ -158,7 +158,7 @@
int i, llen, tlen;
obj_p self_item, tgt_item, tgt_list, false_obj = OBJ(PR_FALSE);
BIN_CONTENT_CHK(Tuple);
- if (!has_proto_QUES(ist, parms[1], OBJ(SEQ_PROTO))) return false_obj;
+ if (!has_proto(ist, parms[1], OBJ(SEQ_PROTO))) return false_obj;
llen = (int) list_len(ist, self);
tgt_list = parms[1];
tlen = (int) list_len(ist, tgt_list);
@@ -203,7 +203,7 @@
int i;
obj_p res = copy_list_obj(ist, self);
BIN_CONTENT_CHK(Tuple);
- if (has_proto_QUES(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO)))
+ if (has_proto(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto(ist, parms[1], OBJ(STRING_PROTO)))
for(i=0; i < (int) list_len(ist, parms[1]); i++)
list_append(ist, res, list_item(ist, parms[1], i));
else
@@ -217,7 +217,7 @@
list_p lstp, selfp = (list_p)(self->data.ptr);
int i, size, times, len = (int) list_len(ist, self);
BIN_CONTENT_CHK(Tuple);
- if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "multiply times parameter must be an integer");
return NULL;
}
Modified: trunk/src/bytecodes.h
===================================================================
--- trunk/src/bytecodes.h 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/bytecodes.h 2004-05-24 20:44:53 UTC (rev 542)
@@ -176,12 +176,12 @@
// |opcode|symbol-key|
OP_PUSH_SELF_REF,
-// PUSH_ANTE_REF(ante.symbol)
-// push inherited ante obj reference (self/ref) onto stack
-// stack: -> ante-proto,symbol
+// PUSH_SUPER_REF(super.symbol)
+// push inherited super obj reference (self/ref) onto stack
+// stack: -> super-proto,symbol
// param: <unused>
// |opcode|symbol-key|
-OP_PUSH_ANTE_REF,
+OP_PUSH_SUPER_REF,
// PUSH_OUTER_REF(outer.symbol)
// push inherited super obj reference (super/ref) onto stack
Modified: trunk/src/getline.c
===================================================================
--- trunk/src/getline.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/getline.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -5,7 +5,7 @@
* Copyright (C) 1991, 1992 by Chris Thewalt ([email protected])
*
* Permission to use, copy, modify, and distribute this software
- * for any purpose and without fee is hereby granted, provided
+ * for any purpose and without fee is hereby grsuperd, provided
* that the above copyright notices appear in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. This software is provided "as is" without express or
Modified: trunk/src/getline.h
===================================================================
--- trunk/src/getline.h 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/getline.h 2004-05-24 20:44:53 UTC (rev 542)
@@ -2,7 +2,7 @@
* Copyright (C) 1991, 1992 by Chris Thewalt ([email protected])
*
* Permission to use, copy, modify, and distribute this software
- * for any purpose and without fee is hereby granted, provided
+ * for any purpose and without fee is hereby grsuperd, provided
* that the above copyright notices appear in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. This software is provided "as is" without express or
Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/interp.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -141,17 +141,17 @@
return local_obj;
}
-//********************************* new_ante_obj *****************************
-obj_p new_ante_obj(isp ist, obj_p container, obj_p symbol) {
+//********************************* new_super_obj *****************************
+obj_p new_super_obj(isp ist, obj_p container, obj_p symbol) {
int i;
- obj_p ante_obj = NEW_OBJ(OBJ(ANTE_PROTO));
- ante_obj->data_type = DATA_TYPE_DATAPTR;
- ante_obj->data.ptr = symbol;
+ obj_p super_obj = NEW_OBJ(OBJ(SUPER_PROTO));
+ super_obj->data_type = DATA_TYPE_DATAPTR;
+ super_obj->data.ptr = symbol;
su(i);
- set_attr(ist, ante_obj, SYM(CONT_), container);
+ set_attr(ist, super_obj, SYM(CONT_), container);
un_su(i);
- ante_obj->immutable = TRUE;
- return ante_obj;
+ super_obj->immutable = TRUE;
+ return super_obj;
}
//********************************* new_outer_obj *****************************
@@ -190,7 +190,7 @@
//********************************* get_item ******************************
obj_p get_item(isp ist, obj_p ref_self, obj_p ref_key){
- if (has_proto_QUES(ist, ref_key, OBJ(SYMBOL_PROTO))) {
+ if (has_proto(ist, ref_key, OBJ(SYMBOL_PROTO))) {
obj_p res;
if_exc_return NULL;
res = get_proto_attr(ist, ref_self, ref_key, NULL, NULL);
@@ -199,15 +199,15 @@
symch(ist, ref_key));
}
return res;
- } else if (has_proto_QUES(ist, ref_key, OBJ(LOCAL_PROTO))) {
+ } else if (has_proto(ist, ref_key, OBJ(LOCAL_PROTO))) {
if_exc_return NULL;
return get_scope_attr(ist, ref_self, ref_key->data.ptr, NULL, NULL);
- } else if (has_proto_QUES(ist, ref_key, OBJ(SLICE_PROTO))) {
+ } else if (has_proto(ist, ref_key, OBJ(SLICE_PROTO))) {
obj_p param[2];
if_exc_return NULL;
param[0]=0; param[1]=ref_key;
return call_func(ist, ref_self, SYM(GETITEM_), 2, param, 0);
- } else if (has_proto_QUES(ist, ref_key, OBJ(OUTER_PROTO))) {
+ } else if (has_proto(ist, ref_key, OBJ(OUTER_PROTO))) {
obj_p res;
if_exc_return NULL;
res = get_scope_attr(ist, ref_self, ref_key->data.ptr, NULL, ref_self);
@@ -216,11 +216,11 @@
return NULL;
}
return res;
- } else if (has_proto_QUES(ist, ref_key, OBJ(INT_PROTO))) {
+ } else if (has_proto(ist, ref_key, OBJ(INT_PROTO))) {
obj_p param[2];
param[0]=0; param[1]=slice1(ref_key);
return call_func(ist, ref_self, SYM(GETITEM_), 2, param, 0);
- } else if (has_proto_QUES(ist, ref_key, OBJ(ANTE_PROTO))) {
+ } else if (has_proto(ist, ref_key, OBJ(SUPER_PROTO))) {
obj_p res, cont = get_attr(ist, ref_key, SYM(CONT_));
if (!cont) {
raise_exception(ist, OBJ(NAME_EXC), "Container obj for attribute %s not found",
@@ -230,7 +230,7 @@
if_exc_return NULL;
res = get_proto_attr(ist, ref_self, ref_key->data.ptr, NULL, cont);
if (!res) {
- raise_exception(ist, OBJ(NAME_EXC), "Ante attribute %s not found",
+ raise_exception(ist, OBJ(NAME_EXC), "Super attribute %s not found",
symch(ist, ref_key->data.ptr));
}
return res;
@@ -242,17 +242,23 @@
//********************************* set_item ******************************
void set_item(isp ist, obj_p ref_self, obj_p ref_key, obj_p value){
- if (has_proto_QUES(ist, ref_key, OBJ(SYMBOL_PROTO))) {
+ if (ref_key == SYM(ATTRS_)) {
+ if (!has_proto(ist, value, OBJ(DICT_PROTO))) {
+ raise_exception(ist, OBJ(TYPE_EXC), "attempt to replace attrs_ with non-dictionary");
+ return;
+ }
+ dict2attr(ist, value, ref_self);
+ } else if (has_proto(ist, ref_key, OBJ(SYMBOL_PROTO))) {
if_exc_return;
set_attr(ist, ref_self, ref_key, value);
- } else if (has_proto_QUES(ist, ref_key, OBJ(LOCAL_PROTO))) {
+ } else if (has_proto(ist, ref_key, OBJ(LOCAL_PROTO))) {
set_attr(ist, ref_self, ref_key->data.ptr, value);
- } else if (has_proto_QUES(ist, ref_key, OBJ(SLICE_PROTO))) {
+ } else if (has_proto(ist, ref_key, OBJ(SLICE_PROTO))) {
obj_p param[4];
param[0]=0; param[1]=ref_key;
param[2]=0; param[3]=value;
call_func(ist, ref_self, SYM(SETITEM_), 4, param, 0);
- } else if (has_proto_QUES(ist, ref_key, OBJ(OUTER_PROTO))) {
+ } else if (has_proto(ist, ref_key, OBJ(OUTER_PROTO))) {
obj_p scope_obj;
if_exc_return;
get_scope_attr(ist, ref_self, ref_key->data.ptr, &scope_obj, ref_self);
@@ -262,12 +268,12 @@
}
if_exc_return;
set_attr(ist, scope_obj, ref_key->data.ptr, value);
- } else if (has_proto_QUES(ist, ref_key, OBJ(INT_PROTO))) {
+ } else if (has_proto(ist, ref_key, OBJ(INT_PROTO))) {
obj_p param[4];
param[0]=0; param[1]=slice1(ref_key);
param[2]=0; param[3]=value;
call_func(ist, ref_self, SYM(SETITEM_), 4, param, 0);
- } else if (has_proto_QUES(ist, ref_key, OBJ(ANTE_PROTO))) {
+ } else if (has_proto(ist, ref_key, OBJ(SUPER_PROTO))) {
obj_p res, proto, cont = get_attr(ist, ref_key, SYM(CONT_));
if (!cont) {
raise_exception(ist, OBJ(NAME_EXC), "Container obj for attribute %s not found",
@@ -277,7 +283,7 @@
if_exc_return;
res = get_proto_attr(ist, ref_self, ref_key->data.ptr, &proto, cont);
if (!res) {
- raise_exception(ist, OBJ(NAME_EXC), "Ante attribute %s not found",
+ raise_exception(ist, OBJ(NAME_EXC), "Super attribute %s not found",
symch(ist, ref_key->data.ptr));
return;
}
@@ -288,16 +294,19 @@
//********************************* del_item ***********************************
void del_item(isp ist, obj_p ref_self, obj_p ref_key){
- if (has_proto_QUES(ist, ref_key, OBJ(SYMBOL_PROTO))) {
+ if (ref_key == SYM(ATTRS_)) {
+ raise_exception(ist, OBJ(TYPE_EXC), "attempt to del attrs_");
+ return;
+ } else if (has_proto(ist, ref_key, OBJ(SYMBOL_PROTO))) {
if_exc_return;
del_attr(ist, ref_self, ref_key);
- } else if (has_proto_QUES(ist, ref_key, OBJ(LOCAL_PROTO))) {
+ } else if (has_proto(ist, ref_key, OBJ(LOCAL_PROTO))) {
del_attr(ist, ref_self, ref_key->data.ptr);
- } else if (has_proto_QUES(ist, ref_key, OBJ(SLICE_PROTO))) {
+ } else if (has_proto(ist, ref_key, OBJ(SLICE_PROTO))) {
obj_p param[2];
param[0]=0; param[1]=ref_key;
call_func(ist, ref_self, SYM(DELITEM_), 2, param, 0);
- } else if (has_proto_QUES(ist, ref_key, OBJ(OUTER_PROTO))) {
+ } else if (has_proto(ist, ref_key, OBJ(OUTER_PROTO))) {
obj_p scope_obj;
if_exc_return;
get_scope_attr(ist, ref_self, ref_key->data.ptr, &scope_obj, ref_self);
@@ -307,11 +316,11 @@
}
if_exc_return;
del_attr(ist, scope_obj, ref_key->data.ptr);
- } else if (has_proto_QUES(ist, ref_key, OBJ(INT_PROTO))) {
+ } else if (has_proto(ist, ref_key, OBJ(INT_PROTO))) {
obj_p param[2];
param[0]=0; param[1]=slice1(ref_key);
call_func(ist, ref_self, SYM(DELITEM_), 2, param, 0);
- } else if (has_proto_QUES(ist, ref_key, OBJ(ANTE_PROTO))) {
+ } else if (has_proto(ist, ref_key, OBJ(SUPER_PROTO))) {
obj_p res, proto, cont = get_attr(ist, ref_key, SYM(CONT_));
if (!cont) {
raise_exception(ist, OBJ(NAME_EXC), "Container obj for attribute %s not found",
@@ -321,7 +330,7 @@
if_exc_return;
res = get_proto_attr(ist, ref_self, ref_key->data.ptr, &proto, cont);
if (!res) {
- raise_exception(ist, OBJ(NAME_EXC), "Ante attribute %s not found",
+ raise_exception(ist, OBJ(NAME_EXC), "Super attribute %s not found",
symch(ist, ref_key->data.ptr));
return;
}
@@ -903,15 +912,15 @@
fr_push(frame->self);
fr_push(fr_data(1));
break;
- case OP_PUSH_ANTE_REF: {
+ case OP_PUSH_SUPER_REF: {
obj_p cont;
if ( !frame->self || !frame->func ||
!(cont = get_attr(ist, frame->func, SYM(CONT_))) ) {
- raise_exception(ist, OBJ(INTERPRETER_EXC), "ante.var only valid in function");
+ raise_exception(ist, OBJ(INTERPRETER_EXC), "super.var only valid in function");
break;
}
fr_push(frame->self);
- fr_push(new_ante_obj(ist, cont, fr_data(1)));
+ fr_push(new_super_obj(ist, cont, fr_data(1)));
break;
}
case OP_PUSH_LOCAL_REF:
@@ -931,15 +940,21 @@
fr_push(fr_data(1));
break;
case OP_DEREF: {
- obj_p att;
+ obj_p att, obj, key;
fr_sp -= 2;
- att = get_item(ist, fr_stack[fr_sp], fr_stack[fr_sp+1]); IF_EXC_BREAK;
- if (!att) {
- raise_exception( ist, OBJ(INTERPRETER_EXC), "attribute %s not found",
- as_str(ist, fr_stack[fr_sp+1]) );
- break;
+ obj = fr_stack[fr_sp];
+ key = fr_stack[fr_sp+1];
+ if (key == SYM(ATTRS_))
+ fr_push(new_attrdict_obj(ist, obj));
+ else {
+ att = get_item(ist, obj, key); IF_EXC_BREAK;
+ if (!att) {
+ raise_exception( ist, OBJ(INTERPRETER_EXC), "attribute %s not found",
+ as_str(ist, key) );
+ break;
+ }
+ fr_push(att);
}
- fr_push(att);
} break;
case OP_ASSIGN: {
int sp1, sp2 = fr_sp - param*2;
@@ -951,7 +966,7 @@
case OP_SEQ_ASSIGN: {
obj_p list;
fr_sp -= param+1;
- if (has_proto_QUES(ist, list=fr_stack[fr_sp], OBJ(LIST_PROTO))){
+ if (has_proto(ist, list=fr_stack[fr_sp], OBJ(LIST_PROTO))){
if (list_len(ist, list) != param){
raise_exception(ist, OBJ(INTERPRETER_EXC), "For param list length doesn't match sequence length");
break;
@@ -1083,7 +1098,7 @@
fr_sp--;
exc_proto = fr_tos;
fr_sp--;
- if (!has_proto_QUES(ist, exc_waiting, exc_proto)) { // need to support list XXX
+ if (!has_proto(ist, exc_waiting, exc_proto)) { // need to support list XXX
IF_EXC_BREAK;
#ifdef TRACE_INTERPRETER
if (trace_interpreter) trace_step(frame);
@@ -1108,7 +1123,7 @@
obj_p str_obj;
frame_p new_frame;
str_obj = fr_pop;
- if (!has_proto_QUES(ist, str_obj, OBJ(STRING_PROTO))){
+ if (!has_proto(ist, str_obj, OBJ(STRING_PROTO))){
raise_exception(ist, OBJ(TYPE_EXC), "Exec parameter must be a string");
break;
}
@@ -1164,7 +1179,7 @@
free_clist(plist);
IF_EXC_BREAK;
fr_push(res);
- } else if (has_proto_QUES(ist, func_obj, OBJ(FUNC_PROTO))) {
+ } else if (has_proto(ist, func_obj, OBJ(FUNC_PROTO))) {
obj_p new_locals, self;
frame_p new_frame;
IF_EXC_BREAK;
@@ -1185,7 +1200,7 @@
load_frame_params(ist, new_locals, func_obj, param*2, fr_stack+fr_sp+2);
IF_EXC_BREAK;
switch_frame = new_frame;
- } else if (has_proto_QUES(ist, func_obj, OBJ(GEN_PROTO))) {
+ } else if (has_proto(ist, func_obj, OBJ(GEN_PROTO))) {
frame_p tmp_frame;
IF_EXC_BREAK;
tmp_frame = func_obj->data.ptr;
@@ -1230,7 +1245,7 @@
if (ist->exception_obj) goto end_op_obj;
}
key = fr_stack[fr_sp+1];
- if (has_proto_QUES(ist, key, OBJ(LOCAL_PROTO))) {
+ if (has_proto(ist, key, OBJ(LOCAL_PROTO))) {
key = key->data.ptr;
//del_unlock(fr_stack[fr_sp+1]);
}
@@ -1268,7 +1283,7 @@
obj_p name_obj;
fr_sp -= 3+(2*param);
name_obj = fr_stack[fr_sp+1];
- if (has_proto_QUES(ist, name_obj, OBJ(ANTE_PROTO))) {
+ if (has_proto(ist, name_obj, OBJ(SUPER_PROTO))) {
obj_p cont = get_attr(ist, name_obj, SYM(CONT_));
name_obj = name_obj->data.ptr;
if (!cont) {
@@ -1279,21 +1294,21 @@
func_obj = get_proto_attr(ist, fr_stack[fr_sp], name_obj, NULL, cont);
goto got_func;
}
- if (has_proto_QUES(ist, name_obj, OBJ(LOCAL_PROTO))) {
+ if (has_proto(ist, name_obj, OBJ(LOCAL_PROTO))) {
name_obj = name_obj->data.ptr;
func_obj = get_scope_attr(ist, fr_stack[fr_sp], name_obj, NULL, NULL);
goto got_func;
}
- if (has_proto_QUES(ist, name_obj, OBJ(OUTER_PROTO))) {
+ if (has_proto(ist, name_obj, OBJ(OUTER_PROTO))) {
name_obj = name_obj->data.ptr;
func_obj = get_scope_attr(ist, fr_stack[fr_sp], name_obj, NULL, fr_stack[fr_sp]);
goto got_func;
}
- if (!has_proto_QUES(ist, name_obj, OBJ(SYMBOL_PROTO))) {
+ if (!has_proto(ist, name_obj, OBJ(SYMBOL_PROTO))) {
raise_exception(ist, OBJ(INTERNAL_EXC), "Indexed function call not supported yet");
break;
}
- if (fr_stack[fr_sp+1] == SYM(NEXT) && has_proto_QUES(ist, fr_stack[fr_sp], OBJ(GEN_PROTO))) {
+ if (fr_stack[fr_sp+1] == SYM(NEXT) && has_proto(ist, fr_stack[fr_sp], OBJ(GEN_PROTO))) {
frame_p new_frame=(frame_p)(fr_stack[fr_sp]->data.ptr);
if (!new_frame) {
raise_exception(ist, OBJ(STOP_ITERATION_EXC), NULL);
@@ -1345,7 +1360,7 @@
free_clist(plist);
IF_EXC_BREAK;
fr_push(res);
- } else if (has_proto_QUES(ist, func_obj, OBJ(FUNC_PROTO))) {
+ } else if (has_proto(ist, func_obj, OBJ(FUNC_PROTO))) {
obj_p new_locals, self;
frame_p new_frame;
IF_EXC_BREAK;
@@ -1367,7 +1382,7 @@
load_frame_params(ist, new_locals, func_obj, param*2, fr_stack+fr_sp+3);
IF_EXC_BREAK;
switch_frame = new_frame;
- } else if (has_proto_QUES(ist, func_obj, OBJ(GEN_PROTO))) {
+ } else if (has_proto(ist, func_obj, OBJ(GEN_PROTO))) {
frame_p tmp_frame;
IF_EXC_BREAK;
tmp_frame = func_obj->data.ptr;
@@ -1596,11 +1611,12 @@
func_obj = get_proto_attr(ist, self, func_sym, NULL, super_obj); if_exc_return NULL;
if (!func_obj) {
if (!ist) {
- printf("Internal error with exceptions disabled: Function not found: \"%s\"", as_str(ist, func_sym));
+ printf("Internal error with exceptions disabled: Function not found: \"%s\"",
+ as_str(ist, func_sym));
pr_exit(1);
}
raise_exception(ist, OBJ(FUNCNOTFOUND_EXC), "Function not found: \"%s\"",
- as_str(ist, func_sym));
+ as_str(ist, func_sym));
return NULL;
}
}
@@ -1618,7 +1634,7 @@
if (intrp_exobj) return NULL;
if (!func_sym) del_unlock(self);
return res;
- } else if (has_proto_QUES(ist, func_obj, OBJ(FUNC_PROTO))) {
+ } else if (has_proto(ist, func_obj, OBJ(FUNC_PROTO))) {
frame_p frame, new_frame;
obj_p new_locals, aself;
if (!ist) {
@@ -1686,7 +1702,7 @@
for (i = (int) list_len(ist, bl) - 1; i >= 0; i--){
obj_p exc = list_item(ist, bl, i);
- if (exc && exc != OBJ(EXCEPTION) && has_proto_QUES(ist, exc, OBJ(EXCEPTION))) {
+ if (exc && exc != OBJ(EXCEPTION) && has_proto(ist, exc, OBJ(EXCEPTION))) {
obj_p doc = get_attr(ist, exc, SYM(DOC_));
if (doc && exc != orig_excobj)
Modified: trunk/src/memory_mgr.c
===================================================================
--- trunk/src/memory_mgr.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/memory_mgr.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -273,6 +273,7 @@
call_func(ist, obj, SYM(DEL_), 0, NULL, NULL);
ist->exception_obj = 0;
mm_write_lock(ist, obj);
+ ist->exception_obj = 0;
obj->state = OBJ_STATE_DELETED;
pr_lock(&object_list_lock);
if (last_obj)
Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/object.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -129,7 +129,7 @@
dll_services.del_attr = del_attr;
dll_services.ins_proto = ins_proto;
dll_services.del_proto = del_proto;
- dll_services.has_proto_QUES = has_proto_QUES;
+ dll_services.has_proto = has_proto;
dll_services.switch_proto = switch_proto;
dll_services.list_append = list_append;
dll_services.list_item = list_item;
@@ -216,7 +216,7 @@
OBJ(SLICE_PROTO) = NEW_OBJ(NULL);
OBJ(LOCAL_PROTO) = NEW_OBJ(NULL);
OBJ(OUTER_PROTO) = NEW_OBJ(NULL);
- OBJ(ANTE_PROTO) = NEW_OBJ(NULL);
+ OBJ(SUPER_PROTO) = NEW_OBJ(NULL);
OBJ(THREAD_PROTO) = NEW_OBJ(NULL);
OBJ(MUTEX_PROTO) = NEW_OBJ(NULL);
OBJ(ROOT_GLOBALS) = NEW_OBJ(NULL);
@@ -333,7 +333,7 @@
for (i=0; i < numprotos; i++) {
obj_p proto = attr_proto_item(attrp, i);
owner_set |= ( attr_pp(attrp, i)->proto.owns_binary =
- ((proto == owner) || has_proto_QUES(ist, proto, owner)) );
+ ((proto == owner) || has_proto(ist, proto, owner)) );
}
if (!owner_set)
raise_exception(ist, OBJ(INTERNAL_EXC), "obj_set_data_owner error");
@@ -359,8 +359,8 @@
}
}
res = owner &&
- ( (proto == owner) || has_proto_QUES(ist, proto, owner) ||
- has_proto_QUES(ist, owner, proto) );
+ ( (proto == owner) || has_proto(ist, proto, owner) ||
+ has_proto(ist, owner, proto) );
if (!res)
owner = NULL;
return res;
@@ -509,11 +509,11 @@
if (exc_obj) {
if (!proto && !proto_list)
return exc_obj;
- if (proto && has_proto_QUES(ist, exc_obj, proto))
+ if (proto && has_proto(ist, exc_obj, proto))
return exc_obj;
if (proto_list)
for (i=0; i < (int) list_len(ist, proto_list); i++){
- if (has_proto_QUES(ist, exc_obj, list_item(ist, proto_list, i)))
+ if (has_proto(ist, exc_obj, list_item(ist, proto_list, i)))
return exc_obj;
}
}
@@ -558,7 +558,7 @@
}
//********************************* add_attrs *********************************
-attr_p add_attrs(obj_p obj){
+attr_p add_attrs(obj_p obj) {
obj_p proto = obj->attr_proto.proto;
attr_p attrs = pr_malloc(ATTRS_TINIT * sizeof(attr_t));
memset(attrs, 0, ATTRS_TINIT * sizeof(attr_t));
@@ -831,8 +831,8 @@
return list_obj;
}
-//********************************* has_proto_QUES **********************************
-int has_proto_QUES(isp ist, obj_p obj, obj_p obj_proto){
+//********************************* has_proto **********************************
+int has_proto(isp ist, obj_p obj, obj_p obj_proto){
i32_t i, j, len;
obj_p proto;
clist_t *pao_list;
Modified: trunk/src/object.h
===================================================================
--- trunk/src/object.h 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/object.h 2004-05-24 20:44:53 UTC (rev 542)
@@ -141,7 +141,8 @@
obj_p new_attrdict_obj(isp ist, obj_p obj);
obj_p new_float_obj(isp ist, double num);
obj_p new_hash_obj(isp ist, i32_t num);
-
+void dict2attr(isp ist, obj_p dict, obj_p obj);
+attr_p add_attrs(obj_p obj);
char* numonly(char* s, char* buf);
void dump_obj(isp ist, obj_p obj, int dep);
Modified: trunk/src/parser.h
===================================================================
--- trunk/src/parser.h 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/parser.h 2004-05-24 20:44:53 UTC (rev 542)
@@ -155,7 +155,7 @@
code_p continue_stmt(void* param, obj_p label);
code_p del_ref(void* param, code_p expr);
code_p self_label_to_attrref(void* param, obj_p label);
-code_p ante_label_to_attrref(void* param, obj_p label);
+code_p super_label_to_attrref(void* param, obj_p label);
code_p outer_label_to_attrref(void* param, obj_p label);
code_p caller_label_to_attrref(void* param, obj_p label);
code_p self_to_obj(void* param);
Modified: trunk/src/parser_routines.c
===================================================================
--- trunk/src/parser_routines.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/parser_routines.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -408,9 +408,9 @@
p->code_data[1].data = sym(IST, pr_strptr(label));
return debug_retrn(__LINE__, p);
}
-code_p ante_label_to_attrref(void* param, obj_p label) {
+code_p super_label_to_attrref(void* param, obj_p label) {
code_p p;
- p = new_code(param, 2, 2, 2, OP_PUSH_ANTE_REF);
+ p = new_code(param, 2, 2, 2, OP_PUSH_SUPER_REF);
p->code_data[1].data = sym(IST, pr_strptr(label));
return debug_retrn(__LINE__, p);
}
Modified: trunk/src/prothon.y
===================================================================
--- trunk/src/prothon.y 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/prothon.y 2004-05-24 20:44:53 UTC (rev 542)
@@ -100,7 +100,6 @@
int yylex (YYSTYPE *lvalp, void* yylex_param);
%}
-%nonassoc ANTE
%nonassoc AS
%nonassoc ASSERT
%nonassoc BREAK
@@ -125,6 +124,7 @@
%nonassoc RAISE
%nonassoc RETURN
%nonassoc SELF
+%nonassoc SUPER
%nonassoc TRY
%nonassoc WHILE
%nonassoc WITH
@@ -594,7 +594,7 @@
;
bound_ref:
SELF '.' LABEL { $$ = self_label_to_attrref(yylex_param, $3); }
- | ANTE '.' LABEL { $$ = ante_label_to_attrref(yylex_param, $3); }
+ | SUPER '.' LABEL { $$ = super_label_to_attrref(yylex_param, $3); }
| OUTER '.' LABEL { $$ = outer_label_to_attrref(yylex_param, $3); }
| CALLER '.' LABEL { $$ = caller_label_to_attrref(yylex_param, $3); }
| obj '.' LABEL { $$ = obj_label_to_attrref(yylex_param, $1, $3); }
@@ -1122,7 +1122,6 @@
if (!strcmp(str_ptr,"not")) return NOT;
if (!strcmp(str_ptr,"in")) return IN_;
if (!strcmp(str_ptr,"is")) return IS;
- if (!strcmp(str_ptr,"ante")) return ANTE;
if (!strcmp(str_ptr,"as")) return AS;
if (!strcmp(str_ptr,"assert")) return ASSERT;
if (!strcmp(str_ptr,"break")) return BREAK;
@@ -1146,6 +1145,7 @@
if (!strcmp(str_ptr,"print")) return PRINT;
if (!strcmp(str_ptr,"raise")) return RAISE;
if (!strcmp(str_ptr,"self")) return SELF;
+ if (!strcmp(str_ptr,"super")) return SUPER;
if (!strcmp(str_ptr,"return")) return RETURN;
if (!strcmp(str_ptr,"try")) return TRY;
if (!strcmp(str_ptr,"while")) return WHILE;
Modified: trunk/src/symbol.c
===================================================================
--- trunk/src/symbol.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/symbol.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -154,7 +154,9 @@
{ "prevScope_", 0},
{ "accLevel_", 0},
{ "cont_", 0},
- { "name_", 0}
+ { "name_", 0},
+ { "attrs_", 0},
+ { "protos_", 0}
};
typedef struct trie_node_s* trie_p;
Modified: trunk/src/sys.c
===================================================================
--- trunk/src/sys.c 2004-05-24 05:26:48 UTC (rev 541)
+++ trunk/src/sys.c 2004-05-24 20:44:53 UTC (rev 542)
@@ -87,7 +87,7 @@
static obj_p sys_exit(isp ist, obj_p self, int pcnt, obj_p* parms, obj_p dlocals) {
apr_thread_t* apr_thread;
- if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "Sys.exit parameter must be an integer");
return NULL;
}