rev 566 - in trunk: pr/test src
SVN User <[email protected]> Thu, 03 Jun 2004 04:51:45 -0400
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-06-03 04:51:39 -0400 (Thu, 03 Jun 2004)
New Revision: 566
Added:
trunk/pr/test/imp.pr
trunk/pr/test/imp2.pr
Modified:
trunk/pr/test/test.pr
trunk/src/builtins-core.c
trunk/src/builtins-int.c
trunk/src/interp.c
Log:
fixed import bug, local scope object in module is now actual module object, added imp.pr and imp2.pr,
changed mainModule?() to isMain?()
Added: trunk/pr/test/imp.pr
===================================================================
--- trunk/pr/test/imp.pr 2004-06-03 05:50:21 UTC (rev 565)
+++ trunk/pr/test/imp.pr 2004-06-03 08:51:39 UTC (rev 566)
@@ -0,0 +1,14 @@
+#!/usr/bin/env prothon
+
+# imp.pr
+
+Sys.path.append!('../../pr/test')
+Sys.path.append!('../pr/test')
+print Sys.path
+
+import imp2
+
+print imp2.attrs_
+
+imp2.func(99)
+
Property changes on: trunk/pr/test/imp.pr
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/pr/test/imp2.pr
===================================================================
--- trunk/pr/test/imp2.pr 2004-06-03 05:50:21 UTC (rev 565)
+++ trunk/pr/test/imp2.pr 2004-06-03 08:51:39 UTC (rev 566)
@@ -0,0 +1,13 @@
+#!/usr/bin/env prothon
+
+# imp2.pr
+
+def func(a):
+ print a
+
+
+if isMain?():
+ print """
+This is not meant to run as a test. This is a loadable module.
+"""
+
Property changes on: trunk/pr/test/imp2.pr
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/pr/test/test.pr
===================================================================
--- trunk/pr/test/test.pr 2004-06-03 05:50:21 UTC (rev 565)
+++ trunk/pr/test/test.pr 2004-06-03 08:51:39 UTC (rev 566)
@@ -1,12 +1,14 @@
#!/usr/bin/env prothon
-# imp2.pr
+# imp.pr
-def func(a):
- print a
+Sys.path.append!('../../pr/test')
+Sys.path.append!('../pr/test')
+print Sys.path
-if mainModule?():
- print """
-This is not meant to run as a test. This is a loadable module.
-"""
-
+import imp2
+
+print imp2.attrs_
+
+imp2.func(99)
+
Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c 2004-06-03 05:50:21 UTC (rev 565)
+++ trunk/src/builtins-core.c 2004-06-03 08:51:39 UTC (rev 566)
@@ -121,7 +121,7 @@
return NEW_INT((intptr_t) self);
}
-DEF(Object, mainModule_QUES, NULL) {
+DEF(Object, isMain_QUES, NULL) {
dump(ist, "self.txt", self);
if (self == get_attr(ist, OBJ(MODULES), sym(ist, "Main")))
return OBJ(PR_TRUE);
@@ -554,6 +554,10 @@
return call_func0(ist, self->data.ptr, SYM(STR_));
}
+DEF(Local, objList_, FORM_RPARAM) {
+ return parms[1];
+}
+
// ***************************** SUPER ******************************************
MODULE_START(Super)
{
@@ -568,6 +572,10 @@
return call_func0(ist, self->data.ptr, SYM(STR_));
}
+DEF(Super, objList_, FORM_RPARAM) {
+ return parms[1];
+}
+
// ***************************** SEQUENCE *************************************
MODULE_START(Seq)
@@ -819,7 +827,7 @@
MODULE_ADD_SYM(Object, init_);
MODULE_ADD_SYM(Object, del_);
MODULE_ADD_SYM(Object, objId_);
- MODULE_ADD_SYM(Object, mainModule_QUES);
+ MODULE_ADD_SYM(Object, isMain_QUES);
MODULE_ADD_SYM(Object, debug_);
MODULE_ADD_SYM(Object, Proto);
MODULE_ADD_SYM(Object, copy);
@@ -890,9 +898,11 @@
MODULE_SUB_INIT(Local);
MODULE_ADD_SYM(Local, str_);
+ MODULE_ADD_SYM(Local, objList_);
MODULE_SUB_INIT(Super);
MODULE_ADD_SYM(Super, str_);
+ MODULE_ADD_SYM(Super, objList_);
MODULE_SUB_INIT(Func);
MODULE_ADD_SYM(Func, init_);
Modified: trunk/src/builtins-int.c
===================================================================
--- trunk/src/builtins-int.c 2004-06-03 05:50:21 UTC (rev 565)
+++ trunk/src/builtins-int.c 2004-06-03 08:51:39 UTC (rev 566)
@@ -2604,6 +2604,9 @@
BIN_CONTENT_CHK(Int);
return NEW_INT(sizeof(long_t) + long_size(self) * sizeof(digit));
}
+DEF(Int, objList_, FORM_RPARAM) {
+ return parms[1];
+}
MAIN_MODULE_INIT(Int)
{
@@ -2635,6 +2638,7 @@
MODULE_ADD_SYM(Int, lShift_);
MODULE_ADD_SYM(Int, iter_);
MODULE_ADD_SYM(Int, cDataLen_);
+ MODULE_ADD_SYM(Int, objList_);
MODULE_SUB_INIT(IntGen);
MODULE_ADD_SYM(IntGen, next);
Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c 2004-06-03 05:50:21 UTC (rev 565)
+++ trunk/src/interp.c 2004-06-03 08:51:39 UTC (rev 566)
@@ -1782,7 +1782,7 @@
int load_module( isp ist, obj_p module_name, obj_p dyn_locals,
obj_p dest_module, obj_p module_alias, char* filename, char* comment,
obj_p module, char* exec_string ) {
- obj_p new_locals, thread;
+ obj_p thread;
frame_p frame, new_frame;
parse_state* state;
char full_doc[1024], *name;
@@ -1818,8 +1818,8 @@
apr_snprintf(full_doc, sizeof(full_doc), "%s%s", name, comment);
set_obj_doc(module, full_doc);
frame = ist->frame;
- new_locals = NEW_OBJ(NULL);
- new_frame = create_frame( ist, NULL, module, NULL, new_locals, NULL, code );
+ //new_locals = NEW_OBJ(NULL);
+ new_frame = create_frame( ist, NULL, NULL, NULL, module, NULL, code );
new_frame->called_from_c = TRUE;
if (frame) ist->frame->next_frame = new_frame;
new_frame->prev_frame = ist->frame;