rev 642 - in trunk: . pr/test src

SVN User <[email protected]> Sat, 19 Jun 2004 01:37:26 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-06-19 01:37:24 -0400 (Sat, 19 Jun 2004)
New Revision: 642

Modified:
   trunk/STATUS.txt
   trunk/pr/test/test.pr
   trunk/src/builtins-file.c
   trunk/src/parser_routines.c
Log:
changed += type operators to always do "= a + b" type operations

Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt	2004-06-19 04:49:48 UTC (rev 641)
+++ trunk/STATUS.txt	2004-06-19 05:37:24 UTC (rev 642)
@@ -1,23 +1,19 @@
 
 ----------------------- TO-DO (highest priority first) ------------------------
 
---- support any object that supports file methods in stdxxx (duck std)
-		http://www.prothon.org/pipermail/prothon-user/2004-June/001769.html	
-
---- += --> = a + b,  +! --> .append!()
-
---- OSThread, Thread, and Gate
-
 --- Python regrets from Paul and print proposal
 	http://www.prothon.org/pipermail/prothon-user/2004-June/001970.html
 	http://www.prothon.org/pipermail/prothon-user/2004-June/001991.html
+--- += --> = a + b,  +! --> .append!()  -!  --> remove!()   *!  --> mul_!()
 --- pretty print
 	http://www.prothon.org/pipermail/prothon-user/2004-June/002112.html
 
---- implement 1xc3fe ?
-
 --- evaluate default expressions on every function call
 
+--- OSThread, Thread, and Gate
+--- lock keyword?
+
+--- implement 1xc3fe ?
 --- implement taint attribute on strings, unTaint() method, respect in .fmt, eval, exec
 
 --- unicode module - codecs
@@ -30,6 +26,7 @@
 --- add \u0000 \U00000000 and \N{name} esc sequences
 
 --- add Object.data_ (builtins-databytes.c)
+--- Bytes methods?  copy struct module?
 
 --- allow tracebacks in the constructors to exception objects or raise command
 --- Traceback objects (stack trace of an exception), exceptions should show function names
@@ -41,16 +38,17 @@
 --- GNU message catalog _"abc" strings
 --- change all strings to resource file
 
+--- Add properties methods: get_,  set_, delete_
+
+--- getAttr(name), setAttr(name, value), delAttr(name)
+--- add conditional expression "if C then x else y"
+
 --- replace <NULL>, <objptr:1>, and <objptr:2> with noDefault_, argList_, and kwDict_ 
 
 --- support list and dictionary object params directly in string.fmt() ???
 
 --- add resolution order combining prototypes and scope chains
 
---- Add properties methods: get_,  set_, delete_
-
---- getAttr(name), setAttr(name, value), delAttr(name)
-
 --- import (string variable)
 
 --- support long ints & Bytes in dbm & prosist
@@ -61,8 +59,6 @@
 
 --- allow strings to compare with symbols
 
---- add conditional expression "if C then x else y"
-
 --- Auto-documenter app
 --- add static checking like interfaces to doc tool
 

Modified: trunk/pr/test/test.pr
===================================================================
--- trunk/pr/test/test.pr	2004-06-19 04:49:48 UTC (rev 641)
+++ trunk/pr/test/test.pr	2004-06-19 05:37:24 UTC (rev 642)
@@ -1,44 +1,17 @@
 #!/usr/bin/env prothon
 
-f = TempTextFile()
-for i in 5:
-	f.write("line "+i+'\n')
-f.writeLines( ['line 5\n', 'line 6\n','line 7\n','line 8\n','line 9\n',])
-f.close()
+i=0
+print i
+i += 1
+print i
+i *= 2
+print i
+i **=3
+print i
+i //= 2
+print i
 
-f.open()
-for line in f:
-	print line
+a = 'a'
+a += 'bc'
+print a
 
-ref =  ['line 0\n','line 1\n','line 2\n','line 3\n','line 4\n',]
-ref += ['line 5\n','line 6\n','line 7\n','line 8\n','line 9\n',]
-
-f.open()
-x = f.read()
-print x
-if (x != ''.join(ref)): 
-	print "test failed: x != f"
-	sys.exit(1)
-
-f.seek(7)
-x = f.read(7)
-print x
-if (x != 'line 1\n'): 
-	print "test failed: x != 'line 1'"
-	sys.exit(1)
-
-f.seek(21)
-x = f.read(14)
-print x
-if (x != 'line 3\nline 4\n'): 
-	print "test failed: x != 'line 3line 4'"
-	sys.exit(1)
-
-x = f.readLines()
-ref = ['line 5\n','line 6\n','line 7\n','line 8\n','line 9\n',]
-print x
-if (''.join(x) != ''.join(ref)): 
-	print "test failed: x != 'line 5','line 6','line 7','line 8','line 9'"
-	sys.exit(1)
-
-print "\nall tests passed"

Modified: trunk/src/builtins-file.c
===================================================================
--- trunk/src/builtins-file.c	2004-06-19 04:49:48 UTC (rev 641)
+++ trunk/src/builtins-file.c	2004-06-19 05:37:24 UTC (rev 642)
@@ -1169,10 +1169,6 @@
 
 DEF(File, setStdOut, FORM_RPARAM) {
 	int i;
-	if (!has_proto(ist, parms[1], File_OBJ)) {
-		raise_exception(ist, OBJ(TYPE_EXC), "stdout can only be assigned to a file object");
-		return NULL;
-	}
 	su(i);  read_unlock(ist, self);
 	set_attr(ist, self, sym(ist, "stdout"), parms[1]);
 	un_su(i); read_lock(ist, self);
Modified: trunk/src/parser_routines.c
===================================================================
--- trunk/src/parser_routines.c	2004-06-19 04:49:48 UTC (rev 641)
+++ trunk/src/parser_routines.c	2004-06-19 05:37:24 UTC (rev 642)
@@ -1181,69 +1181,30 @@
 }
 code_p ref_expr_to_ass_op(void* param, code_p ref, code_p rparm, int iop, int op){
 	code *res;
-	int len=0, stack_depth=0, max_stack_depth = 0;
-	int k=0, end_icall_loc, end_exc_loc, end_loc;
+	int k=0, len=0, stack_depth=0, max_stack_depth = 0;
+	calc_code(ref, &len, &stack_depth, &max_stack_depth); 
+	len += 5;
 	calc_code(rparm, &len, &stack_depth, &max_stack_depth); 
-	len += 1;
+	len++;
 	calc_code(ref, &len, &stack_depth, &max_stack_depth); 
-	len += 9;
-	end_icall_loc = len;
-	len += 4;
-	calc_code(ref, &len, &stack_depth, &max_stack_depth); 
-	len += 7;
-	calc_code(ref, &len, &stack_depth, &max_stack_depth);
 	len += 2;
-	end_exc_loc = len;
-	len++;
-	end_loc = len;
 	res = new_code(param, len, stack_depth, max_stack_depth, 0);
-	add_code(rparm, res, &k);
-	res->code_data[k  ].bytecode.opcode = OP_TRYEXCEPT;
-	res->code_data[k  ].bytecode.param  = end_icall_loc - k;
-	k++;
 	add_code_no_free(ref, res, &k);
 	res->code_data[k++].bytecode.opcode = OP_DEREF;
 	res->code_data[k  ].bytecode.opcode = OP_PUSH;
 	res->code_data[k++].bytecode.param  = 4;
-	res->code_data[k++].data = sym_id_table[iop].id;
-	res->code_data[k++].data = NULL;
-	res->code_data[k++].data = PARAM_NORMAL;
-	res->code_data[k  ].bytecode.opcode = OP_DUPLICATE;
-	res->code_data[k++].bytecode.param  = -5;
-	res->code_data[k  ].bytecode.opcode = OP_CALL;
-	res->code_data[k++].bytecode.param  = 1;
-	res->code_data[k  ].bytecode.opcode = OP_POP;
-	res->code_data[k++].bytecode.param  = 2;
-	res->code_data[k  ].bytecode.opcode = OP_BR;
-	res->code_data[k  ].bytecode.param  = end_loc - k;
-	k++;
-	pr_assert(end_icall_loc = k);
-	res->code_data[k  ].bytecode.opcode = OP_PUSH;
-	res->code_data[k++].bytecode.param  = 3;
-	res->code_data[k++].data = OBJ(FUNCNOTFOUND_EXC);
-	res->code_data[k++].data = NULL;
-	res->code_data[k  ].bytecode.opcode = OP_EXCEPT;
-	res->code_data[k  ].bytecode.param  = end_exc_loc - k;
-	k++;
-	add_code_no_free(ref, res, &k);
-	res->code_data[k++].bytecode.opcode = OP_DEREF;
-	res->code_data[k  ].bytecode.opcode = OP_PUSH;
-	res->code_data[k++].bytecode.param  = 4;
 	res->code_data[k++].data = sym_id_table[op].id;
 	res->code_data[k++].data = NULL;
 	res->code_data[k++].data = PARAM_NORMAL;
-	res->code_data[k  ].bytecode.opcode = OP_DUPLICATE;
-	res->code_data[k++].bytecode.param  = -5;
+	add_code(rparm, res, &k);
 	res->code_data[k  ].bytecode.opcode = OP_CALL;
 	res->code_data[k++].bytecode.param  = 1;
 	add_code(ref, res, &k);
 	res->code_data[k  ].bytecode.opcode = OP_ASSIGN;
 	res->code_data[k++].bytecode.param  = 1;
 	res->code_data[k  ].bytecode.opcode = OP_POP;
-	res->code_data[k++].bytecode.param  = 2;
-	pr_assert(end_exc_loc = k);
-	res->code_data[k++].bytecode.opcode = OP_RERAISE;
-	pr_assert(end_loc = k);
+	res->code_data[k++].bytecode.param  = 1;
+	pr_assert(len = k);
 	res->stack_depth = 0;
 	return debug_retrn(__LINE__, res);
 }