rev 584 - in trunk: include/prothon pr/test src

SVN User <[email protected]> Mon, 07 Jun 2004 09:10:20 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: bcollins
Date: 2004-06-07 09:10:17 -0400 (Mon, 07 Jun 2004)
New Revision: 584

Modified:
   trunk/include/prothon/prothon.h
   trunk/pr/test/adict.pr
   trunk/pr/test/finally.pr
   trunk/pr/test/imp.pr
   trunk/pr/test/imp2.pr
   trunk/pr/test/int.pr
   trunk/pr/test/mi2.pr
   trunk/pr/test/plist.pr
   trunk/pr/test/supercall.pr
   trunk/src/Makefile.in
   trunk/src/builtins-attrdict.c
   trunk/src/builtins-int.c
   trunk/src/interp.c
   trunk/src/lock.c
   trunk/src/prothon.y
   trunk/src/symbol.c
Log:
Full-on warning cleanup.


Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h	2004-06-07 08:54:22 UTC (rev 583)
+++ trunk/include/prothon/prothon.h	2004-06-07 13:10:17 UTC (rev 584)
@@ -57,12 +57,12 @@
 
 //**************************** DEBUG DEFINITIONS ******************************
  
-#define CMDLINE_FLAGS
-#define TRACE_PARSER
-#define DUMP_MODULE_CODE
-#define TRACE_INTERPRETER
-#define DUMP_OBJECTS_AT_END
-#define DEBUG_THREADS
+//#define CMDLINE_FLAGS
+//#define TRACE_PARSER
+//#define DUMP_MODULE_CODE
+//#define TRACE_INTERPRETER
+//#define DUMP_OBJECTS_AT_END
+//#define DEBUG_THREADS
 
 //#define DEBUG_MEM_MGR
 //#define PROSIST_DEBUG
@@ -133,8 +133,10 @@
 # define max(a,b) (((a)<(b)) ? (b) : (a))
 #undef exch
 #define exch(a,b) (tmp=a, a=b, b=tmp)
+#ifdef WIN32
 #undef abs
 #define abs(x) ((x) < 0 ? -(x) : (x))
+#endif
 
 // neg key value means entry is deleted
 #define ENTRY_DELETED	-1
@@ -1330,8 +1332,8 @@
 #else
 #define Py_OVERFLOWED(X) ((X) != 0.0 && (errno == ERANGE))
 #endif
-//#define Py_OVERFLOWED(X) ((X) != 0.0 && (errno == ERANGE ||    \
-//					 (X) == Py_HUGE_VAL || \
-//					 (X) == -Py_HUGE_VAL))
+/* #define Py_OVERFLOWED(X) ((X) != 0.0 && (errno == ERANGE ||    \
+					 (X) == Py_HUGE_VAL || \
+					 (X) == -Py_HUGE_VAL)) */
 
 #endif // PROTHON_H

Modified: trunk/pr/test/adict.pr
===================================================================
--- trunk/pr/test/adict.pr	2004-06-07 08:54:22 UTC (rev 583)
+++ trunk/pr/test/adict.pr	2004-06-07 13:10:17 UTC (rev 584)
@@ -1,24 +1,24 @@
-#!/usr/bin/env prothon
-
-def err(n):
-	print "failure number",n
-	Sys.exit(1)
-
-x = [1]
-if Len(x.attrs_) != 0: err(0)
-x.attrs_ = {`a:1, `b:2}
-if x.a != 1 or x.b != 2: err(1)
-x.c = 3
-if x.attrs_[`c] != 3: err(2)
-if x.attrs_['c'] != 3: err(3)
-if Len(x.attrs_) != 3: err(4)
-del x.attrs_['c']
-del x.attrs_[`b]
-if Len(x.attrs_) != 1: err(5)
-if x.attrs_.str_() != "{`a:1}": err(6)
-x.attrs_[`b] = 22
-if x.b != 22: err(7)
-
-print """
-all tests passed
-"""
+#!/usr/bin/env prothon
+
+def err(n):
+	print "failure number",n
+	Sys.exit(1)
+
+x = [1]
+if Len(x.attrs_) != 0: err(0)
+x.attrs_ = {`a:1, `b:2}
+if x.a != 1 or x.b != 2: err(1)
+x.c = 3
+if x.attrs_[`c] != 3: err(2)
+if x.attrs_['c'] != 3: err(3)
+if Len(x.attrs_) != 3: err(4)
+del x.attrs_['c']
+del x.attrs_[`b]
+if Len(x.attrs_) != 1: err(5)
+if x.attrs_.str_() != "{`a:1}": err(6)
+x.attrs_[`b] = 22
+if x.b != 22: err(7)
+
+print """
+all tests passed
+"""


Property changes on: trunk/pr/test/adict.pr
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native


Property changes on: trunk/pr/test/finally.pr
___________________________________________________________________
Name: svn:executable
   + *


Property changes on: trunk/pr/test/imp.pr
___________________________________________________________________
Name: svn:executable
   + *


Property changes on: trunk/pr/test/imp2.pr
___________________________________________________________________
Name: svn:executable
   + *


Property changes on: trunk/pr/test/int.pr
___________________________________________________________________
Name: svn:executable
   + *


Property changes on: trunk/pr/test/mi2.pr
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/pr/test/plist.pr
===================================================================
--- trunk/pr/test/plist.pr	2004-06-07 08:54:22 UTC (rev 583)
+++ trunk/pr/test/plist.pr	2004-06-07 13:10:17 UTC (rev 584)
@@ -1,42 +1,42 @@
-#!/usr/bin/env prothon
-
-def err(n):
-	print "failure number",n
-	Sys.exit(1)
-
-x = Object()
-x2 = x()
-x3 = x2()
-x4 = x3()
-object x5(x4,x3,x2,x): pass
-
-if Len(x5.protos_) != 4: err(-1)
-if x5.protos_[0] is not x4: err(0)
-if x5.protos_[1] is not x3: err(1)
-if x5.protos_[2] is not x2: err(2)
-if x5.protos_[3] is not x:  err(3)
-
-y = Object()
-a=1
-b=2
-c=3
-y.protos_ = [a,b,c]
-if Len(y.protos_) != 3: err(4)
-if y.protos_[0] is not a: err(5)
-if y.protos_[1] is not b: err(6)
-if y.protos_[2] is not c: err(7)
-
-del y.protos_[1]
-if y.protos_ != [1,3]: err(8)
-if 1 not in y.protos_: err(9)
-if 3 not in y.protos_: err(10)
-y.protos_.insert!(1,2)
-if y.protos_ != [1,2,3]: err(11)
-y.protos_.append!(4)
-if y.protos_ != [1,2,3,4]: err(12)
-y.protos_.remove!(1)
-if y.protos_ != [2,3,4]: err(13)
-
-print """
-all tests passed
-"""
+#!/usr/bin/env prothon
+
+def err(n):
+	print "failure number",n
+	Sys.exit(1)
+
+x = Object()
+x2 = x()
+x3 = x2()
+x4 = x3()
+object x5(x4,x3,x2,x): pass
+
+if Len(x5.protos_) != 4: err(-1)
+if x5.protos_[0] is not x4: err(0)
+if x5.protos_[1] is not x3: err(1)
+if x5.protos_[2] is not x2: err(2)
+if x5.protos_[3] is not x:  err(3)
+
+y = Object()
+a=1
+b=2
+c=3
+y.protos_ = [a,b,c]
+if Len(y.protos_) != 3: err(4)
+if y.protos_[0] is not a: err(5)
+if y.protos_[1] is not b: err(6)
+if y.protos_[2] is not c: err(7)
+
+del y.protos_[1]
+if y.protos_ != [1,3]: err(8)
+if 1 not in y.protos_: err(9)
+if 3 not in y.protos_: err(10)
+y.protos_.insert!(1,2)
+if y.protos_ != [1,2,3]: err(11)
+y.protos_.append!(4)
+if y.protos_ != [1,2,3,4]: err(12)
+y.protos_.remove!(1)
+if y.protos_ != [2,3,4]: err(13)
+
+print """
+all tests passed
+"""


Property changes on: trunk/pr/test/plist.pr
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

Modified: trunk/pr/test/supercall.pr
===================================================================
--- trunk/pr/test/supercall.pr	2004-06-07 08:54:22 UTC (rev 583)
+++ trunk/pr/test/supercall.pr	2004-06-07 13:10:17 UTC (rev 584)
@@ -1,16 +1,16 @@
-#!/usr/bin/env prothon
-
-object X:
-    def call_():
-        if self.call_ is super.call_:
-            print "Error: self.call_ is super.call_"
-            Sys.exit(1)
-        return super.call_()
-
-Y = X()
-X()
-Y()
-    
-print """
-test passed
-"""
+#!/usr/bin/env prothon
+
+object X:
+    def call_():
+        if self.call_ is super.call_:
+            print "Error: self.call_ is super.call_"
+            Sys.exit(1)
+        return super.call_()
+
+Y = X()
+X()
+Y()
+    
+print """
+test passed
+"""


Property changes on: trunk/pr/test/supercall.pr
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

Modified: trunk/src/Makefile.in
===================================================================
--- trunk/src/Makefile.in	2004-06-07 08:54:22 UTC (rev 583)
+++ trunk/src/Makefile.in	2004-06-07 13:10:17 UTC (rev 584)
@@ -11,7 +11,8 @@
 
 BUILTIN_MOD_OBJS = builtins-core.o builtins-dict.o builtins-int.o \
 	builtins-list.o builtins-string.o builtins-tuple.o \
-	builtins-float.o builtins-thread.o
+	builtins-float.o builtins-thread.o builtins-attrdict.o \
+	builtins-protolist.o
 
 OBJS = main.o $(BUILTIN_MOD_OBJS) object.o argproc.o clist.o lock.o \
 	memory_mgr.o parser.o prmalloc.o sys.o interp.o parser_routines.o \

Modified: trunk/src/builtins-attrdict.c
===================================================================
--- trunk/src/builtins-attrdict.c	2004-06-07 08:54:22 UTC (rev 583)
+++ trunk/src/builtins-attrdict.c	2004-06-07 13:10:17 UTC (rev 584)
@@ -197,7 +197,7 @@
 }
 
 DEF(AttrDict, getItem_, FORM_RPARAM) {
-	obj_p res, index;
+	obj_p res = NULL, index;
 	BIN_CONTENT_CHK(AttrDict);
 	if (list_len(ist, parms[1]) > 1) {
 		raise_exception(ist, OBJ(INTERPRETER_EXC), "slice not allowed in attr dictionary indexing");	
Modified: trunk/src/builtins-int.c
===================================================================
--- trunk/src/builtins-int.c	2004-06-07 08:54:22 UTC (rev 583)
+++ trunk/src/builtins-int.c	2004-06-07 13:10:17 UTC (rev 584)
@@ -55,6 +55,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <math.h>
+#include <ctype.h>
 
 #include <apr_strings.h>
 
@@ -74,12 +75,21 @@
  */
 #define KARATSUBA_CUTOFF 35
 
+#ifndef INT_MAX
 #define INT_MAX       2147483647    /* maximum (signed) int value */
+#endif
 #define Py_IS_INFINITY(X) ((X) && (X)*0.5 == (X))
 
+
+#ifdef WIN32
 #define MAX32	0x000000003fffffff
+#define MAX64   0x3fffffffffffffff
+#else
+#define MAX32   0x000000003fffffffLL
+#define MAX64   0x3fffffffffffffffLL
+#endif
+
 #define MIN32	-MAX32
-#define MAX64	0x3fffffffffffffff
 #define MIN64	-MAX64
 
 typedef u32_t wdigit;
@@ -104,8 +114,8 @@
 
 #define SIGCHECK(x)			if (0) x
 #define Py_CHARMASK(c)		((c) & 0xff)
-#define Py_INCREF
-#define Py_XDECREF
+#define Py_INCREF(x)		do {} while (0)
+#define Py_XDECREF(x)		do {} while (0)
 
 /* Forward */
 static long_p long_normalize(long_p);
@@ -852,7 +862,6 @@
 /* forward */
 static long_p x_divrem
 	(long_p, long_p, long_p *);
-static long_p long_pos(long_p);
 static int long_divrem(long_p, long_p,
 	long_p *, long_p *);
 
@@ -1574,60 +1583,6 @@
 	return (long_p) div;
 }
 
-static long_p long_classic_div(long_p v, long_p w)
-{
-	long_p a, b, div, mod;
-
-	CONVERT_BINOP(v, w, &a, &b);
-
-	if (l_divmod(a, b, &div, &mod) < 0)
-		div = NULL;
-	else
-		pr_free(mod);
-
-	pr_free(a);
-	pr_free(b);
-	return (long_p) div;
-}
-
-static double long_true_divide(long_p v, long_p w)
-{
-	long_p a, b;
-	double ad, bd;
-	int aexp, bexp;
-
-	CONVERT_BINOP(v, w, &a, &b);
-	ad = _PyLong_AsScaledDouble((long_p)a, &aexp);
-	bd = _PyLong_AsScaledDouble((long_p)b, &bexp);
-	pr_free(a);
-	pr_free(b);
-
-	if (bd == 0.0) {
-		raise_exception(ist, OBJ(DIVIDEZERO_EXC),
-			                 "long division or modulo by zero");
-		return 0.0;
-	}
-
-	/* True value is very close to ad/bd * 2**(SHIFT*(aexp-bexp)) */
-	ad /= bd;	/* overflow/underflow impossible here */
-	aexp -= bexp;
-	if (aexp > INT_MAX / SHIFT)
-		goto overflow;
-	else if (aexp < -(INT_MAX / SHIFT))
-		return 0.0;	/* underflow to 0 */
-	errno = 0;
-	ad = ldexp(ad, aexp * SHIFT);
-	if (Py_OVERFLOWED(ad)) /* ignore underflow to 0.0 */
-		goto overflow;
-	return ad;
-
-overflow:
-	raise_exception(ist, OBJ(OVERFLOW_EXC),
-		                 "integer too large for a float");
-	return 0.0;
-
-}
-
 static long_p long_mod(long_p v, long_p w)
 {
 	long_p a, b, div, mod;

Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c	2004-06-07 08:54:22 UTC (rev 583)
+++ trunk/src/interp.c	2004-06-07 13:10:17 UTC (rev 584)
@@ -117,7 +117,7 @@
 	if (func_obj) {
 		obj_p name_obj;
 		frame->func = func_obj;
-		if (name_obj = get_attr(ist, func_obj, SYM(NAME_)))
+		if ((name_obj = get_attr(ist, func_obj, SYM(NAME_))))
 			frame->func_name = as_str(ist, name_obj);
 	}
 	frame->self				  = self;
@@ -816,7 +816,7 @@
 
 //******************************** exec_loop **********************************
 obj_p exec_loop(isp ist){
-	obj_p  func_obj, temp = NULL;
+	obj_p  func_obj;
 	opcode_t op;
 	int i, param;
 	frame_p switch_frame = NULL, free_frame = NULL, frame = ist->frame;

Modified: trunk/src/lock.c
===================================================================
--- trunk/src/lock.c	2004-06-07 08:54:22 UTC (rev 583)
+++ trunk/src/lock.c	2004-06-07 13:10:17 UTC (rev 584)
@@ -290,4 +290,4 @@
 	res = obj->del_locked;
 	free_wrlock(obj);
 	return res;
-}
\ No newline at end of file
+}

Modified: trunk/src/prothon.y
===================================================================
--- trunk/src/prothon.y	2004-06-07 08:54:22 UTC (rev 583)
+++ trunk/src/prothon.y	2004-06-07 13:10:17 UTC (rev 584)
@@ -1196,7 +1196,7 @@
 					add_string(c, &str_ptr, &str_index, &cur_size);
 				if (c == 'x' || c == 'X')
 					hex_flag = 1;
-				if (imag_flag = (c == 'j' || c == 'J'))
+				if ((imag_flag = (c == 'j' || c == 'J')))
 					break;
 				if (c != '0' && c != 'x' && c != 'X')
 					nonzero_flag = 1;

Modified: trunk/src/symbol.c
===================================================================
--- trunk/src/symbol.c	2004-06-07 08:54:22 UTC (rev 583)
+++ trunk/src/symbol.c	2004-06-07 13:10:17 UTC (rev 584)
@@ -233,13 +233,13 @@
 	if (!strcmp(s+len-5, "_BANG")) strcpy(s+len-5, "!");
 	if (!strcmp(s+len-5, "_QUES")) strcpy(s+len-5, "?");
 	if (!*s) goto bad_sym;
-	if (! ( *s >= 'a' && *s <= 'z' || 
-		    *s >= 'A' && *s <= 'Z' || *s == '_' ) ) goto bad_sym;
+	if (! ( (*s >= 'a' && *s <= 'z') || 
+		    (*s >= 'A' && *s <= 'Z') || *s == '_' ) ) goto bad_sym;
 	for (p=s+1; *p; p++) {
-		if (! ( *p >= 'a' && *p <= 'z' || 
-				*p >= 'A' && *p <= 'Z' || 
-				*p >= '0' && *p <= '9' || 
-				*p == '_' || *p == '!' || *p == '?' ) ) goto bad_sym;
+		if (! ( (*p >= 'a' && *p <= 'z') || 
+				(*p >= 'A' && *p <= 'Z') || 
+				(*p >= '0' && *p <= '9') || 
+				(*p == '_' || *p == '!') || *p == '?' ) ) goto bad_sym;
 		if ((*p == '!' || *p == '?') && *(p+1)) goto bad_sym;
 	}
 	goto good_sym;