rev 466 - in trunk: . include/prothon modules/DBM modules/File modules/OS modules/Prosist modules/Re modules/SQLite pr src
SVN User <[email protected]> Wed, 12 May 2004 12:52:06 -0400
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-05-12 12:52:02 -0400 (Wed, 12 May 2004)
New Revision: 466
Modified:
trunk/STATUS.txt
trunk/include/prothon/prothon.h
trunk/modules/DBM/DBM.vcproj
trunk/modules/File/file.vcproj
trunk/modules/OS/OS.vcproj
trunk/modules/Prosist/Prosist.c
trunk/modules/Prosist/Prosist.vcproj
trunk/modules/Re/re.vcproj
trunk/modules/SQLite/SQLite.vcproj
trunk/pr/test.pr
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/console.c
trunk/src/interp.c
trunk/src/interp.h
trunk/src/object.c
trunk/src/parser.h
trunk/src/parser_routines.c
trunk/src/prothon.y
trunk/src/src.vcproj
trunk/src/symbol.c
Log:
removed super, local, and global, removed capitalization
scheme, added local scope chain lookup for local vars
Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/STATUS.txt 2004-05-12 16:52:02 UTC (rev 466)
@@ -1,6 +1,8 @@
----------------------- TO-DO (highest priority first) ------------------------
+--- nesting /* .. */ comments
+
--- Add properties methods support (__get__, __set__, __delete__) rename protoList
--- Add __attrs__ & __protos__ functionality.
Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/include/prothon/prothon.h 2004-05-12 16:52:02 UTC (rev 466)
@@ -281,33 +281,34 @@
METHOD_PROTO, // 15 Method
HASH_PROTO, // 16 Hash
SLICE_PROTO, // 17 Slice
- SUPER_PROTO, // 18 Super
- GEN_PROTO, // 19 gen (generator)
- THREAD_PROTO, // 20 Thread
- MUTEX_PROTO, // 21 Mutex
+ LOCAL_PROTO, // 18
+ OUTER_PROTO, // 19
+ GEN_PROTO, // 20
+ THREAD_PROTO, // 21 Thread
+ MUTEX_PROTO, // 22 Mutex
// Exceptions
- EXCEPTION, // 22 Exception
- INTERNAL_EXC, // 23 InternalError
- PARSEERROR_EXC, // 24
- INTERPRETER_EXC, // 25
- ASSERTION_EXC, // 26 AssertionError
- NAME_EXC, // 27 NameError
- INDEX_EXC, // 28 IndexError
- TYPE_EXC, // 29 TypeError
- MUTABLE_EXC, // 30 Mutable Error
- DIVIDEZERO_EXC, // 31
- OUTOFMEMORY_EXC, // 32
- IOEXCEPTION, // 33
- FUNCNOTFOUND_EXC, // 34
- FILENOTFOUND_EXC, // 35
- STOP_ITERATION_EXC, // 36
- LOCK_EXC, // 37
- PERMISSION_EXC, // 38
+ EXCEPTION, // 23 Exception
+ INTERNAL_EXC, // 24 InternalError
+ PARSEERROR_EXC, // 25
+ INTERPRETER_EXC, // 26
+ ASSERTION_EXC, // 27 AssertionError
+ NAME_EXC, // 28 NameError
+ INDEX_EXC, // IndexError
+ TYPE_EXC, // TypeError
+ MUTABLE_EXC, // Mutable Error
+ DIVIDEZERO_EXC, //
+ OUTOFMEMORY_EXC, //
+ IOEXCEPTION, //
+ FUNCNOTFOUND_EXC, //
+ FILENOTFOUND_EXC, //
+ STOP_ITERATION_EXC, //
+ LOCK_EXC, //
+ PERMISSION_EXC, //
// constants
- ZERO_INT, // 39
- MAX_INT, // 40 MaxInt
+ ZERO_INT, //
+ MAX_INT, // MaxInt
// Containers
ROOT_GLOBALS, // 41 Root_Globals
@@ -326,22 +327,22 @@
// actual symbols are lower-case versions of these constants
typedef enum {
STRING_,
- NOT_QUES_,
+ NOT__QUES,
POS_,
NEG_,
INV_,
- IN_QUES_,
- NOTIN_QUES_,
- IS_QUES_,
- ISNOT_QUES_,
+ IN__QUES,
+ NOTIN__QUES,
+ IS__QUES,
+ ISNOT__QUES,
- LT_QUES_, // LT_QUES_ thru EQ_QUES_
- LE_QUES_, // must stay in this sequence
- GT_QUES_, // see binary() in parser_routines.c
- GE_QUES_,
- NE_QUES_,
- EQ_QUES_,
+ LT__QUES, // LT__QUES thru EQ__QUES
+ LE__QUES, // must stay in this sequence
+ GT__QUES, // see binary() in parser_routines.c
+ GE__QUES,
+ NE__QUES,
+ EQ__QUES,
CMP,
OR_,
@@ -370,12 +371,12 @@
IMOD_,
IPOW_,
- RIN_QUES_,
- RNOTIN_QUES_,
- RLT_QUES_,
- RLE_QUES_,
- RGT_QUES_,
- RGE_QUES_,
+ RIN__QUES,
+ RNOTIN__QUES,
+ RLT__QUES,
+ RLE__QUES,
+ RGT__QUES,
+ RGE__QUES,
RRSHIFT_,
RLSHIFT_,
RSUB_,
@@ -386,7 +387,7 @@
RCMP_,
INIT_,
- BOOL_QUES_,
+ BOOL__QUES,
GETCMP_,
CMPVALOBJ_,
ITER_,
@@ -397,8 +398,6 @@
GLOBALS_,
SYN_FUNC_,
SYN_LOCALS_,
- LOCALS_,
- SYN_SELF_,
RPARAM,
PARAM1,
PARAM2,
@@ -423,6 +422,7 @@
FROMSTORPROXY_,
CALL_,
BINDOBJ_,
+ PREV_SCOPE_,
SYM_ENUM_COUNT
} sym_enum_t;
@@ -455,15 +455,17 @@
// Access determines the access priveleges the thread has in accessing objects.
// Each object has a threshold access for reading and for writing. See the definition
// of struct obj_s.
+// "module" is the main module of the code for this interpreter.
// NOTE: The pointer type "isp" and the variable name "ist" were chosen to be short
// because they are used in almost every function call in Prothon C code. You must
// use these names as given because many macros expect these names. Don't worry,
// you will have them memorized in no time.
typedef struct interp_state_s {
- access_t access;
- void* lock_stack;
- frame_p frame;
- obj_p exception_obj;
+ obj_p module;
+ access_t access;
+ void* lock_stack;
+ frame_p frame;
+ obj_p exception_obj;
} interp_state_t;
// NEW_OBJECT: Create a new empty object with only proto pointer
@@ -523,13 +525,19 @@
// prototype chain.
// The ist param may return an exception object if proto pointers are missing
// or have a circular reference. See section "INTERPRETER STATE".
-obj_p get_attr_in_chain(isp ist, obj_p object, obj_p key, obj_p *proto_pp, obj_p super_obj);
+obj_p get_proto_attr(isp ist, obj_p object, obj_p key, obj_p *proto_pp, obj_p super_obj);
// DEL_ATTR: Find attr in object that matches a key and delete it.
// Much like get-attr, except that when an attr is found it is deleted.
// If no attr is found to delete it returns FALSE, else TRUE.
int del_attr(isp ist, obj_p obj, obj_p key);
+// GET_SCOPE_ATTR: Same as get_attr except that it will also try local scope chain.
+// same as get_attr but will look in all surrounding syntactical scopes as well
+// if scope_pp not null, then will return scope obj that attr was found in
+// if super_obj specified, then only objects after super_obj after searched
+obj_p get_scope_attr(isp ist, obj_p scope, obj_p key, obj_p *scope_pp, obj_p super_obj);
+
// ATTR_xxx: functions to scan attribute table
// key is the unique integer assigned to each symbol by the symbol table
// you can use key_to_symstr(key) to find the symbol string for an attribute
@@ -670,7 +678,7 @@
// NEW_DICT_OBJ: Create a new dictionary object
// A dictionary stores objects much like the attributes are stored except that
// any immutable object can be the key, not just a symbol. Lookups are more
-// expensive since hashes are used and an eq_QUES_ call must be made during the
+// expensive since hashes are used and an eq__QUES call must be made during the
// lookup unlike attributes that just use the key identity for comparisom.
// Make sure the initial size is at least twice as large as the intended number
// of objects you will be adding initially. Expanding a dictionary is an expensive
@@ -713,7 +721,7 @@
obj_p item5, obj_p item6, obj_p item7, obj_p item8 );
// DICT_ADD: Add a key/value pair to the dictionary. Replace old one if key exists.
-// Key equality is determined by the eq_QUES_ function on the key objects. The eq_QUES_
+// Key equality is determined by the eq__QUES function on the key objects. The eq__QUES
// function is called on the existing key in the dict with the passed key as the parameter.
// If the keys match, then the value in the dictionary is replaced and the existing key
// is left in place. If there is no match the ky and value are added.
@@ -725,7 +733,7 @@
size_t dict_len(isp ist, obj_p dict);
// DICT_ITEM: Look up a value in the dictionary for the given key.
-// Find a key using the same eq_QUES_ match criteria given for
+// Find a key using the same eq__QUES match criteria given for
// dict_add and return the corresponding value object. If no key
// matches then return null.
obj_p dict_item(isp ist, obj_p dict, obj_p key);
@@ -838,14 +846,10 @@
// SLICE_ALL: Convenience macro for creating slice object representing entire sequence
#define SLICE_ALL new_slice_obj(ist, SLICEPARAM_EMPTY, SLICEPARAM_EMPTY, SLICEPARAM_MISSING)
-// NEW_SUPER_OBJ: This represents the reference of a proto of an object
+// NEW_LOCAL_OBJ: This represents the reference of a local variable
// 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 attribute of a proto.
-// Example: If you are in the function of an object self, and you refer to ^x,
-// then you are referring to the attribute x in a proto of self. Then
-// to access ^x in the proto of self do:
-// get_item(ist, self, new_super_obj(ist, sym(ist, "x")));
-obj_p new_super_obj(isp ist, obj_p symbol);
+// 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);
//************************* Prothon C FUNCTION ********************************
// This is the type of C function that the dll author must provide to implement
@@ -1024,7 +1028,7 @@
// represent. For example, float type "covers" int type and long type "covers"
// int type. Covering a value does not mean that some precision will not be lost.
// This test determines when coercion is allowed. It is up to the prototype
-// objects to decide which objects they cover by offering the covers_QUES_ function.
+// objects to decide which objects they cover by offering the covers__QUES function.
#define covers(o1, o2) (call_func1((ist), (o1), SYM(COVERS_), (o2)) == OBJ(PR_TRUE))
Modified: trunk/modules/DBM/DBM.vcproj
===================================================================
--- trunk/modules/DBM/DBM.vcproj 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/modules/DBM/DBM.vcproj 2004-05-12 16:52:02 UTC (rev 466)
@@ -19,7 +19,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\apr\apr-util\include"
+ AdditionalIncludeDirectories="..\..\include;..\..\apr\apr\include;..\..\apr\apr-util\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DBM_EXPORTS;APR_DECLARE_STATIC;APU_DECLARE_STATIC"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
@@ -36,7 +36,7 @@
AdditionalDependencies="apr.lib aprutil.lib wsock32.lib"
OutputFile="$(OutDir)/dbm.dll"
LinkIncremental="2"
- AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR;C:\prothon\apr\apr-util\LibR"
+ AdditionalLibraryDirectories="..\..\apr\apr\LibR;..\..\apr\apr-util\LibR"
IgnoreDefaultLibraryNames="LIBCMTD.LIB"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/dbm.pdb"
@@ -72,7 +72,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\apr\apr-util\include"
+ AdditionalIncludeDirectories="..\..\include;..\..\apr\apr\include;..\..\apr\apr-util\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DBM_EXPORTS;APR_DECLARE_STATIC;APU_DECLARE_STATIC"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
@@ -87,7 +87,7 @@
AdditionalDependencies="apr.lib aprutil.lib wsock32.lib"
OutputFile="$(OutDir)/dbm.dll"
LinkIncremental="1"
- AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR;C:\prothon\apr\apr-util\LibR"
+ AdditionalLibraryDirectories="..\..\apr\apr\LibR;..\..\apr\apr-util\LibR"
IgnoreDefaultLibraryNames="LIBCMTD.LIB"
GenerateDebugInformation="TRUE"
SubSystem="2"
Modified: trunk/modules/File/file.vcproj
===================================================================
--- trunk/modules/File/file.vcproj 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/modules/File/file.vcproj 2004-05-12 16:52:02 UTC (rev 466)
@@ -19,7 +19,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include"
+ AdditionalIncludeDirectories="..\..\include;..\..\apr\apr\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FILE_EXPORTS;APR_DECLARE_STATIC;APU_DECLARE_STATIC"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
@@ -36,7 +36,7 @@
AdditionalDependencies="apr.lib wsock32.lib"
OutputFile="$(OutDir)/file.dll"
LinkIncremental="2"
- AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR"
+ AdditionalLibraryDirectories="..\..\apr\apr\LibR"
IgnoreDefaultLibraryNames="LIBCMTD.lib"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/file.pdb"
@@ -75,7 +75,7 @@
Optimization="2"
InlineFunctionExpansion="1"
OmitFramePointers="TRUE"
- AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include"
+ AdditionalIncludeDirectories="..\..\include;..\..\apr\apr\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FILE_EXPORTS;APR_DECLARE_STATIC;APU_DECLARE_STATIC"
StringPooling="TRUE"
RuntimeLibrary="1"
@@ -92,7 +92,7 @@
AdditionalDependencies="apr.lib wsock32.lib"
OutputFile="$(OutDir)/file.dll"
LinkIncremental="1"
- AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR"
+ AdditionalLibraryDirectories="..\..\apr\apr\LibR"
IgnoreDefaultLibraryNames="LIBCMTD.lib"
GenerateDebugInformation="TRUE"
SubSystem="2"
Modified: trunk/modules/OS/OS.vcproj
===================================================================
--- trunk/modules/OS/OS.vcproj 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/modules/OS/OS.vcproj 2004-05-12 16:52:02 UTC (rev 466)
@@ -19,7 +19,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include"
+ AdditionalIncludeDirectories="..\..\include;..\..\apr\apr\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;OS_EXPORTS"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
@@ -36,7 +36,7 @@
AdditionalDependencies="apr.lib wsock32.lib"
OutputFile="$(OutDir)/OS.dll"
LinkIncremental="2"
- AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR"
+ AdditionalLibraryDirectories="..\..\apr\apr\LibR"
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/OS.pdb"
@@ -72,7 +72,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include"
+ AdditionalIncludeDirectories="..\..\include;..\..\apr\apr\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OS_EXPORTS"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
@@ -87,7 +87,7 @@
AdditionalDependencies="apr.lib wsock32.lib"
OutputFile="$(OutDir)/OS.dll"
LinkIncremental="1"
- AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR"
+ AdditionalLibraryDirectories="..\..\apr\apr\LibR"
IgnoreDefaultLibraryNames=""
GenerateDebugInformation="TRUE"
SubSystem="2"
Modified: trunk/modules/Prosist/Prosist.c
===================================================================
--- trunk/modules/Prosist/Prosist.c 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/modules/Prosist/Prosist.c 2004-05-12 16:52:02 UTC (rev 466)
@@ -1033,7 +1033,7 @@
return new_hash_obj(ist, (i32_t)(intptr_t) self->data.ptr);
}
-DEF(MutWrap, eq_QUES_, FORM_RPARAM) {
+DEF(MutWrap, eq__QUES, FORM_RPARAM) {
BIN_CONTENT_CHK(MutWrap);
CHECK_TYPE_EXC(parms[1], MutWrap_OBJ, "immutable object wrapper");
if (self->data.ptr == parms[1]->data.ptr) return OBJ(PR_TRUE);
@@ -1056,7 +1056,7 @@
MODULE_ADD_SYM(Prosist, objList_);
MODULE_ADD_SYM(MutWrap, hash_);
- MODULE_ADD_SYM(MutWrap, eq_QUES_);
+ MODULE_ADD_SYM(MutWrap, eq__QUES);
MODULE_ADD_SYM(MutWrap, objList_);
check_exceptions(ist);
Modified: trunk/modules/Prosist/Prosist.vcproj
===================================================================
--- trunk/modules/Prosist/Prosist.vcproj 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/modules/Prosist/Prosist.vcproj 2004-05-12 16:52:02 UTC (rev 466)
@@ -19,7 +19,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\apr\apr-util\include"
+ AdditionalIncludeDirectories="..\..\include;..\..\apr\apr\include;..\..\apr\apr-util\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FILE_EXPORTS;APR_DECLARE_STATIC;APU_DECLARE_STATIC"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
@@ -36,7 +36,7 @@
AdditionalDependencies="apr.lib aprutil.lib wsock32.lib"
OutputFile="$(OutDir)/Prosist.dll"
LinkIncremental="2"
- AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR;C:\prothon\apr\apr-util\LibR"
+ AdditionalLibraryDirectories="..\..\apr\apr\LibR;..\..\apr\apr-util\LibR"
IgnoreDefaultLibraryNames="LIBCMTD.LIB"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/Prosist.pdb"
@@ -72,7 +72,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\apr\apr-util\include"
+ AdditionalIncludeDirectories="..\..\include;..\..\apr\apr\include;..\..\apr\apr-util\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PROSIST_EXPORTS;APR_DECLARE_STATIC;APU_DECLARE_STATIC"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
@@ -87,7 +87,7 @@
AdditionalDependencies="apr.lib aprutil.lib wsock32.lib"
OutputFile="$(OutDir)/Prosist.dll"
LinkIncremental="1"
- AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR;C:\prothon\apr\apr-util\LibR"
+ AdditionalLibraryDirectories="..\..\apr\apr\LibR;..\..\apr\apr-util\LibR"
IgnoreDefaultLibraryNames="LIBCMTD.lib"
GenerateDebugInformation="TRUE"
SubSystem="2"
Modified: trunk/modules/Re/re.vcproj
===================================================================
--- trunk/modules/Re/re.vcproj 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/modules/Re/re.vcproj 2004-05-12 16:52:02 UTC (rev 466)
@@ -19,7 +19,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\include\regex"
+ AdditionalIncludeDirectories="..\..\include;..\..\apr\apr\include;..\..\include\regex"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;RE_EXPORTS"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
@@ -72,7 +72,7 @@
Optimization="2"
InlineFunctionExpansion="1"
OmitFramePointers="TRUE"
- AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\include\regex"
+ AdditionalIncludeDirectories="..\..\include;..\..\apr\apr\include;..\..\include\regex"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;RE_EXPORTS"
StringPooling="TRUE"
RuntimeLibrary="1"
Modified: trunk/modules/SQLite/SQLite.vcproj
===================================================================
--- trunk/modules/SQLite/SQLite.vcproj 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/modules/SQLite/SQLite.vcproj 2004-05-12 16:52:02 UTC (rev 466)
@@ -19,7 +19,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\SQLiteC"
+ AdditionalIncludeDirectories="..\..\include;..\..\apr\apr\include;..\..\SQLiteC"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SQLITE_EXPORTS;APR_DECLARE_STATIC;APU_DECLARE_STATIC"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
@@ -36,7 +36,7 @@
AdditionalDependencies="SQLiteC.lib apr.lib wsock32.lib"
OutputFile="$(OutDir)/SQLite.dll"
LinkIncremental="2"
- AdditionalLibraryDirectories="C:\Prothon\SQLiteC\Debug;C:\prothon\apr\apr\LibR"
+ AdditionalLibraryDirectories="..\..\SQLiteC\Debug;..\..\apr\apr\LibR"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/SQLite.pdb"
SubSystem="2"
@@ -71,7 +71,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\SQLiteC"
+ AdditionalIncludeDirectories="..\..\include;..\..\apr\apr\include;..\..\SQLiteC"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SQLITE_EXPORTS"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
@@ -86,7 +86,7 @@
AdditionalDependencies="SQLiteC.lib"
OutputFile="$(OutDir)/SQLite.dll"
LinkIncremental="0"
- AdditionalLibraryDirectories="C:\Prothon\SQLiteC\Debug"
+ AdditionalLibraryDirectories="..\..\SQLiteC\Debug"
IgnoreDefaultLibraryNames="LIBCMTD.lib"
GenerateDebugInformation="TRUE"
SubSystem="2"
Modified: trunk/pr/test.pr
===================================================================
--- trunk/pr/test.pr 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/pr/test.pr 2004-05-12 16:52:02 UTC (rev 466)
@@ -1,42 +1,20 @@
#!/usr/bin/env prothon
-if not e.hasKey?(1) or e.hasKey?(2): print 'error4'
-/*
+x = 1
+object obj(Object):
+ print x
+ y = 4
-d = {1:2}
-if d.keys() != [1] : print 'error in keys'
-if d.values() != [2] : print 'error in values'
-if d.get(1) != 2 : print 'error1 in get'
-if d.get(2) != None : print 'error2 in get'
-if d.get(3,4) != 4 : print 'error3 in get'
-if d.get(3,5) != 5 : print 'error4 in get'
-if d.setDefault!(3,4) != 4 : print 'error5 in setdefault'
-if d.get(3,5) != 4 : print 'error6 in get'
-if 3 not in d: print 'error 7 in notin'
+ def init_(x):
+ self.x = x
-d = {1:2, 3:4}
-e = d.copy()
-
-if d.items() != e.items():
- print 'error1'
-
-if Len(e.items()) != 2:
- print 'error2'
+ def func():
+ print 'x1',x
+ outer.x = 2
+ print 'x2',x
+ print 'self.x', self.x
+ print 'outer.y', outer.y
-d.clear!()
+z = obj(3)
+z.func()
-d = {1:2}
-d.update!({3:4})
-if d.items() != e.items():
- print d.items(), e.items(), 'error3'
-
-if not e.hasKey?(1) or e.hasKey?(2): print 'error4'
-
-print 'all tests passed'
-
-print '\nfollowing should be: 1 (1, 2) 3 (3, 4)\n'
-
-for i in e: print i, d.popItem!(),
-
-print '\n'
-*/
\ No newline at end of file
Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/builtins-core.c 2004-05-12 16:52:02 UTC (rev 466)
@@ -85,7 +85,8 @@
set_obj_doc(OBJ(SYMBOL_PROTO), "Symbol object prototype");
set_obj_doc(OBJ(HASH_PROTO), "Hash object prototype");
set_obj_doc(OBJ(SLICE_PROTO), "Slice object prototype");
- set_obj_doc(OBJ(SUPER_PROTO), "Super object prototype");
+ set_obj_doc(OBJ(LOCAL_PROTO), "Local object prototype");
+ set_obj_doc(OBJ(OUTER_PROTO), "Outer 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");
@@ -255,21 +256,21 @@
return proto_list(ist, self);
}
-DEF(Object, bool_QUES_, NULL) { return OBJ(PR_TRUE); }
-DEF(Object, not_QUES_, NULL)
+DEF(Object, bool__QUES, NULL) { return OBJ(PR_TRUE); }
+DEF(Object, not__QUES, NULL)
{
- if (call_func0(ist, self, SYM(BOOL_QUES_)) == OBJ(PR_TRUE))
+ if (call_func0(ist, self, SYM(BOOL__QUES)) == OBJ(PR_TRUE))
return OBJ(PR_FALSE);
else
return OBJ(PR_TRUE);
}
-DEF(Object, is_QUES_, FORM_RPARAM) {
+DEF(Object, is__QUES, FORM_RPARAM) {
if (self == parms[1]) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
-DEF(Object, isNot_QUES_, FORM_RPARAM) {
+DEF(Object, isNot__QUES, FORM_RPARAM) {
if (self != parms[1]) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
@@ -289,7 +290,7 @@
return new_hash_obj(ist, (i32_t)(uintptr_t) self);
}
-DEF(Object, eq_QUES_, FORM_RPARAM) {
+DEF(Object, eq__QUES, FORM_RPARAM) {
obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]);
if(catch_exception(ist, OBJ(FUNCNOTFOUND_EXC), NULL))
return OBJ(PR_FALSE);
@@ -299,44 +300,44 @@
return OBJ(PR_FALSE);
}
-DEF(Object, ne_QUES_, FORM_RPARAM) {
- obj_p cmp_obj = call_func1(ist, self, SYM(EQ_QUES_), parms[1]); if_exc_return NULL;
+DEF(Object, ne__QUES, FORM_RPARAM) {
+ obj_p cmp_obj = call_func1(ist, self, SYM(EQ__QUES), parms[1]); if_exc_return NULL;
if (cmp_obj == OBJ(PR_TRUE))
return OBJ(PR_FALSE);
else
return OBJ(PR_TRUE);
}
-DEF(Object, lt_QUES_, FORM_RPARAM) {
+DEF(Object, lt__QUES, FORM_RPARAM) {
obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]); if_exc_return NULL;
if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) < 0) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
-DEF(Object, le_QUES_, FORM_RPARAM) {
+DEF(Object, le__QUES, FORM_RPARAM) {
obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]); if_exc_return NULL;
if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) <= 0) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
-DEF(Object, gt_QUES_, FORM_RPARAM) {
+DEF(Object, gt__QUES, FORM_RPARAM) {
obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]); if_exc_return NULL;
if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) > 0) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
-DEF(Object, ge_QUES_, FORM_RPARAM) {
+DEF(Object, ge__QUES, FORM_RPARAM) {
obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]); if_exc_return NULL;
if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) >= 0) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
-DEF(Object, in_QUES_, FORM_RPARAM) {
- return call_func1(ist, parms[1], SYM(RIN_QUES_), self);
+DEF(Object, in__QUES, FORM_RPARAM) {
+ return call_func1(ist, parms[1], SYM(RIN__QUES), self);
}
-DEF(Object, notIn_QUES_, FORM_RPARAM) {
- return call_func1(ist, parms[1], SYM(RNOTIN_QUES_), self);
+DEF(Object, notIn__QUES, FORM_RPARAM) {
+ return call_func1(ist, parms[1], SYM(RNOTIN__QUES), self);
}
DEF(Object, attrs, NULL) {
@@ -390,7 +391,7 @@
}
DEF(False, str_, NULL) { return NEW_STRING("False"); }
-DEF(False, bool_QUES_, NULL) { return False_OBJ; }
+DEF(False, bool__QUES, NULL) { return False_OBJ; }
DEF(False, cmp, FORM_RPARAM) {
if (parms[1] == False_OBJ)
return NEW_INT(0);
@@ -409,7 +410,7 @@
}
DEF(True, str_, NULL) { return NEW_STRING("True"); }
-DEF(True, bool_QUES_, NULL) { return True_OBJ; }
+DEF(True, bool__QUES, NULL) { return True_OBJ; }
DEF(True, cmp, FORM_RPARAM) {
if (parms[1] == OBJ(PR_FALSE))
return NEW_INT(1);
@@ -436,11 +437,11 @@
return NEW_STRING("None");
}
-DEF(None, bool_QUES_, NULL) {
+DEF(None, bool__QUES, NULL) {
return OBJ(PR_FALSE);
}
-DEF(None, eq_QUES_, FORM_RPARAM) {
+DEF(None, eq__QUES, FORM_RPARAM) {
if (parms[1] == OBJ(NONE)) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
@@ -684,7 +685,7 @@
}
DEF(Func, init_, FORM_RPARAM) {
- obj_p other, fparms, globals, syn_locals, obj;
+ obj_p other, fparms;
code_p optr;
int size;
@@ -697,25 +698,9 @@
}
self->data_type = other->data_type;
if (self->data_type == DATA_TYPE_DATAPTR) {
- if (!(globals = get_attr(ist, other, SYM(GLOBALS_)))) {
- raise_exception(ist, OBJ(INTERNAL_EXC), "Func init_ global specifier missing");
- return NULL;
- }
- if (!(syn_locals = get_attr(ist, other, SYM(SYN_LOCALS_)))) {
- raise_exception(ist, OBJ(INTERNAL_EXC), "Func init_ syn_locals specifier missing");
- return NULL;
- }
- read_unlock(ist, self);
size = (int) (sizeof(code) + optr->len * sizeof(code_t));
self->data.ptr = pr_malloc(size);
memcpy(self->data.ptr, other->data.ptr, size);
- set_attr(ist, self, SYM(GLOBALS_), globals);
- set_attr(ist, self, SYM(SYN_LOCALS_), syn_locals);
- if (obj = get_attr(ist, other, SYM(SYN_SELF_)))
- set_attr(ist, self, SYM(SYN_SELF_), obj);
- if (obj = get_attr(ist, other, SYM(SYN_FUNC_)))
- set_attr(ist, self, SYM(SYN_FUNC_), obj);
- read_lock(ist, self);
} else
self->data.ptr = other->data.ptr;
read_unlock(ist, self);
@@ -783,20 +768,20 @@
MODULE_ADD_SYM(Object, getItem_);
MODULE_ADD_SYM(Object, setItem_);
MODULE_ADD_SYM(Object, delItem_);
- MODULE_ADD_SYM(Object, bool_QUES_);
- MODULE_ADD_SYM(Object, not_QUES_);
- MODULE_ADD_SYM(Object, is_QUES_);
- MODULE_ADD_SYM(Object, isNot_QUES_);
+ MODULE_ADD_SYM(Object, bool__QUES);
+ MODULE_ADD_SYM(Object, not__QUES);
+ MODULE_ADD_SYM(Object, is__QUES);
+ MODULE_ADD_SYM(Object, isNot__QUES);
MODULE_ADD_SYM(Object, str_);
MODULE_ADD_SYM(Object, hash_);
- MODULE_ADD_SYM(Object, eq_QUES_);
- MODULE_ADD_SYM(Object, ne_QUES_);
- MODULE_ADD_SYM(Object, lt_QUES_);
- MODULE_ADD_SYM(Object, le_QUES_);
- MODULE_ADD_SYM(Object, gt_QUES_);
- MODULE_ADD_SYM(Object, ge_QUES_);
- MODULE_ADD_SYM(Object, in_QUES_);
- MODULE_ADD_SYM(Object, notIn_QUES_);
+ MODULE_ADD_SYM(Object, eq__QUES);
+ MODULE_ADD_SYM(Object, ne__QUES);
+ MODULE_ADD_SYM(Object, lt__QUES);
+ MODULE_ADD_SYM(Object, le__QUES);
+ MODULE_ADD_SYM(Object, gt__QUES);
+ 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);
@@ -807,19 +792,19 @@
MODULE_SUB_INIT(False);
MODULE_ADD_SYM(False, str_);
- MODULE_ADD_SYM(False, bool_QUES_);
+ MODULE_ADD_SYM(False, bool__QUES);
MODULE_ADD_SYM(False, cmp);
MODULE_SUB_INIT(True);
MODULE_ADD_SYM(True, str_);
- MODULE_ADD_SYM(True, bool_QUES_);
+ MODULE_ADD_SYM(True, bool__QUES);
MODULE_ADD_SYM(True, cmp);
MODULE_ADD_SYM(True, getCmp_);
MODULE_SUB_INIT(None);
MODULE_ADD_SYM(None, str_);
- MODULE_ADD_SYM(None, bool_QUES_);
- MODULE_ADD_SYM(None, eq_QUES_);
+ MODULE_ADD_SYM(None, bool__QUES);
+ MODULE_ADD_SYM(None, eq__QUES);
MODULE_SUB_INIT(Exception);
MODULE_ADD_SYM(Exception, init_);
Modified: trunk/src/builtins-dict.c
===================================================================
--- trunk/src/builtins-dict.c 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/builtins-dict.c 2004-05-12 16:52:02 UTC (rev 466)
@@ -142,7 +142,7 @@
hash = dp->entry.hash;
if (hash < 0) { hole = dp; continue; }
if ( hash == hash_in && ( key == key_in ||
- call_func(ist, key, SYM(EQ_QUES_), 2, rp, NULL) == OBJ(PR_TRUE) ) ) {
+ call_func(ist, key, SYM(EQ__QUES), 2, rp, NULL) == OBJ(PR_TRUE) ) ) {
match = PR_TRUE;
break;
}
@@ -191,7 +191,7 @@
dict = (dict_p) obj_data_p(dict_obj);
for (i=hash_in; (key=((dp=dictptr(dict,i))->entry.key)); i++){
if ( dp->entry.hash == hash_in && ( key == key_in ||
- call_func(ist, key, SYM(EQ_QUES_), 2, rp, NULL) == OBJ(PR_TRUE) ) ) {
+ call_func(ist, key, SYM(EQ__QUES), 2, rp, NULL) == OBJ(PR_TRUE) ) ) {
dict_rd_chk();
res = dp->entry.value;
read_unlock(ist, dict_obj);
@@ -357,7 +357,7 @@
return parms[3];
}
-DEF(Dict, rIn_QUES_, FORM_RPARAM) {
+DEF(Dict, rIn__QUES, FORM_RPARAM) {
obj_p res;
BIN_CONTENT_CHK(Dict);
if ((res = dict_item(ist, self, parms[1]))) {
@@ -367,7 +367,7 @@
return OBJ(PR_FALSE);
}
-DEF(Dict, rNotIn_QUES_, FORM_RPARAM) {
+DEF(Dict, rNotIn__QUES, FORM_RPARAM) {
obj_p res;
BIN_CONTENT_CHK(Dict);
if ((res = dict_item(ist, self, parms[1]))) {
@@ -437,7 +437,7 @@
dict = (dict_p) self->data.ptr;
for(i=hash_in; (key=((dp=dictptr(dict,i))->entry.key)); i++){
if ( dp->entry.hash == hash_in && ( key == key_in ||
- call_func(ist, key, SYM(EQ_QUES_), 2, rp, NULL) == OBJ(PR_TRUE) ) ) {
+ call_func(ist, key, SYM(EQ__QUES), 2, rp, NULL) == OBJ(PR_TRUE) ) ) {
dp->entry.hash = ENTRY_DELETED;
dictlen(dict)--;
def_write_unlock(self);
@@ -588,8 +588,8 @@
MODULE_ADD_SYM(Dict, update_BANG);
MODULE_ADD_SYM(Dict, setDefault_BANG);
MODULE_ADD_SYM(Dict, popItem_BANG);
- MODULE_ADD_SYM(Dict, rIn_QUES_);
- MODULE_ADD_SYM(Dict, rNotIn_QUES_);
+ MODULE_ADD_SYM(Dict, rIn__QUES);
+ MODULE_ADD_SYM(Dict, rNotIn__QUES);
MODULE_ADD_SYM(Dict, getItem_);
MODULE_ADD_SYM(Dict, setItem_);
MODULE_ADD_SYM(Dict, delItem_);
Modified: trunk/src/builtins-float.c
===================================================================
--- trunk/src/builtins-float.c 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/builtins-float.c 2004-05-12 16:52:02 UTC (rev 466)
@@ -119,7 +119,7 @@
return OBJ(NONE);
}
-DEF(Float, bool_QUES_, NULL) {
+DEF(Float, bool__QUES, NULL) {
BIN_CONTENT_CHK(Float);
if (Float_value(self) != 0.0 )
return OBJ(PR_TRUE);
@@ -343,7 +343,7 @@
return NEW_INT(-1);
}
-DEF(Float, eq_QUES_, FORM_RPARAM){
+DEF(Float, eq__QUES, FORM_RPARAM){
double float_other;
obj_p other = parms[1];
BIN_CONTENT_CHK(Float);
@@ -353,7 +353,7 @@
float_other = (double)other->data.i64;
else {
if (covers(other, self))
- return call_func1(ist, other, SYM(EQ_QUES_), self);
+ return call_func1(ist, other, SYM(EQ__QUES), self);
return OBJ(PR_FALSE);
}
}
@@ -368,7 +368,7 @@
return NEW_STRING(str);
}
-DEF(Float, covers_QUES_, FORM_RPARAM) {
+DEF(Float, covers__QUES, FORM_RPARAM) {
BIN_CONTENT_CHK(Float);
if (has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
@@ -391,10 +391,10 @@
{
MODULE_SUB_INIT(Float);
MODULE_ADD_SYM(Float, init_);
- MODULE_ADD_SYM(Float, bool_QUES_);
+ MODULE_ADD_SYM(Float, bool__QUES);
MODULE_ADD_SYM(Float, str_);
MODULE_ADD_SYM(Float, hash_);
- MODULE_ADD_SYM(Float, eq_QUES_);
+ MODULE_ADD_SYM(Float, eq__QUES);
MODULE_ADD_SYM(Float, cmp);
MODULE_ADD_SYM(Float, rCmp_);
MODULE_ADD_SYM(Float, abs_);
@@ -408,7 +408,7 @@
MODULE_ADD_SYM(Float, rDiv_);
MODULE_ADD_SYM(Float, pow_);
MODULE_ADD_SYM(Float, rPow_);
- MODULE_ADD_SYM(Float, covers_QUES_);
+ MODULE_ADD_SYM(Float, covers__QUES);
MODULE_ADD_SYM(Float, coerce_);
check_exceptions(ist);
Modified: trunk/src/builtins-int.c
===================================================================
--- trunk/src/builtins-int.c 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/builtins-int.c 2004-05-12 16:52:02 UTC (rev 466)
@@ -126,7 +126,7 @@
return NEW_STRING(str);
}
-DEF(Int, bool_QUES_, NULL) {
+DEF(Int, bool__QUES, NULL) {
BIN_CONTENT_CHK(Int);
if (Int_value(self)) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
@@ -267,14 +267,14 @@
return NEW_INT(-1);
}
-DEF(Int, eq_QUES_, FORM_RPARAM){
+DEF(Int, eq__QUES, FORM_RPARAM){
obj_p other = parms[1];
BIN_CONTENT_CHK(Int);
if (!is_Int(other)) {
int c = covers(other, self);
if (catch_exception(ist, OBJ(FUNCNOTFOUND_EXC), NULL))
return FALSE;
- if (c) return call_func1(ist, other, SYM(EQ_QUES_), self);
+ if (c) return call_func1(ist, other, SYM(EQ__QUES), self);
return OBJ(PR_FALSE);
}
if (Int_value(self) == Int_value(other)) return OBJ(PR_TRUE);
@@ -386,10 +386,10 @@
MODULE_SUB_INIT(Int);
MODULE_ADD_SYM(Int, init_);
- MODULE_ADD_SYM(Int, bool_QUES_);
+ MODULE_ADD_SYM(Int, bool__QUES);
MODULE_ADD_SYM(Int, str_);
MODULE_ADD_SYM(Int, hash_);
- MODULE_ADD_SYM(Int, eq_QUES_);
+ MODULE_ADD_SYM(Int, eq__QUES);
MODULE_ADD_SYM(Int, cmp);
MODULE_ADD_SYM(Int, chr);
MODULE_ADD_SYM(Int, abs_);
Modified: trunk/src/builtins-list.c
===================================================================
--- trunk/src/builtins-list.c 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/builtins-list.c 2004-05-12 16:52:02 UTC (rev 466)
@@ -267,7 +267,7 @@
}
arr[0] = NULL;
arr[1] = b;
- res = call_func(ist, a, SYM(EQ_QUES_), 2, arr, NULL);
+ res = call_func(ist, a, SYM(EQ__QUES), 2, arr, NULL);
if_exc_return 0;
return (res == OBJ(PR_TRUE));
}
@@ -675,7 +675,7 @@
selfp = self->data.ptr;
self_len = lstplen(selfp);
for (i=0; i < self_len; i++) {
- if (call_func1(ist, listitem(self, i), SYM(EQ_QUES_), parms[1]) == OBJ(PR_TRUE)) break;
+ if (call_func1(ist, listitem(self, i), SYM(EQ__QUES), parms[1]) == OBJ(PR_TRUE)) break;
if_exc_return NULL;
}
if (i == self_len) {
Modified: trunk/src/builtins-string.c
===================================================================
--- trunk/src/builtins-string.c 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/builtins-string.c 2004-05-12 16:52:02 UTC (rev 466)
@@ -446,18 +446,18 @@
return obj;
}
-DEF(String, in_QUES_, FORM_RPARAM) {
+DEF(String, in__QUES, FORM_RPARAM) {
BIN_CONTENT_CHK(String);
if (!has_proto_QUES(ist, parms[1], String_OBJ))
- return call_func1(ist, parms[1], SYM(RIN_QUES_), self);
+ 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);
}
-DEF(String, notIn_QUES_, FORM_RPARAM) {
+DEF(String, notIn__QUES, FORM_RPARAM) {
BIN_CONTENT_CHK(String);
if (!has_proto_QUES(ist, parms[1], String_OBJ))
- return call_func1(ist, parms[1], SYM(RNOTIN_QUES_), self);
+ 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);
}
@@ -467,7 +467,7 @@
return NEW_INT(pr_strlen(self));
}
-DEF(String, bool_QUES_, NULL) {
+DEF(String, bool__QUES, NULL) {
BIN_CONTENT_CHK(String);
if (pr_strlen(self)) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
@@ -785,7 +785,7 @@
{
MODULE_SUB_INIT(String);
MODULE_ADD_SYM(String, init_);
- MODULE_ADD_SYM(String, bool_QUES_);
+ MODULE_ADD_SYM(String, bool__QUES);
MODULE_ADD_SYM(String, str_);
MODULE_ADD_SYM(String, hash_);
MODULE_ADD_SYM(String, cmp);
@@ -797,8 +797,8 @@
MODULE_ADD_SYM(String, mod_);
MODULE_ADD_SYM(String, iter_);
MODULE_ADD_SYM(String, join);
- MODULE_ADD_SYM(String, in_QUES_);
- MODULE_ADD_SYM(String, notIn_QUES_);
+ MODULE_ADD_SYM(String, in__QUES);
+ MODULE_ADD_SYM(String, notIn__QUES);
MODULE_ADD_SYM(String, setItem_);
MODULE_ADD_SYM(String, delItem_);
MODULE_ADD_SYM(String, lower);
Modified: trunk/src/builtins-tuple.c
===================================================================
--- trunk/src/builtins-tuple.c 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/builtins-tuple.c 2004-05-12 16:52:02 UTC (rev 466)
@@ -154,7 +154,7 @@
return OBJ(ZERO_INT);
}
-DEF(Tuple, eq_QUES_, FORM_RPARAM) {
+DEF(Tuple, eq__QUES, FORM_RPARAM) {
int i, llen, tlen;
obj_p self_item, tgt_item, tgt_list, false_obj = OBJ(PR_FALSE);
BIN_CONTENT_CHK(Tuple);
@@ -166,33 +166,33 @@
for(i=0; i < llen; i++) {
self_item = list_item(ist, self, i);
tgt_item = list_item(ist, tgt_list, i);
- if (call_func1(ist, self_item, SYM(EQ_QUES_), tgt_item) == false_obj)
+ if (call_func1(ist, self_item, SYM(EQ__QUES), tgt_item) == false_obj)
return false_obj;
else if_exc_return NULL;
}
return OBJ(PR_TRUE);
}
-DEF(Tuple, rIn_QUES_, FORM_RPARAM) {
+DEF(Tuple, rIn__QUES, FORM_RPARAM) {
int i, llen = (int) list_len(ist, self);
obj_p item, tgt = parms[1];
BIN_CONTENT_CHK(Tuple);
for(i=0; i < llen; i++) {
item = list_item(ist, self, i);
- if (call_func1(ist, item, SYM(EQ_QUES_), tgt) == OBJ(PR_TRUE))
+ if (call_func1(ist, item, SYM(EQ__QUES), tgt) == OBJ(PR_TRUE))
return OBJ(PR_TRUE);
else if_exc_return NULL;
}
return OBJ(PR_FALSE);
}
-DEF(Tuple, rNotIn_QUES_, FORM_RPARAM) {
+DEF(Tuple, rNotIn__QUES, FORM_RPARAM) {
int i, llen = (int) list_len(ist, self);
obj_p item, tgt = parms[1];
BIN_CONTENT_CHK(Tuple);
for(i=0; i < llen; i++) {
item = list_item(ist, self, i);
- if (call_func1(ist, item, SYM(EQ_QUES_), tgt) == OBJ(PR_TRUE))
+ if (call_func1(ist, item, SYM(EQ__QUES), tgt) == OBJ(PR_TRUE))
return OBJ(PR_FALSE);
else if_exc_return NULL;
}
@@ -284,7 +284,7 @@
int i, cnt=0, llen = (int) list_len(ist, self);
BIN_CONTENT_CHK(Tuple);
for (i=0; i < llen; i++) {
- if (call_func1(ist, list_item(ist, self, i), SYM(EQ_QUES_), parms[1]) == OBJ(PR_TRUE))
+ if (call_func1(ist, list_item(ist, self, i), SYM(EQ__QUES), parms[1]) == OBJ(PR_TRUE))
cnt++;
if_exc_return NULL;
}
@@ -295,7 +295,7 @@
int i, llen = (int) list_len(ist, self);
BIN_CONTENT_CHK(Tuple);
for (i=0; i < llen; i++) {
- if (call_func1(ist, list_item(ist, self, i), SYM(EQ_QUES_), parms[1]) == OBJ(PR_TRUE))
+ if (call_func1(ist, list_item(ist, self, i), SYM(EQ__QUES), parms[1]) == OBJ(PR_TRUE))
return NEW_INT(i);
if_exc_return NULL;
}
@@ -363,14 +363,14 @@
MODULE_ADD_SYM(Tuple, min);
MODULE_ADD_SYM(Tuple, max);
MODULE_ADD_SYM(Tuple, cmp);
- MODULE_ADD_SYM(Tuple, eq_QUES_);
+ MODULE_ADD_SYM(Tuple, eq__QUES);
MODULE_ADD_SYM(Tuple, count);
MODULE_ADD_SYM(Tuple, index);
MODULE_ADD_SYM(Tuple, getItem_);
MODULE_ADD_SYM(Tuple, add_);
MODULE_ADD_SYM(Tuple, mul_);
- MODULE_ADD_SYM(Tuple, rIn_QUES_);
- MODULE_ADD_SYM(Tuple, rNotIn_QUES_);
+ MODULE_ADD_SYM(Tuple, rIn__QUES);
+ MODULE_ADD_SYM(Tuple, rNotIn__QUES);
MODULE_ADD_SYM(Tuple, iter_);
MODULE_ADD_SYM(Tuple, setItem_);
MODULE_ADD_SYM(Tuple, delItem_);
Modified: trunk/src/bytecodes.h
===================================================================
--- trunk/src/bytecodes.h 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/bytecodes.h 2004-05-12 16:52:02 UTC (rev 466)
@@ -129,7 +129,7 @@
// Push new execution frame identical to last except with locals
// equal to top-of-stack. Similar to a call.
// Code is in a simple function-object that only has code.
-// stack: self -> <empty>
+// stack: local-scope-obj -> <empty>
// param: total word count (==2)
// |opcode|func-obj|
OP_WITH,
@@ -162,13 +162,6 @@
//*** The combined obj/reference represents attributes or data
//*** contained in the object that can be read from or written to.
-// PUSH_DEF_LOCAL_REF(symbol)
-// push default local reference (local-obj/ref) onto stack
-// stack: -> def-local,symbol
-// param: <unused>
-// |opcode|symbol-key|
-OP_PUSH_DEF_LOCAL_REF,
-
// PUSH_LOCAL_REF(symbol)
// push local reference (local-obj/ref) onto stack
// stack: -> local-scope,symbol
@@ -176,42 +169,21 @@
// |opcode|symbol-key|
OP_PUSH_LOCAL_REF,
-// PUSH_DEF_GLOBAL_REF(Symbol)
-// push default global reference (global-obj/ref) onto stack
-// stack: -> def-global,symbol
-// param: <unused>
-// |opcode|symbol-key|
-OP_PUSH_DEF_GLOBAL_REF,
-
-// PUSH_GLOBAL_REF(Symbol)
-// push global reference (global-obj/ref) onto stack
-// stack: -> global-scope,symbol
-// param: <unused>
-// |opcode|symbol-key|
-OP_PUSH_GLOBAL_REF,
-
-// PUSH_SELF_REF(.symbol)
+// PUSH_SELF_REF(self.symbol)
// push self or inherited self obj reference (self/ref) onto stack
// stack: -> self-obj,symbol
// param: <unused>
// |opcode|symbol-key|
OP_PUSH_SELF_REF,
-// PUSH_SUPER_REF(.symbol)
+// PUSH_OUTER_REF(outer.symbol)
// push inherited super obj reference (super/ref) onto stack
// stack: -> super-obj,symbol
// param: <unused>
// |opcode|symbol-key|
-OP_PUSH_SUPER_REF,
-
-// PUSH_SUPER_REF(.symbol)
-// push inherited super obj reference (super/ref) onto stack
-// stack: -> super-obj,symbol
-// param: <unused>
-// |opcode|symbol-key|
OP_PUSH_OUTER_REF,
-// PUSH_SUPER_REF(.symbol)
+// PUSH_CALLER_REF(caller.symbol)
// push inherited super obj reference (super/ref) onto stack
// stack: -> super-obj,symbol
// param: <unused>
@@ -278,36 +250,12 @@
// |opcode|
OP_RESTORE_TMP,
-// PUSH_LOCAL
-// push local scope object-id onto stack
-// param: <unused>
-// |opcode|
-OP_PUSH_LOCAL,
-
-// PUSH_GLOBAL
-// push global scope object-id onto stack
-// param: <unused>
-// |opcode|
-OP_PUSH_GLOBAL,
-
// PUSH_SELF
// push self scope object-id onto stack
// param: <unused>
// |opcode|
OP_PUSH_SELF,
-// PUSH_SUPER
-// push super scope object-id onto stack
-// param: <unused>
-// |opcode|
-OP_PUSH_SUPER,
-
-// PUSH_OUTER
-// push outer scope object-id onto stack
-// param: <unused>
-// |opcode|
-OP_PUSH_OUTER,
-
// PUSH_CALLER
// push caller scope object-id onto stack
// param: <unused>
Modified: trunk/src/console.c
===================================================================
--- trunk/src/console.c 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/console.c 2004-05-12 16:52:02 UTC (rev 466)
@@ -180,17 +180,16 @@
#define PROTHON_HISTORY ".prothon_history"
void console(isp ist) {
- obj_p res, new_globals, new_locals;
+ obj_p res, new_self, new_locals;
frame_p frame = NULL;
char buf[16];
int ind_level = 0, colon_flg = FALSE;
char histfile[512], *home;
+ new_self = new_object(ist, NULL);
if (!ist->frame) {
new_locals = NEW_OBJ(NULL);
- new_globals = NEW_OBJ(NULL);
- frame = create_frame( ist, NULL, new_globals, new_globals,
- new_locals, new_locals, new_locals, NULL, NULL );
+ frame = create_frame(ist, new_self, new_locals, new_locals, new_locals, NULL, NULL);
}
if ((home = getenv("HOME")) != NULL)
Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/interp.c 2004-05-12 16:52:02 UTC (rev 466)
@@ -95,9 +95,9 @@
}
//******************************** create_frame *****************************
-frame_p create_frame( isp ist, obj_p syn_self, obj_p self, obj_p globals,
- obj_p syn_locals, obj_p dyn_locals, obj_p locals,
- obj_p func_obj, code_p code_in ) {
+frame_p create_frame( isp ist, obj_p self, obj_p syn_locals, obj_p dyn_locals,
+ obj_p locals, obj_p func_obj, code_p code_in ) {
+ obj_p prev_scope;
frame_p frame;
code_p code = NULL;
size_t flen;
@@ -108,35 +108,42 @@
memset(frame, 0, flen);
if (func_obj) frame->func = func_obj;
- frame->syn_self = syn_self;
- frame->self = self;
- frame->globals = (func_obj ? get_attr(ist, func_obj, SYM(GLOBALS_)) : globals);
- frame->syn_locals = (func_obj ? get_attr(ist, func_obj, SYM(SYN_LOCALS_)) : syn_locals);
- frame->dyn_locals = dyn_locals;
- frame->locals = locals;
- frame->code = code;
- if(!frame->globals) frame->globals = globals;
- if(!frame->syn_locals) frame->syn_locals = syn_locals;
- if(!frame->syn_locals) frame->syn_locals = locals;
+ frame->self = self;
+ frame->dyn_locals = dyn_locals;
+ frame->locals = locals;
+ frame->code = code;
if(!frame->dyn_locals) frame->dyn_locals = locals;
- pr_assert(frame->globals && frame->syn_locals && frame->dyn_locals && frame->locals);
- frame->def_locals = frame->locals;
- frame->def_globals = frame->globals;
+ pr_assert(frame->dyn_locals && frame->locals);
+
+ prev_scope = (func_obj ? get_attr(ist, func_obj, SYM(PREV_SCOPE_)) : syn_locals);
+ if (!prev_scope && syn_locals) prev_scope = syn_locals;
+ if (prev_scope)
+ set_attr(ist, frame->locals, SYM(PREV_SCOPE_), prev_scope);
+
return frame;
}
#define ERR 1
#define OK 0
-//********************************* new_super_obj *****************************
-obj_p new_super_obj(isp ist, obj_p symbol){
- obj_p super_obj = NEW_OBJ(OBJ(SUPER_PROTO));
- super_obj->data_type = DATA_TYPE_DATAPTR;
- super_obj->data.ptr = symbol;
- super_obj->immutable = TRUE;
- return super_obj;
+//********************************* new_local_obj *****************************
+obj_p new_local_obj(isp ist, obj_p symbol){
+ obj_p local_obj = NEW_OBJ(OBJ(LOCAL_PROTO));
+ local_obj->data_type = DATA_TYPE_DATAPTR;
+ local_obj->data.ptr = symbol;
+ local_obj->immutable = TRUE;
+ return local_obj;
}
+//********************************* new_outer_obj *****************************
+obj_p new_outer_obj(isp ist, obj_p symbol){
+ obj_p outer_obj = NEW_OBJ(OBJ(OUTER_PROTO));
+ outer_obj->data_type = DATA_TYPE_DATAPTR;
+ outer_obj->data.ptr = symbol;
+ outer_obj->immutable = TRUE;
+ return outer_obj;
+}
+
//********************************* new_slice_obj *****************************
obj_p new_slice_obj(isp ist, obj_p ind1, obj_p ind2, obj_p ind3) {
obj_p slice_obj = NEW_LIST(3);
@@ -167,20 +174,29 @@
if (has_proto_QUES(ist, ref_key, OBJ(SYMBOL_PROTO))) {
obj_p res;
if_exc_return NULL;
- res = get_attr_in_chain(ist, ref_self, ref_key, NULL, NULL);
+ res = get_proto_attr(ist, ref_self, ref_key, NULL, NULL);
if (!res) {
raise_exception(ist, OBJ(NAME_EXC), "Attribute %s not found",
symch(ist, ref_key));
}
return res;
+ } else if (has_proto_QUES(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))) {
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(SUPER_PROTO))) {
+ } else if (has_proto_QUES(ist, ref_key, OBJ(OUTER_PROTO))) {
+ obj_p res;
if_exc_return NULL;
- return get_attr_in_chain(ist, ref_self, ref_key->data.ptr, NULL, ref_self);
+ res = get_scope_attr(ist, ref_self, ref_key->data.ptr, NULL, ref_self);
+ if (!res) {
+ raise_exception(ist, OBJ(INTERPRETER_EXC), "outer.%s not found", as_str(ist, ref_key->data.ptr));
+ return NULL;
+ }
+ return res;
} else {
raise_exception(ist, OBJ(INTERNAL_EXC), "Invalid reference type");
return NULL;
@@ -192,24 +208,25 @@
if (has_proto_QUES(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))) {
+ set_attr(ist, ref_self, ref_key->data.ptr, value);
} else if (has_proto_QUES(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(SUPER_PROTO))) {
- obj_p proto_obj;
- get_attr_in_chain(ist, ref_self, ref_key->data.ptr, &proto_obj, ref_self);
+ } else if (has_proto_QUES(ist, ref_key, OBJ(OUTER_PROTO))) {
+ obj_p scope_obj;
if_exc_return;
- if (!proto_obj) {
- obj_p proto_list_obj = proto_list(ist, ref_self); if_exc_return;
- proto_obj = list_item(ist, proto_list_obj, 1);
+ get_scope_attr(ist, ref_self, ref_key->data.ptr, &scope_obj, ref_self);
+ if (!scope_obj) {
+ raise_exception(ist, OBJ(INTERPRETER_EXC), "outer.%s not found", as_str(ist, ref_key->data.ptr));
+ return;
}
- set_attr(ist, proto_obj, ref_key->data.ptr, value);
- } else {
+ if_exc_return;
+ set_attr(ist, scope_obj, ref_key->data.ptr, value);
+ } else
raise_exception(ist, OBJ(INTERNAL_EXC), "Invalid reference type");
- return;
- }
}
//********************************* del_item ***********************************
@@ -217,19 +234,24 @@
if (has_proto_QUES(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))) {
+ del_attr(ist, ref_self, ref_key->data.ptr);
} else if (has_proto_QUES(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(SUPER_PROTO))) {
- obj_p proto_obj;
- get_attr_in_chain(ist, ref_self, ref_key->data.ptr, &proto_obj, ref_self);
+ } else if (has_proto_QUES(ist, ref_key, OBJ(OUTER_PROTO))) {
+ obj_p scope_obj;
if_exc_return;
- if (proto_obj) del_attr(ist, proto_obj, ref_key->data.ptr);
- } else {
+ get_scope_attr(ist, ref_self, ref_key->data.ptr, &scope_obj, ref_self);
+ if (!scope_obj) {
+ raise_exception(ist, OBJ(INTERPRETER_EXC), "outer.%s not found", as_str(ist, ref_key->data.ptr));
+ return;
+ }
+ if_exc_return;
+ del_attr(ist, scope_obj, ref_key->data.ptr);
+ } else
raise_exception(ist, OBJ(INTERNAL_EXC), "Invalid reference type");
- return;
- }
}
//******************************** add_pos_param ******************************
@@ -472,12 +494,9 @@
else
ch = *module_name;
- if (store_local) {
- if (ch >= 'A' && ch <= 'Z')
- dest_module = frame->globals;
- else
- dest_module = frame->locals;
- } else
+ if (store_local)
+ dest_module = frame->locals;
+ else
dest_module = NULL;
llen = (int) list_len(ist, path_list);
@@ -760,25 +779,9 @@
for(i=0; i < param; i++)
return_value = fr_pop;
break;
- case OP_PUSH_LOCAL:
- fr_push(frame->locals);
- break;
- case OP_PUSH_GLOBAL:
- fr_push(frame->globals);
- break;
case OP_PUSH_SELF:
fr_push(frame->self);
break;
- case OP_PUSH_SUPER:
- fr_push(proto_item(ist, frame->self, 0));
- break;
- case OP_PUSH_OUTER: {
- if (!frame->syn_locals) {
- raise_exception(ist, OBJ(INTERPRETER_EXC), "outer not available here");
- break;
- }
- fr_push(frame->syn_locals);
- } break;
case OP_PUSH_CALLER:
if (!frame->dyn_locals) {
raise_exception(ist, OBJ(INTERPRETER_EXC), "caller not available here");
@@ -786,45 +789,18 @@
}
fr_push(frame->dyn_locals);
break;
- case OP_PUSH_DEF_LOCAL_REF:
- fr_push(frame->def_locals);
+ case OP_PUSH_SELF_REF:
+ fr_push(frame->self);
fr_push(fr_data(1));
break;
- case OP_PUSH_DEF_GLOBAL_REF:
- fr_push(frame->def_globals);
- fr_push(fr_data(1));
- break;
case OP_PUSH_LOCAL_REF:
fr_push(frame->locals);
- fr_push(fr_data(1));
+ fr_push(new_local_obj(ist, fr_data(1)));
break;
- case OP_PUSH_GLOBAL_REF:
- fr_push(frame->globals);
- fr_push(fr_data(1));
- break;
- case OP_PUSH_SELF_REF:
- fr_push(frame->self);
- fr_push(fr_data(1));
- break;
- case OP_PUSH_SUPER_REF:
- fr_push(proto_item(ist, frame->self, 0));
- fr_push(fr_data(1));
- break;
- case OP_PUSH_OUTER_REF: {
- obj_p func = frame->func;
- obj_p synloc = frame->syn_locals;
- obj_p sym = fr_data(1);
- while (!synloc || !get_attr(ist, synloc, sym)) {
- if (!func || !(synloc = get_attr(ist, func, SYM(SYN_LOCALS_)))) {
- raise_exception(ist, OBJ(INTERPRETER_EXC), "outer.%s not found", as_str(ist, sym));
- goto outref_brk;
- }
- func = get_attr(ist, func, SYM(SYN_FUNC_));
- }
- fr_push(synloc);
- fr_push(sym);
-outref_brk: break;
- }
+ case OP_PUSH_OUTER_REF:
+ fr_push(frame->locals);
+ fr_push(new_outer_obj(ist, fr_data(1)));
+ break;
case OP_PUSH_CALLER_REF:
if (!frame->dyn_locals) {
raise_exception(ist, OBJ(INTERPRETER_EXC), "caller not available here");
@@ -912,11 +888,7 @@
listlen(fparams_obj) = fparams_len;
set_attr(ist, func, SYM(FPARAMS_), fparams_obj);
}
- set_attr(ist, func, SYM(SYN_SELF_), frame->self);
- set_attr(ist, func, SYM(GLOBALS_), frame->globals);
- set_attr(ist, func, SYM(SYN_LOCALS_), frame->locals);
- if (frame->func)
- set_attr(ist, func, SYM(SYN_FUNC_), frame->func);
+ set_attr(ist, func, SYM(PREV_SCOPE_), frame->locals);
#ifdef DUMP_MODULE_CODE
{
char dump_name[256];
@@ -927,9 +899,9 @@
}
#endif
if (op == OP_GEN) {
- frame_p new_frame = create_frame( ist,
- NULL, frame->self, NULL, NULL,
- frame->dyn_locals, frame->locals, func, NULL );
+ frame_p new_frame = create_frame( ist, frame->self, NULL,
+ frame->dyn_locals, frame->locals,
+ func, NULL );
new_frame->gen_marker = TRUE;
func->data.ptr = new_frame;
switch_proto(ist, func, OBJ(GEN_PROTO));
@@ -1012,9 +984,8 @@
}
state = parse_file_or_string(ist, NULL, pr_strptr(str_obj));
if (!state || !(code = (state->parse_results))) break;
- new_frame = create_frame( ist, NULL, frame->self, frame->globals, frame->syn_locals,
- frame->dyn_locals, frame->locals, NULL, code );
- new_frame->globals = frame->globals;
+ new_frame = create_frame( ist, frame->self, frame->syn_locals, frame->dyn_locals,
+ frame->locals, NULL, code );
new_frame->syn_locals = frame->syn_locals;
new_frame->prev_frame = frame;
frame->next_frame = new_frame;
@@ -1060,18 +1031,17 @@
IF_EXC_BREAK;
fr_push(res);
} else if (has_proto_QUES(ist, func_obj, OBJ(FUNC_PROTO))) {
- obj_p new_locals, syn_self, self;
+ obj_p new_locals, self;
frame_p new_frame;
IF_EXC_BREAK;
if (!func_obj->data.ptr) goto no_func_ptr;
new_locals = NEW_OBJ(NULL);
- syn_self = get_attr(ist, func_obj, SYM(SYN_SELF_)); IF_EXC_BREAK;
if ( !(self = fr_stack[fr_sp+1]) &&
!(self = get_attr(ist, func_obj, SYM(BINDOBJ_))) )
self = frame->self;
IF_EXC_BREAK;
- new_frame = create_frame( ist, syn_self, self, NULL, NULL,
- frame->locals, new_locals, func_obj, NULL );
+ new_frame = create_frame( ist, self, NULL, frame->locals,
+ new_locals, func_obj, NULL );
fr_next = new_frame;
new_frame->prev_frame = frame;
load_frame_params(ist, new_locals, func_obj, param*2, fr_stack+fr_sp+2);
@@ -1095,47 +1065,55 @@
break;
case OP_OBJ: {
int i, num_protos = (int)(intptr_t) fr_data(2);
- obj_p new_obj;
+ obj_p new_obj, key;
fr_sp -= (num_protos+1)*2;
if (num_protos == 0) new_obj = new_object(ist, NULL);
else {
obj_p psym = fr_stack[fr_sp+3];
- obj_p proto = get_attr_in_chain(ist, fr_stack[fr_sp+2], psym, NULL, NULL); IF_EXC_BREAK;
+ obj_p proto = get_item(ist, fr_stack[fr_sp+2], psym); IF_EXC_BREAK;
if (!proto) {
- raise_exception(ist, OBJ(NAME_EXC), "prototype %s not found", symch(ist, psym));
+ raise_exception(ist, OBJ(NAME_EXC), "prototype %s not found", as_str(ist, psym));
goto end_op_obj;
}
new_obj = new_object(ist, proto);
}
for (i=1; i < num_protos; i++) {
obj_p psym = fr_stack[fr_sp+(i+1)*2+1];
- obj_p proto = get_attr_in_chain(ist, fr_stack[fr_sp+(i+1)*2], psym, NULL, NULL);
+ obj_p proto = get_item(ist, fr_stack[fr_sp+(i+1)*2], psym);
if (ist->exception_obj) goto end_op_obj;
if (!proto) {
- raise_exception(ist, OBJ(NAME_EXC), "prototype %s not found", symch(ist, psym));
+ raise_exception(ist, OBJ(NAME_EXC), "prototype %s not found", as_str(ist, psym));
goto end_op_obj;
}
ins_proto(ist, new_obj, proto, 0x7fffffff);
if (ist->exception_obj) goto end_op_obj;
}
- set_attr(ist, fr_stack[fr_sp], fr_stack[fr_sp+1], new_obj); IF_EXC_BREAK;
+ key = fr_stack[fr_sp+1];
+ if (has_proto_QUES(ist, key, OBJ(LOCAL_PROTO))) {
+ key = key->data.ptr;
+ del_unlock(fr_stack[fr_sp+1]);
+ }
+ set_attr(ist, fr_stack[fr_sp], key, new_obj); IF_EXC_BREAK;
del_unlock(new_obj);
fr_push(new_obj);
- } // fall into OP_WITH on purpose
+ } // fall into OP_WITH
case OP_WITH:
fr_sp--;
- switch_frame = create_frame( ist, NULL, frame->self, frame->globals, frame->syn_locals,
- frame->dyn_locals, frame->locals, fr_data(1), NULL );
- switch_frame->def_locals = fr_stack[fr_sp];
+ switch_frame = create_frame( ist, frame->self, frame->locals, frame->dyn_locals,
+ fr_stack[fr_sp], fr_data(1), NULL );
switch_frame->prev_frame = frame;
frame->next_frame = switch_frame;
end_op_obj: break;
case OP_CALL: {
fr_sp -= 3+(2*param);
- if (has_proto_QUES(ist, fr_stack[fr_sp+1], OBJ(SUPER_PROTO))) {
- func_obj = get_attr_in_chain(ist, fr_stack[fr_sp], fr_stack[fr_sp+1]->data.ptr, NULL, frame->syn_self);
+ if (has_proto_QUES(ist, fr_stack[fr_sp+1], OBJ(LOCAL_PROTO))) {
+ func_obj = get_scope_attr(ist, fr_stack[fr_sp], fr_stack[fr_sp+1]->data.ptr, NULL, NULL);
goto got_func;
}
+ if (has_proto_QUES(ist, fr_stack[fr_sp+1], OBJ(OUTER_PROTO))) {
+ func_obj = get_scope_attr(ist, fr_stack[fr_sp], fr_stack[fr_sp+1]->data.ptr, NULL, fr_stack[fr_sp]);
+ goto got_func;
+ }
if (!has_proto_QUES(ist, fr_stack[fr_sp+1], OBJ(SYMBOL_PROTO))) {
raise_exception(ist, OBJ(INTERNAL_EXC), "Indexed function call not supported yet");
break;
@@ -1157,7 +1135,7 @@
raise_exception(ist, OBJ(INTERPRETER_EXC), "reference to non-existant self object");
break;
}
- func_obj = get_attr_in_chain(ist, fr_stack[fr_sp], fr_stack[fr_sp+1], NULL, NULL);
+ func_obj = get_proto_attr(ist, fr_stack[fr_sp], fr_stack[fr_sp+1], NULL, NULL);
got_func:
IF_EXC_BREAK;
if (!func_obj) {
@@ -1188,18 +1166,17 @@
IF_EXC_BREAK;
fr_push(res);
} else if (has_proto_QUES(ist, func_obj, OBJ(FUNC_PROTO))) {
- obj_p new_locals, syn_self, self;
+ obj_p new_locals, self;
frame_p new_frame;
IF_EXC_BREAK;
if (!func_obj->data.ptr) goto no_func_ptr2;
new_locals = NEW_OBJ(NULL);
- syn_self = get_attr(ist, func_obj, SYM(SYN_SELF_)); IF_EXC_BREAK;
if ( !(self = fr_stack[fr_sp+2]) &&
!(self = get_attr(ist, func_obj, SYM(BINDOBJ_))) )
self = fr_stack[fr_sp];
IF_EXC_BREAK;
- new_frame = create_frame( ist, syn_self, self, NULL, NULL,
- frame->locals, new_locals, func_obj, NULL );
+ new_frame = create_frame( ist, self, NULL, frame->locals,
+ new_locals, func_obj, NULL );
fr_next = new_frame;
new_frame->prev_frame = frame;
load_frame_params(ist, new_locals, func_obj, param*2, fr_stack+fr_sp+3);
@@ -1216,7 +1193,7 @@
} else {
obj_p value;
if (fr_stack[fr_sp+1] != SYM(CALL_)) {
- value = get_attr_in_chain(ist, fr_stack[fr_sp],
+ value = get_proto_attr(ist, fr_stack[fr_sp],
fr_stack[fr_sp+1], NULL, NULL);
IF_EXC_BREAK;
if (value) {
@@ -1274,8 +1251,13 @@
symch(ist, fr_data(1)));
break;
}
+ if (!ist->module){
+ raise_exception( ist, OBJ(INTERPRETER_EXC),
+ "No main module set for importing" );
+ break;
+ }
su(i);
- set_attr(ist, frame->globals, fr_data(1), obj);
+ set_attr(ist, ist->module, fr_data(1), obj);
un_su(i);
} break;
case OP_IMPORT_ATTR_AS: {
@@ -1289,8 +1271,13 @@
break;
}
}
+ if (!ist->module){
+ raise_exception( ist, OBJ(INTERPRETER_EXC),
+ "No main module set for importing" );
+ break;
+ }
su(i);
- set_attr(ist, frame->globals, fr_data(param-1), obj);
+ set_attr(ist, ist->module, fr_data(param-1), obj);
un_su(i);
} break;
case OP_PRINT: {
@@ -1412,7 +1399,7 @@
func_obj = func_sym;
self = NEW_OBJ(NULL);
} else {
- func_obj = get_attr_in_chain(ist, self, func_sym, NULL, super_obj); if_exc_return NULL;
+ 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));
@@ -1439,7 +1426,7 @@
return res;
} else if (has_proto_QUES(ist, func_obj, OBJ(FUNC_PROTO))) {
frame_p frame, new_frame;
- obj_p new_locals, syn_self, aself;
+ obj_p new_locals, aself;
if (!ist) {
raise_exception(ist, OBJ(INTERNAL_EXC), "Illegal function call to Prothon function");
if (!func_sym) del_unlock(self);
@@ -1451,14 +1438,13 @@
}
frame = ist->frame;
new_locals = NEW_OBJ(NULL);
- syn_self = get_attr(ist, func_obj, SYM(SYN_SELF_));
if (intrp_exobj) {
if (!func_sym) del_unlock(self);
return 0;
}
if (! (aself = get_attr(ist, func_obj, SYM(BINDOBJ_))) )
aself = self; if_exc_return 0;
- new_frame = create_frame( ist, syn_self, aself, NULL, NULL, NULL,
+ new_frame = create_frame( ist, aself, NULL, NULL,
new_locals, func_obj, NULL );
new_frame->called_from_c = TRUE;
ist->frame->next_frame = new_frame;
@@ -1546,20 +1532,20 @@
#endif
if (framep && *framep) {
frame = *framep;
- new_frame = create_frame( ist, NULL, frame->self, frame->globals,
- frame->syn_locals, frame->dyn_locals, frame->locals, NULL, code );
+ new_frame = create_frame( ist, frame->self, frame->syn_locals, frame->dyn_locals,
+ frame->locals, NULL, code );
pr_free(*framep);
frame = NULL;
} else {
frame = ist->frame;
if (frame)
- new_frame = create_frame( ist, NULL, frame->self, frame->globals,
- frame->syn_locals, frame->dyn_locals, frame->locals, NULL, code );
+ new_frame = create_frame( ist, frame->self, frame->syn_locals, frame->dyn_locals,
+ frame->locals, NULL, code );
else {
obj_p new_globals = NEW_OBJ(NULL);
new_locals = NEW_OBJ(NULL);
- new_frame = create_frame( ist, NULL, new_globals, new_globals,
- new_locals, new_locals, new_locals, NULL, code );
+ new_frame = create_frame( ist, new_globals, new_locals, new_locals,
+ new_locals, NULL, code );
}
}
new_frame->called_from_c = TRUE;
@@ -1586,6 +1572,7 @@
module = get_attr(ist, OBJ(MODULES), module_name);
if (!module)
module = NEW_OBJ(NULL);
+ ist->module = module;
su(i);
set_attr(ist, OBJ(MODULES), module_name, module);
un_su(i);
@@ -1611,8 +1598,7 @@
set_obj_doc(module, full_doc);
frame = ist->frame;
new_locals = NEW_OBJ(NULL);
- set_attr(ist, module, SYM(LOCALS_), new_locals);
- new_frame = create_frame( ist, NULL, module, module, dest_module, dyn_locals, new_locals, NULL, code );
+ new_frame = create_frame( ist, module, dest_module, dyn_locals, new_locals, NULL, code );
new_frame->called_from_c = TRUE;
if (frame) ist->frame->next_frame = new_frame;
new_frame->prev_frame = ist->frame;
@@ -1706,7 +1692,7 @@
isp ist = get_ist(uthread->access);
obj_p func_obj = uthread->func;
frame_p new_frame;
- obj_p new_locals, syn_self, lbl_val_arr[MAX_NUM_PARAMS];
+ obj_p new_locals, lbl_val_arr[MAX_NUM_PARAMS];
int i, parm_cnt = (int) list_len(ist, uthread->params) * 2;
obj_p thread_obj = register_thread(ist, handle);
pr_thread_p thread_p = thread_obj->data.ptr;
@@ -1721,9 +1707,7 @@
lbl_val_arr[i+1] = list_item(ist, uthread->params, i/2);
}
new_locals = NEW_OBJ(NULL);
- set_attr(ist, thread_obj, SYM(LOCALS_), new_locals);
- syn_self = get_attr(ist, func_obj, SYM(SYN_SELF_));
- new_frame = create_frame( ist, syn_self, NULL, thread_obj, NULL, NULL, new_locals, func_obj, NULL );
+ new_frame = create_frame( ist, NULL, NULL, NULL, new_locals, func_obj, NULL );
new_frame->called_from_c = TRUE;
new_frame->prev_frame = NULL;
load_frame_params( ist, new_locals, func_obj, parm_cnt, lbl_val_arr);
@@ -1776,7 +1760,9 @@
fprintf(fout, "%x ", (unsigned)(uintptr_t)frame);
switch (op) {
- case OP_NOP: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_NOP", param, codedata(str, code, op, param, pc));
+ case OP_NOP:
+ pr_assert(param);
+ fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_NOP", param, codedata(str, code, op, param, pc));
break;
case OP_SAVE_TMP: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_SAVE_TMP", param, codedata(str, code, op, param, pc));
break;
@@ -1802,24 +1788,12 @@
break;
case OP_PUSH_SELF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_SELF", param, codedata(str, code, op, param, pc));
break;
- case OP_PUSH_SUPER: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_SUPER", param, codedata(str, code, op, param, pc));
- break;
- case OP_PUSH_OUTER: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_OUTER", param, codedata(str, code, op, param, pc));
- break;
case OP_PUSH_CALLER: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_CALLER", param, codedata(str, code, op, param, pc));
break;
- case OP_PUSH_DEF_LOCAL_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_DEF_LOCAL_REF", param, codedata(str, code, op, param, pc));
- break;
- case OP_PUSH_DEF_GLOBAL_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_DEF_GLOBAL_REF", param, codedata(str, code, op, param, pc));
- break;
case OP_PUSH_LOCAL_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_LOCAL_REF", param, codedata(str, code, op, param, pc));
break;
- case OP_PUSH_GLOBAL_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_GLOBAL_REF", param, codedata(str, code, op, param, pc));
- break;
case OP_PUSH_SELF_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_SELF_REF", param, codedata(str, code, op, param, pc));
break;
- case OP_PUSH_SUPER_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_SUPER_REF", param, codedata(str, code, op, param, pc));
- break;
case OP_PUSH_OUTER_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_OUTER_REF", param, codedata(str, code, op, param, pc));
break;
case OP_PUSH_CALLER_REF: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_PUSH_CALLER_REF", param, codedata(str, code, op, param, pc));
Modified: trunk/src/interp.h
===================================================================
--- trunk/src/interp.h 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/interp.h 2004-05-12 16:52:02 UTC (rev 466)
@@ -81,9 +81,6 @@
obj_p syn_locals;
obj_p dyn_locals;
obj_p locals;
- obj_p globals;
- obj_p def_locals;
- obj_p def_globals;
int pc;
code_p code;
clist_p exc_stack;
@@ -109,9 +106,8 @@
obj_p free_label_list_obj;
} fparam_proc_state_t;
-frame_p create_frame( isp ist, obj_p syn_self, obj_p self, obj_p globals,
- obj_p syn_locals, obj_p dyn_locals, obj_p locals,
- obj_p func_obj, code_p code_in );
+frame_p create_frame( isp ist, obj_p self, obj_p syn_locals, obj_p dyn_locals,
+ obj_p locals, obj_p func_obj, code_p code_in );
void *main_thread(apr_thread_t *handle, void *filename);
void *user_thread(apr_thread_t *handle, void *argv);
Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/object.c 2004-05-12 16:52:02 UTC (rev 466)
@@ -212,7 +212,8 @@
OBJ(HASH_PROTO) = NEW_OBJ(NULL);
OBJ(SLICE_PROTO) = NEW_OBJ(NULL);
- OBJ(SUPER_PROTO) = NEW_OBJ(NULL);
+ OBJ(LOCAL_PROTO) = NEW_OBJ(NULL);
+ OBJ(OUTER_PROTO) = NEW_OBJ(NULL);
OBJ(THREAD_PROTO) = NEW_OBJ(NULL);
OBJ(MUTEX_PROTO) = NEW_OBJ(NULL);
OBJ(ROOT_GLOBALS) = NEW_OBJ(NULL);
@@ -860,11 +861,11 @@
return TRUE;
}
-//********************************* get_attr_in_chain *****************************
+//********************************* get_proto_attr *****************************
// same as get_attr but will look in all protos for key as well
// if proto_pp not null, then will return proto obj that attr was found in
// if super_obj specified, then only objects after super_obj searched
-obj_p get_attr_in_chain(isp ist, obj_p objid, obj_p key, obj_p *proto_pp, obj_p super_obj) {
+obj_p get_proto_attr(isp ist, obj_p objid, obj_p key, obj_p *proto_pp, obj_p super_obj) {
obj_p obj=objid, proto, res = NULL;
int i, j, len;
clist_t *pao_list;
@@ -967,6 +968,26 @@
return NULL;
}
+//********************************* get_scope_attr *****************************
+// same as get_attr but will look in all surrounding syntactical scopes as well
+// if scope_pp not null, then will return scope obj that attr was found in
+// if super_obj specified, then only objects after super_obj after searched
+obj_p get_scope_attr(isp ist, obj_p scope, obj_p key, obj_p *scope_pp, obj_p super_obj) {
+ obj_p res = NULL, last_scope = NULL;
+ while (scope && !res) {
+ if (!super_obj && (res = get_attr(ist, scope, key))) {
+ if (scope_pp) *scope_pp = scope;
+ break;
+ }
+ if (scope == super_obj) super_obj = NULL;
+ last_scope = scope;
+ scope = get_attr(ist, scope, SYM(PREV_SCOPE_));
+ }
+ if (!res && last_scope)
+ return get_proto_attr(ist, last_scope, key, scope_pp, super_obj);
+ return res;
+}
+
//********************************* obj_alloc ***************************
void* obj_malloc(isp ist, obj_p proto, obj_p obj, size_t size) {
if (size <= sizeof(obj_data_t)){
Modified: trunk/src/parser.h
===================================================================
--- trunk/src/parser.h 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/parser.h 2004-05-12 16:52:02 UTC (rev 466)
@@ -152,17 +152,10 @@
code_p cond_exc_to_assert(void* param, code_p cond, code_p exc);
code_p continue_stmt(void* param, obj_p label);
code_p del_ref(void* param, code_p expr);
-code_p local_label_to_attrref(void* param, obj_p label);
-code_p global_label_to_attrref(void* param, obj_p label);
code_p self_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 local_to_obj(void* param);
-code_p global_to_obj(void* param);
code_p self_to_obj(void* param);
-code_p super_to_obj(void* param);
-code_p outer_to_obj(void* param);
code_p caller_to_obj(void* param);
code_p exceptall(void* param);
code_p exec_expr(void* param, code_p expr);
Modified: trunk/src/parser_routines.c
===================================================================
--- trunk/src/parser_routines.c 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/parser_routines.c 2004-05-12 16:52:02 UTC (rev 466)
@@ -393,37 +393,16 @@
}
code_p label_to_attrref(void* param, obj_p label){
code_p p;
- if (*(pr_strptr(label)) >= 'A' && *(pr_strptr(label)) <= 'Z')
- p = new_code(param, 2, 2, 2, OP_PUSH_DEF_GLOBAL_REF);
- else
- p = new_code(param, 2, 2, 2, OP_PUSH_DEF_LOCAL_REF);
+ p = new_code(param, 2, 2, 2, OP_PUSH_LOCAL_REF);
p->code_data[1].data = sym(IST, (pr_strptr(label)));
return debug_retrn(__LINE__, p);
}
-code_p local_label_to_attrref(void* param, obj_p label){
- code_p p;
- p = new_code(param, 2, 2, 2, OP_PUSH_LOCAL_REF);
- p->code_data[1].data = sym(IST, pr_strptr(label));
- return debug_retrn(__LINE__, p);
-}
-code_p global_label_to_attrref(void* param, obj_p label){
- code_p p;
- p = new_code(param, 2, 2, 2, OP_PUSH_GLOBAL_REF);
- p->code_data[1].data = sym(IST, pr_strptr(label));
- return debug_retrn(__LINE__, p);
-}
code_p self_label_to_attrref(void* param, obj_p label){
code_p p;
p = new_code(param, 2, 2, 2, OP_PUSH_SELF_REF);
p->code_data[1].data = sym(IST, pr_strptr(label));
return debug_retrn(__LINE__, p);
}
-code_p super_label_to_attrref(void* param, obj_p label){
- code_p p;
- 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);
-}
code_p outer_label_to_attrref(void* param, obj_p label){
code_p p;
p = new_code(param, 2, 2, 2, OP_PUSH_OUTER_REF);
@@ -721,7 +700,7 @@
code_p res;
int have_lparm = FALSE;
int k=0, len=0, stack_depth=7, max_stack_depth = 7;
- int have_cmp_op = (op >= LT_QUES_ && op <= EQ_QUES_);
+ int have_cmp_op = (op >= LT__QUES && op <= EQ__QUES);
if (lparm->cmp_expr && have_cmp_op) {
lparm->cmp_expr = FALSE;
calc_code(lparm, &len, &stack_depth, &max_stack_depth);
@@ -792,7 +771,7 @@
res->code_data[k++].bytecode.param = -1;
res->code_data[k ].bytecode.opcode = OP_PUSH;
res->code_data[k++].bytecode.param = 3;
- res->code_data[k++].data = SYM(BOOL_QUES_);
+ res->code_data[k++].data = SYM(BOOL__QUES);
res->code_data[k++].data = NULL;
res->code_data[k ].bytecode.opcode = OP_CALL;
res->code_data[k++].bytecode.param = 0;
@@ -813,7 +792,7 @@
void add_skip_code1(code_p body, code_p res, int* k){
res->code_data[(*k) ].bytecode.opcode = OP_PUSH;
res->code_data[(*k)++].bytecode.param = 3;
- res->code_data[(*k)++].data = SYM(BOOL_QUES_);
+ res->code_data[(*k)++].data = SYM(BOOL__QUES);
res->code_data[(*k)++].data = NULL;
res->code_data[(*k) ].bytecode.opcode = OP_CALL;
res->code_data[(*k)++].bytecode.param = 0;
@@ -950,7 +929,7 @@
add_code(ifexpr, res, k);
res->code_data[(*k) ].bytecode.opcode = OP_PUSH;
res->code_data[(*k)++].bytecode.param = 3;
- res->code_data[(*k)++].data = SYM(BOOL_QUES_);
+ res->code_data[(*k)++].data = SYM(BOOL__QUES);
res->code_data[(*k)++].data = NULL;
res->code_data[(*k) ].bytecode.opcode = OP_CALL;
res->code_data[(*k)++].bytecode.param = 0;
@@ -1276,7 +1255,7 @@
add_code(expr, res, &k);
res->code_data[k ].bytecode.opcode = OP_PUSH;
res->code_data[k++].bytecode.param = 3;
- res->code_data[k++].data = SYM(BOOL_QUES_);
+ res->code_data[k++].data = SYM(BOOL__QUES);
res->code_data[k++].data = NULL;
res->code_data[k ].bytecode.opcode = OP_CALL;
res->code_data[k++].bytecode.param = 0;
@@ -1316,7 +1295,7 @@
add_code(cond, res, &k);
res->code_data[k ].bytecode.opcode = OP_PUSH;
res->code_data[k++].bytecode.param = 3;
- res->code_data[k++].data = SYM(BOOL_QUES_);
+ res->code_data[k++].data = SYM(BOOL__QUES);
res->code_data[k++].data = NULL;
res->code_data[k ].bytecode.opcode = OP_CALL;
res->code_data[k++].bytecode.param = 0;
@@ -1536,26 +1515,10 @@
add_to_const_list(param, obj);
return debug_retrn(__LINE__, p);
}
-code_p local_to_obj(void* param){
- code_p p = new_code(param, 1, 1, 1, OP_PUSH_LOCAL);
- return debug_retrn(__LINE__, p);
-}
-code_p global_to_obj(void* param){
- code_p p = new_code(param, 1, 1, 1, OP_PUSH_GLOBAL);
- return debug_retrn(__LINE__, p);
-}
code_p self_to_obj(void* param){
code_p p = new_code(param, 1, 1, 1, OP_PUSH_SELF);
return debug_retrn(__LINE__, p);
}
-code_p super_to_obj(void* param){
- code_p p = new_code(param, 1, 1, 1, OP_PUSH_SUPER);
- return debug_retrn(__LINE__, p);
-}
-code_p outer_to_obj(void* param){
- code_p p = new_code(param, 1, 1, 1, OP_PUSH_OUTER);
- return debug_retrn(__LINE__, p);
-}
code_p caller_to_obj(void* param){
code_p p = new_code(param, 1, 1, 1, OP_PUSH_CALLER);
return debug_retrn(__LINE__, p);
Modified: trunk/src/prothon.y
===================================================================
--- trunk/src/prothon.y 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/prothon.y 2004-05-12 16:52:02 UTC (rev 466)
@@ -115,10 +115,8 @@
%nonassoc FOR
%nonassoc FROM
%nonassoc GEN
-%nonassoc GLOBAL
%nonassoc IF
%nonassoc IMPORT
-%nonassoc LOCAL
%nonassoc OBJ_
%nonassoc OUTER
%nonassoc PASS
@@ -126,7 +124,6 @@
%nonassoc RAISE
%nonassoc RETURN
%nonassoc SELF
-%nonassoc SUPER
%nonassoc TRY
%nonassoc WHILE
%nonassoc WITH
@@ -378,10 +375,7 @@
;
obj_ref:
OBJ_ LABEL { $$ = label_to_attrref(yylex_param, $2); state->defdoc_flag=1; }
- | OBJ_ LOCAL '.' LABEL { $$ = local_label_to_attrref(yylex_param, $4); state->defdoc_flag=1; }
- | OBJ_ GLOBAL '.' LABEL { $$ = global_label_to_attrref(yylex_param, $4);state->defdoc_flag=1; }
| OBJ_ SELF '.' LABEL { $$ = self_label_to_attrref(yylex_param, $4); state->defdoc_flag=1; }
- | OBJ_ SUPER '.' LABEL { $$ = super_label_to_attrref(yylex_param, $4); state->defdoc_flag=1; }
| OBJ_ OUTER '.' LABEL { $$ = outer_label_to_attrref(yylex_param, $4); state->defdoc_flag=1; }
| OBJ_ CALLER '.' LABEL { $$ = caller_label_to_attrref(yylex_param, $4);state->defdoc_flag=1; }
| OBJ_ obj '.' LABEL { $$ = obj_label_to_attrref(yylex_param, $2, $4);state->defdoc_flag=1; }
@@ -400,20 +394,14 @@
;
def_ref:
DEF_ LABEL { $$ = label_to_attrref(yylex_param, $2); state->defdoc_flag=1; }
- | DEF_ LOCAL '.' LABEL { $$ = local_label_to_attrref(yylex_param, $4); state->defdoc_flag=1; }
- | DEF_ GLOBAL '.' LABEL { $$ = global_label_to_attrref(yylex_param, $4);state->defdoc_flag=1; }
| DEF_ SELF '.' LABEL { $$ = self_label_to_attrref(yylex_param, $4); state->defdoc_flag=1; }
- | DEF_ SUPER '.' LABEL { $$ = super_label_to_attrref(yylex_param, $4); state->defdoc_flag=1; }
| DEF_ OUTER '.' LABEL { $$ = outer_label_to_attrref(yylex_param, $4); state->defdoc_flag=1; }
| DEF_ CALLER '.' LABEL { $$ = caller_label_to_attrref(yylex_param, $4);state->defdoc_flag=1; }
| DEF_ obj '.' LABEL { $$ = obj_label_to_attrref(yylex_param, $2, $4);state->defdoc_flag=1; }
;
gen_ref:
GEN LABEL { $$ = label_to_attrref(yylex_param, $2); state->defdoc_flag=1; }
- | GEN LOCAL '.' LABEL { $$ = local_label_to_attrref(yylex_param, $4); state->defdoc_flag=1; }
- | GEN GLOBAL '.' LABEL { $$ = global_label_to_attrref(yylex_param, $4); state->defdoc_flag=1; }
| GEN SELF '.' LABEL { $$ = self_label_to_attrref(yylex_param, $4); state->defdoc_flag=1; }
- | GEN SUPER '.' LABEL { $$ = super_label_to_attrref(yylex_param, $4); state->defdoc_flag=1; }
| GEN OUTER '.' LABEL { $$ = outer_label_to_attrref(yylex_param, $4); state->defdoc_flag=1; }
| GEN CALLER '.' LABEL { $$ = caller_label_to_attrref(yylex_param, $4); state->defdoc_flag=1; }
| GEN obj '.' LABEL { $$ = obj_label_to_attrref(yylex_param, $2, $4);state->defdoc_flag=1; }
@@ -489,8 +477,8 @@
PRINT arg_list { $$ = print_arglist(yylex_param, $2); }
;
is_not_check:
- /* empty string */ { $$ = (void *)(unsigned long)IS_QUES_; }
- | NOT { $$ = (void *)(unsigned long)ISNOT_QUES_; }
+ /* empty string */ { $$ = (void *)(unsigned long)IS__QUES; }
+ | NOT { $$ = (void *)(unsigned long)ISNOT__QUES; }
;
expr:
expr OR expr
@@ -500,34 +488,34 @@
{ $$ = expr_andor_expr(yylex_param, $1, $3, AND_FLAG); }
| expr IN_ expr
- { $$ = binary(yylex_param, $1, IN_QUES_, $3); }
+ { $$ = binary(yylex_param, $1, IN__QUES, $3); }
| expr NOT IN_ expr %prec NOT_IN
- { $$ = binary(yylex_param, $1, NOTIN_QUES_, $4); }
+ { $$ = binary(yylex_param, $1, NOTIN__QUES, $4); }
| expr IS is_not_check expr
{ $$ = binary(yylex_param, $1, (int)(intptr_t)$3, $4); }
| NOT expr
- { $$ = unary(yylex_param, NOT_QUES_, $2); }
+ { $$ = unary(yylex_param, NOT__QUES, $2); }
| expr '<' expr %prec EQ
- { $$ = binary(yylex_param, $1, LT_QUES_, $3); }
+ { $$ = binary(yylex_param, $1, LT__QUES, $3); }
| expr LE expr %prec EQ
- { $$ = binary(yylex_param, $1, LE_QUES_, $3); }
+ { $$ = binary(yylex_param, $1, LE__QUES, $3); }
| expr '>' expr %prec EQ
- { $$ = binary(yylex_param, $1, GT_QUES_ , $3); }
+ { $$ = binary(yylex_param, $1, GT__QUES , $3); }
| expr GE expr %prec EQ
- { $$ = binary(yylex_param, $1, GE_QUES_, $3); }
+ { $$ = binary(yylex_param, $1, GE__QUES, $3); }
| expr NE expr %prec EQ
- { $$ = binary(yylex_param, $1, NE_QUES_, $3); }
+ { $$ = binary(yylex_param, $1, NE__QUES, $3); }
| expr EQ expr %prec EQ
- { $$ = binary(yylex_param, $1, EQ_QUES_, $3); }
+ { $$ = binary(yylex_param, $1, EQ__QUES, $3); }
| expr '|' expr
{ $$ = binary(yylex_param, $1, OR_, $3); }
@@ -554,11 +542,7 @@
| obj
;
obj:
- LOCAL { $$ = local_to_obj(yylex_param); }
- | GLOBAL { $$ = global_to_obj(yylex_param); }
- | SELF { $$ = self_to_obj(yylex_param); }
- | SUPER { $$ = super_to_obj(yylex_param); }
- | OUTER { $$ = outer_to_obj(yylex_param); }
+ SELF { $$ = self_to_obj(yylex_param); }
| CALLER { $$ = caller_to_obj(yylex_param); }
| INT_ { $$ = int_to_obj(yylex_param, $1); }
| LONG_ { $$ = string_to_obj(yylex_param, $1, NEW_LONG); }
@@ -606,10 +590,7 @@
LABEL { $$ = label_to_attrref(yylex_param, $1); }
;
bound_ref:
- LOCAL '.' LABEL { $$ = local_label_to_attrref(yylex_param, $3); }
- | GLOBAL '.' LABEL { $$ = global_label_to_attrref(yylex_param, $3); }
- | SELF '.' LABEL { $$ = self_label_to_attrref(yylex_param, $3); }
- | SUPER '.' LABEL { $$ = super_label_to_attrref(yylex_param, $3); }
+ SELF '.' LABEL { $$ = self_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); }
@@ -1151,17 +1132,14 @@
if (!strcmp(str_ptr,"for")) return FOR;
if (!strcmp(str_ptr,"from")) return FROM;
if (!strcmp(str_ptr,"gen")) return GEN;
- if (!strcmp(str_ptr,"global")) return GLOBAL;
if (!strcmp(str_ptr,"if")) return IF;
if (!strcmp(str_ptr,"import")) return IMPORT;
- if (!strcmp(str_ptr,"local")) return LOCAL;
if (!strcmp(str_ptr,"object")) return OBJ_;
if (!strcmp(str_ptr,"outer")) return OUTER;
if (!strcmp(str_ptr,"pass")) return PASS;
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/src.vcproj
===================================================================
--- trunk/src/src.vcproj 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/src.vcproj 2004-05-12 16:52:02 UTC (rev 466)
@@ -19,14 +19,14 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\apr\apr-util\include"
+ AdditionalIncludeDirectories="..\include;..\apr\apr\include;..\apr\apr-util\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;APR_DECLARE_STATIC;APU_DECLARE_STATIC"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
- WarnAsError="FALSE"
+ WarnAsError="TRUE"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
@@ -36,7 +36,7 @@
AdditionalDependencies="apr.lib aprutil.lib wsock32.lib"
OutputFile="$(OutDir)/prothon.exe"
LinkIncremental="2"
- AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR;C:\prothon\apr\apr-util\LibR"
+ AdditionalLibraryDirectories="..\apr\apr\LibR;..\apr\apr-util\LibR"
IgnoreAllDefaultLibraries="FALSE"
IgnoreDefaultLibraryNames="LIBCMTD.lib"
GenerateDebugInformation="TRUE"
@@ -75,7 +75,7 @@
Optimization="2"
InlineFunctionExpansion="1"
OmitFramePointers="TRUE"
- AdditionalIncludeDirectories="c:\prothon\include;c:\prothon\apr\apr\include;c:\prothon\apr\apr-util\include"
+ AdditionalIncludeDirectories="..\include;..\apr\apr\include;..\apr\apr-util\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;APR_DECLARE_STATIC;APU_DECLARE_STATIC"
StringPooling="TRUE"
ExceptionHandling="FALSE"
@@ -95,7 +95,7 @@
AdditionalDependencies="apr.lib aprutil.lib wsock32.lib"
OutputFile="$(OutDir)/prothon.exe"
LinkIncremental="1"
- AdditionalLibraryDirectories="C:\prothon\apr\apr\LibR;C:\prothon\apr\apr-util\LibR"
+ AdditionalLibraryDirectories="..\apr\apr\LibR;..\apr\apr-util\LibR"
IgnoreDefaultLibraryNames="LIBCMTD.lib"
GenerateDebugInformation="TRUE"
SubSystem="1"
Modified: trunk/src/symbol.c
===================================================================
--- trunk/src/symbol.c 2004-05-11 19:19:20 UTC (rev 465)
+++ trunk/src/symbol.c 2004-05-12 16:52:02 UTC (rev 466)
@@ -62,97 +62,96 @@
// this must match exact order in enum sym_enum_t in bytecodes.h
sym_id_entry_t sym_id_table[SYM_ENUM_COUNT] = {
{ "string_", 0 }, // string_ must be first (==0)
- { "not_QUES_", 0 },
- { "pos_", 0 },
- { "neg_", 0 },
+ { "not__QUES", 0 },
+ { "pos_", 0 },
+ { "neg_", 0 },
{ "invert_", 0 },
- { "in_QUES_", 0 },
- { "notIn_QUES_", 0 },
- { "is_QUES_", 0 },
- { "isNot_QUES_", 0 },
- { "lt_QUES_", 0 },
- { "le_QUES_", 0 },
- { "gt_QUES_", 0 },
- { "ge_QUES_", 0 },
- { "ne_QUES_", 0 },
- { "eq_QUES_", 0 },
+ { "in__QUES", 0 },
+ { "notIn__QUES", 0 },
+ { "is__QUES", 0 },
+ { "isNot__QUES", 0 },
+ { "lt__QUES", 0 },
+ { "le__QUES", 0 },
+ { "gt__QUES", 0 },
+ { "ge__QUES", 0 },
+ { "ne__QUES", 0 },
+ { "eq__QUES", 0 },
{ "cmp", 0 },
{ "or_", 0 },
- { "xor_", 0 },
- { "and_", 0 },
+ { "xor_", 0 },
+ { "and_", 0 },
{ "rShift_", 0 },
{ "lShift_", 0 },
- { "add_", 0 },
- { "sub_", 0 },
- { "mul_", 0 },
- { "div_", 0 },
- { "floorDiv_", 0 },
- { "mod_", 0 },
- { "pow_", 0 },
- { "ior_", 0 },
- { "ixor_", 0 },
- { "iand_", 0 },
- { "irshift_", 0 },
- { "ilshift_", 0 },
- { "iadd_", 0 },
- { "isub_", 0 },
- { "imul_", 0 },
- { "idiv_", 0 },
- { "ifloordiv_", 0 },
- { "imod_", 0 },
- { "ipow_", 0 },
- { "rIn_QUES_", 0 },
- { "rNotIn_QUES_", 0 },
- { "rlt_", 0 },
- { "rle_", 0 },
- { "rgt_", 0 },
- { "rge_", 0 },
- { "rrshift_", 0 },
- { "rlshift_", 0 },
- { "rSub_", 0 },
- { "rDiv_", 0 },
- { "rfloordiv_", 0 },
- { "rmod_", 0 },
- { "rPow_", 0 },
- { "rCmp_", 0 },
- { "init_", 0 },
- { "bool_QUES_", 0 },
+ { "add_", 0 },
+ { "sub_", 0 },
+ { "mul_", 0 },
+ { "div_", 0 },
+ { "floorDiv_", 0 },
+ { "mod_", 0 },
+ { "pow_", 0 },
+ { "ior_", 0 },
+ { "ixor_", 0 },
+ { "iand_", 0 },
+ { "irshift_", 0 },
+ { "ilshift_", 0 },
+ { "iadd_", 0 },
+ { "isub_", 0 },
+ { "imul_", 0 },
+ { "idiv_", 0 },
+ { "ifloordiv_", 0 },
+ { "imod_", 0 },
+ { "ipow_", 0 },
+ { "rIn__QUES", 0 },
+ { "rNotIn__QUES", 0 },
+ { "rlt_", 0 },
+ { "rle_", 0 },
+ { "rgt_", 0 },
+ { "rge_", 0 },
+ { "rrshift_", 0 },
+ { "rlshift_", 0 },
+ { "rSub_", 0 },
+ { "rDiv_", 0 },
+ { "rfloordiv_", 0 },
+ { "rmod_", 0 },
+ { "rPow_", 0 },
+ { "rCmp_", 0 },
+ { "init_", 0 },
+ { "bool__QUES", 0 },
{ "getCmp_", 0 },
- { "cmpvalobj_", 0 },
- { "iter_", 0 },
- { "id_", 0 },
- { "doc_", 0 },
- { "hash_", 0 },
- { "fparams_", 0 },
- { "globals_", 0 },
- { "syn_func_", 0 },
+ { "cmpvalobj_", 0 },
+ { "iter_", 0 },
+ { "id_", 0 },
+ { "doc_", 0 },
+ { "hash_", 0 },
+ { "fparams_", 0 },
+ { "globals_", 0 },
+ { "syn_func_", 0 },
{ "syn_locals_", 0 },
- { "locals_", 0 },
- { "syn_self_", 0 },
{ "rparam", 0 },
{ "param1", 0 },
{ "param2", 0 },
{ "args", 0 },
{ "kwargs", 0 },
- { "copy_", 0 },
- { "covers_QUES_", 0 },
+ { "copy_", 0 },
+ { "covers__QUES", 0 },
{ "coerce_", 0 },
- { "str_", 0 },
+ { "str_", 0 },
{ "next", 0 },
- { "getItem_", 0 },
- { "setItem_", 0 },
- { "delItem_", 0 },
- { "objList_", 0 }, // f3
- { "cDataLen_", 0 },
- { "del_", 0 },
+ { "getItem_", 0 },
+ { "setItem_", 0 },
+ { "delItem_", 0 },
+ { "objList_", 0 }, // f3
+ { "cDataLen_", 0 },
+ { "del_", 0 },
{ "len", 0 },
{ "max", 0 },
{ "min", 0 },
{ "copy", 0 },
- { "toStorProxy_", 0 },
+ { "toStorProxy_", 0 },
{ "fromStorProxy_", 0},
- { "call_", 0},
- { "bindObj_", 0},
+ { "call_", 0},
+ { "bindObj_", 0},
+ { "prev_scope_", 0}
};
typedef struct trie_node_s* trie_p;