rev 753 - in trunk: . include/prothon src

SVN User <[email protected]> Sun, 18 Jul 2004 16:24:02 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-07-18 16:23:58 -0400 (Sun, 18 Jul 2004)
New Revision: 753

Modified:
   trunk/STATUS.txt
   trunk/include/prothon/prothon.h
   trunk/include/prothon/prothon_dll.h
   trunk/src/builtins-core.c
   trunk/src/bytecodes.h
   trunk/src/interp.c
   trunk/src/parser.h
   trunk/src/parser_routines.c
   trunk/src/prothon.y
   trunk/src/symbol.c
Log:
removed function-as-command

Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt	2004-07-18 20:08:18 UTC (rev 752)
+++ trunk/STATUS.txt	2004-07-18 20:23:58 UTC (rev 753)
@@ -8,7 +8,6 @@
 1o777777
 O>> "{0:#X}".fmt(-15643650786985697674865478654765)
 
---- remove function-as-command
 --- "import as" broken
 --- bug: prints ... after 15 items in a list
 

Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h	2004-07-18 20:08:18 UTC (rev 752)
+++ trunk/include/prothon/prothon.h	2004-07-18 20:23:58 UTC (rev 753)
@@ -376,7 +376,6 @@
 	STOP_ITERATION_EXC,	//  
 	LOCK_EXC,			//  
 	PERMISSION_EXC,		//  
-	COMMAND_EXC,		//  
  
 // constants
 	ZERO_INT,			//  
@@ -501,7 +500,6 @@
 	NAME_,
 	ATTRS_,
 	PROTOS_,
-	COMMAND_,
 	NOTIFYCALLBACK_,
 	GET_,
 	SET_,

Modified: trunk/include/prothon/prothon_dll.h
===================================================================
--- trunk/include/prothon/prothon_dll.h	2004-07-18 20:08:18 UTC (rev 752)
+++ trunk/include/prothon/prothon_dll.h	2004-07-18 20:23:58 UTC (rev 753)
@@ -281,8 +281,6 @@
 	name##__sym##init();			\
 	check_exceptions(ist);
 
-#define MARK_AS_COMMAND set_attr(ist, _ncfo_, SYM(COMMAND_), OBJ(PR_TRUE));
-
 #define MODULE_SET_DOC(name, docstr)					\
 	set_obj_doc(name##_OBJ, #name ": " docstr);	\
 	check_exceptions(ist);

Modified: trunk/src/builtins-core.c
===================================================================
--- trunk/src/builtins-core.c	2004-07-18 20:08:18 UTC (rev 752)
+++ trunk/src/builtins-core.c	2004-07-18 20:23:58 UTC (rev 753)
@@ -586,7 +586,6 @@
 EXCEPTION_DECLARE(Exception_OBJ, STOP_ITERATION_EXC,  StopIteration,     "Stop iteration (not an error)");
 EXCEPTION_DECLARE(Exception_OBJ, LOCK_EXC,            LockError,         "Locking Error");
 EXCEPTION_DECLARE(Exception_OBJ, PERMISSION_EXC,      PermissionError,   "Permission Error");
-EXCEPTION_DECLARE(Exception_OBJ, COMMAND_EXC,         CommandError,      "Invalid Command");
 }
 
 DEF(Exception, init_,  FORM_STAR_PARAM) {
@@ -1321,7 +1320,7 @@
 	MODULE_ADD_SYM(Object, toStorProxy_);
 	MODULE_ADD_SYM(Object, fromStorProxy_);
 	MODULE_ADD_SYM(Object, dbgPrt);
-	MODULE_ADD_SYM(Object, print);  MARK_AS_COMMAND;
+	MODULE_ADD_SYM(Object, print);
 
 
 	MODULE_SUB_INIT(Symbol);

Modified: trunk/src/bytecodes.h
===================================================================
--- trunk/src/bytecodes.h	2004-07-18 20:08:18 UTC (rev 752)
+++ trunk/src/bytecodes.h	2004-07-18 20:23:58 UTC (rev 753)
@@ -235,19 +235,6 @@
 // |opcode|(char*) label|
 OP_CONTINUE,
 
-// CMDCALL(func_obj, params)
-// (almost same as OP_OBJCALL)
-// call function as a command, with unbound function object, bind target, & params on stack
-// use locals container for self
-// params are in pairs of optional-label/value
-// pop all and leave result on stack
-// if bind-tgt is NULL, use current self as bind-tgt
-// symbol is provided for error message
-// stack: func-object,bind-tgt,label,value,label,value,... -> result
-// param: num param pairs on stack
-// |opcode|symbol|
-OP_CMDCALL,
-
 // HDR_PRT (hdr string)
 // print hdr string and value on top of stack, leave value on stack
 // stack:  value -> value

Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c	2004-07-18 20:08:18 UTC (rev 752)
+++ trunk/src/interp.c	2004-07-18 20:23:58 UTC (rev 753)
@@ -879,7 +879,7 @@
 	int have_exstk, exc_try_loc = 0, exc_exc_loc = 0, return_flag = FALSE;
 	int exc_final=0, exc_final_return=0; 
 	frame_p exc_free_frame = NULL, exc_switch_frame = NULL;
-	int stack_lim = frame->code->max_stack_depth, cmd_flag;
+	int stack_lim = frame->code->max_stack_depth;
 	obj_p exc_waiting=NULL, return_value = 0;
 
 #ifdef DUMP_MODULE_CODE
@@ -1278,12 +1278,7 @@
 				IF_EXC_BREAK;
 				fr_push(bound_meth);
 			}	break;
-			case OP_CMDCALL:
-				cmd_flag = 1;
-				goto got_cmd_flag;
 			case OP_OBJCALL: {
-				cmd_flag = 0;
-got_cmd_flag:
 				if (frame->fparam_proc_state_idx >= 0) {
 					clist_item( frame->fparam_proc_state.lbl_val_list,
 						       (frame->fparam_proc_state_idx*2)+1 ) = fr_pop;
@@ -1294,15 +1289,6 @@
 					fr_push(NEW_STRING("..."));
 					goto break_loc;
 				}
-				if (cmd_flag && !get_attr(ist, func_obj, SYM(COMMAND_))) {
-					if (param == 0) {
-						fr_sp++;
-						goto break_loc;
-					}
-					raise_exception( ist, OBJ(COMMAND_EXC), "Unknown: %s", 
-						                            symch(ist, fr_data(1)) );
-					break;
-				}
 				if (func_obj->body->data_type == DATA_TYPE_EXTPTR) {
 					obj_p res, self;
 					clist_p plist;
@@ -2318,8 +2304,6 @@
 		break;
 	case OP_OBJCALL: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_OBJCALL", param, codedata(str, code, op, param, pc));
 		break;
-	case OP_CMDCALL: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_CMDCALL", param, codedata(str, code, op, param, pc));
-		break;
 	case OP_CALL: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_CALL", param, codedata(str, code, op, param, pc));
 		break;
 	case OP_OBJBIND: fprintf(fout,"%4d %20s(%4d) %s", pc, "OP_OBJBIND", param, codedata(str, code, op, param, pc));

Modified: trunk/src/parser.h
===================================================================
--- trunk/src/parser.h	2004-07-18 20:08:18 UTC (rev 752)
+++ trunk/src/parser.h	2004-07-18 20:23:58 UTC (rev 753)
@@ -203,7 +203,7 @@
 code_p bound_bind_params(void* param, code_p attr_ref, code_p obj);
 code_p unbound_bind_params(void* param, code_p attr_ref, code_p obj);
 code_p bound_func_params(void* param, code_p attr_ref, clist_p parms);
-code_p unbound_func_params(void* param, code_p attr_ref, clist_p parms, int cmd_flag);
+code_p unbound_func_params(void* param, code_p attr_ref, clist_p parms);
 code_p bound_bind_func_params(void* param, code_p attr_ref, code_p obj, clist_p parms);
 code_p unbound_bind_func_params(void* param, code_p attr_ref, code_p obj, clist_p parms);
 code_p sparms_to_slice(void* param, code_p p1, code_p p2, code_p p3, int parm_cnt);

Modified: trunk/src/parser_routines.c
===================================================================
--- trunk/src/parser_routines.c	2004-07-18 20:08:18 UTC (rev 752)
+++ trunk/src/parser_routines.c	2004-07-18 20:23:58 UTC (rev 753)
@@ -584,7 +584,7 @@
 	pr_assert(k==res->len);
 	return debug_retrn(IST, __LINE__, res);
 }
-code_p unbound_func_params(void* param, code_p attr_ref, clist_p parms, int cmd_flag) {
+code_p unbound_func_params(void* param, code_p attr_ref, clist_p parms) {
 	code_p res, nul = push_null(param);
 	int i, k=0, len = 0, stack_depth = 0, max_stack_depth = 0;
 	int llen = clist_len(parms);
@@ -592,20 +592,14 @@
 	calc_code(nul, &len, &stack_depth, &max_stack_depth);
 	for(i=0; i < llen; i++)
 		calc_code(clist_item(parms,i), &len, &stack_depth, &max_stack_depth);
-	res = new_code(param, len+2+cmd_flag, stack_depth, max_stack_depth, 0);
+	res = new_code(param, len+2, stack_depth, max_stack_depth, 0);
 	add_code(attr_ref, res, &k);
 	res->code_data[k++].bytecode.opcode = OP_DEREF;
 	add_code(nul, res, &k);
 	for(i=0; i < llen; i++)
-		add_code(clist_item(parms,i), res, &k);
-	if (cmd_flag == 1) {
-		res->code_data[k  ].bytecode.opcode = OP_CMDCALL;
-		res->code_data[k++].bytecode.param  = clist_len(parms);
-		res->code_data[k++].data = attr_ref->code_data[1].data;
-	} else {
-		res->code_data[k  ].bytecode.opcode = OP_OBJCALL;
-		res->code_data[k++].bytecode.param  = clist_len(parms);
-	}
+	add_code(clist_item(parms,i), res, &k);
+	res->code_data[k  ].bytecode.opcode = OP_OBJCALL;
+	res->code_data[k++].bytecode.param  = clist_len(parms);
 	res->stack_depth -= 2+(2*llen);
 	pr_assert(k==res->len);
 	return debug_retrn(IST, __LINE__, res);

Modified: trunk/src/prothon.y
===================================================================
--- trunk/src/prothon.y	2004-07-18 20:08:18 UTC (rev 752)
+++ trunk/src/prothon.y	2004-07-18 20:23:58 UTC (rev 753)
@@ -245,7 +245,7 @@
 			else slice slice_param formal_param is_not_check
 			function_param break_statement return_statement
 			yield_statement with_statement continue_statement
-			del_statement exec_statement command_statement 
+			del_statement exec_statement 
 			raise_statement prop_statement obj_statement				
 					
 /* Grammar */
@@ -283,7 +283,7 @@
 		ass_shr_statement    | ass_shl_statement | ass_exp_statement  |
 		break_statement      | continue_statement| del_statement      |
    		exec_statement	     | raise_statement   | return_statement   |
-   	    yield_statement      | command_statement | expr               |
+   	    yield_statement      | expr              |
    	    PASS														{ $$ = none(yylex_param); }
 	;
 if_statement: 
@@ -561,7 +561,7 @@
 	| 	bound_ref '{' obj_or_empty '}' '(' func_params ')'  		{ $$ = bound_bind_func_params(yylex_param, $1, $3, $6); }
 	| 	unbound_ref '{' obj_or_empty '}' '(' func_params ')'  		{ $$ = unbound_bind_func_params(yylex_param, $1, $3, $6); }
 	| 	bound_ref '(' func_params ')'  								{ $$ = bound_func_params(yylex_param, $1, $3); }
-	| 	unbound_ref '(' func_params ')'  							{ $$ = unbound_func_params(yylex_param, $1, $3, 0); }
+	| 	unbound_ref '(' func_params ')'  							{ $$ = unbound_func_params(yylex_param, $1, $3); }
 	;
 obj_or_empty:
 		/* empty string */											{ $$ = push_null(yylex_param); }
@@ -658,9 +658,6 @@
 		expr														{ $$ = new_list(yylex_param, $1); }
 	|	list_params2 ',' expr										{ $$ = append_list(yylex_param, $1, $3); }
 	;
-command_statement:
-		LABEL func_params                                           { $$ = unbound_func_params(yylex_param, label_to_attrref(yylex_param, $1), $2, CMD_FLAG); }
-	;
 %%
 
 // **************************************************************************************************

Modified: trunk/src/symbol.c
===================================================================
--- trunk/src/symbol.c	2004-07-18 20:08:18 UTC (rev 752)
+++ trunk/src/symbol.c	2004-07-18 20:23:58 UTC (rev 753)
@@ -158,7 +158,6 @@
 	{ "name_",          0},
 	{ "attrs_",         0},
 	{ "protos_",        0},
-	{ "command_",       0},
 	{ "notifyCallback_",0},
 	{ "get_",           0},
 	{ "set_",           0},