Changeset 499
- Timestamp:
- Apr 17, 2011, 11:57:07 PM (11 years ago)
- Location:
- abuse/trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/ant.cpp
r494 r499 119 119 push_onto_list(LNumber::Create(o->aitype()),call_list); 120 120 push_onto_list(LPointer::Create(o),call_list); 121 eval_user_fun((LSymbol *)l_fire_object,call_list);121 ((LSymbol *)l_fire_object)->EvalUserFunction((LList *)call_list); 122 122 o->set_state((character_state)S_weapon_fire); 123 123 } -
abuse/trunk/src/lisp/lisp.cpp
r498 r499 1460 1460 break; 1461 1461 case L_USER_FUNCTION: 1462 return (LObject *)eval_user_fun(this,arg_list);1462 return EvalUserFunction((LList *)arg_list); 1463 1463 default: 1464 1464 Print(); … … 1506 1506 break; 1507 1507 case L_USER_FUNCTION: 1508 return (LObject *)eval_user_fun(this,arg_list);1508 return EvalUserFunction((LList *)arg_list); 1509 1509 case L_C_FUNCTION: 1510 1510 case L_C_BOOL: … … 2773 2773 if (x < 0 || x >= (int32_t)strlen(st)) 2774 2774 { 2775 lbreak("elt 2775 lbreak("elt: out of range of string\n"); 2776 2776 ret = NULL; 2777 2777 } … … 2782 2782 case SYS_FUNC_LISTP: 2783 2783 { 2784 ltype t = item_type(CAR(arg_list)->Eval()); 2784 LObject *tmp = CAR(arg_list)->Eval(); 2785 ltype t = item_type(tmp); 2785 2786 ret = (t == L_CONS_CELL) ? true_symbol : NULL; 2786 2787 break; … … 2788 2789 case SYS_FUNC_NUMBERP: 2789 2790 { 2790 ltype t = item_type(CAR(arg_list)->Eval()); 2791 LObject *tmp = CAR(arg_list)->Eval(); 2792 ltype t = item_type(tmp); 2791 2793 ret = (t == L_NUMBER || t == L_FIXED_POINT) ? true_symbol : NULL; 2792 2794 break; … … 2796 2798 LObject *init_var = CAR(arg_list); 2797 2799 PtrRef r1(init_var); 2798 int ustack_start = l_user_stack.son; 2800 int ustack_start = l_user_stack.son; // restore stack at end 2799 2801 LSymbol *sym = NULL; 2800 2802 PtrRef r2(sym); … … 2868 2870 } 2869 2871 case SYS_FUNC_SYMBOLP: 2870 if (item_type(CAR(arg_list)->Eval()) == L_SYMBOL) 2871 ret = true_symbol; 2872 break; 2872 { 2873 LObject *tmp = CAR(arg_list)->Eval(); 2874 ret = (item_type(tmp) == L_SYMBOL) ? true_symbol : NULL; 2875 break; 2876 } 2873 2877 case SYS_FUNC_NUM2STR: 2874 2878 { … … 2988 2992 void tmp_space() 2989 2993 { 2990 current_space=TMP_SPACE;2994 current_space = TMP_SPACE; 2991 2995 } 2992 2996 2993 2997 void perm_space() 2994 2998 { 2995 current_space=PERM_SPACE;2999 current_space = PERM_SPACE; 2996 3000 } 2997 3001 2998 3002 void use_user_space(void *addr, long size) 2999 3003 { 3000 current_space = 2;3001 free_space[USER_SPACE] = space[USER_SPACE] = (uint8_t *)addr;3002 space_size[USER_SPACE] = size;3003 } 3004 3005 3006 void *eval_user_fun(LSymbol *sym, void*arg_list)3007 { 3008 void *ret=NULL;3009 PtrRef ref1(ret);3004 current_space = 2; 3005 free_space[USER_SPACE] = space[USER_SPACE] = (uint8_t *)addr; 3006 space_size[USER_SPACE] = size; 3007 } 3008 3009 /* PtrRef check: OK */ 3010 LObject *LSymbol::EvalUserFunction(LList *arg_list) 3011 { 3012 LObject *ret = NULL; 3013 PtrRef ref1(ret); 3010 3014 3011 3015 #ifdef TYPE_CHECKING 3012 if (item_type(sym)!=L_SYMBOL)3013 {3014 ((LObject *)sym)->Print();3015 lbreak("EVAL : is not a function name (not symbol either)");3016 exit(0);3017 }3016 if (item_type(this) != L_SYMBOL) 3017 { 3018 Print(); 3019 lbreak("EVAL : is not a function name (not symbol either)"); 3020 exit(0); 3021 } 3018 3022 #endif 3019 3023 #ifdef L_PROFILE 3020 time_marker start; 3021 #endif 3022 3023 3024 LUserFunction *fun=(LUserFunction *)(((LSymbol *)sym)->function); 3024 time_marker start; 3025 #endif 3026 3027 LUserFunction *fun = (LUserFunction *)function; 3025 3028 3026 3029 #ifdef TYPE_CHECKING 3027 if (item_type(fun)!=L_USER_FUNCTION)3028 {3029 ((LObject *)sym)->Print();3030 lbreak("is not a user defined function\n");3031 }3030 if (item_type(fun) != L_USER_FUNCTION) 3031 { 3032 Print(); 3033 lbreak("is not a user defined function\n"); 3034 } 3032 3035 #endif 3033 3036 3034 3037 #ifndef NO_LIBS 3035 void *fun_arg_list=cache.lblock(fun->alist);3036 void *block_list=cache.lblock(fun->blist);3037 PtrRef r9(block_list), r10(fun_arg_list);3038 void *fun_arg_list = cache.lblock(fun->alist); 3039 void *block_list = cache.lblock(fun->blist); 3040 PtrRef r9(block_list), r10(fun_arg_list); 3038 3041 #else 3039 void *fun_arg_list=fun->arg_list; 3040 void *block_list=fun->block_list; 3041 PtrRef r9(block_list), r10(fun_arg_list); 3042 #endif 3043 3044 3045 3046 // mark the start start, so we can restore when done 3047 long stack_start=l_user_stack.son; 3048 3049 // first push all of the old symbol values 3050 void *f_arg=fun_arg_list; 3051 PtrRef r18(f_arg); 3052 PtrRef r19(arg_list); 3053 for (; f_arg; f_arg=CDR(f_arg)) 3054 { 3055 LSymbol *s = (LSymbol *)CAR(f_arg); 3056 l_user_stack.push(s->value); 3057 } 3058 3059 // open block so that local vars aren't saved on the stack 3060 { 3061 int new_start=l_user_stack.son; 3062 int i=new_start; 3063 // now push all the values we wish to gather 3064 for (f_arg=fun_arg_list; f_arg; ) 3065 { 3066 if (!arg_list) 3067 { sym->Print(); lbreak("too few parameter to function\n"); exit(0); } 3068 l_user_stack.push(CAR(arg_list)->Eval()); 3069 f_arg=CDR(f_arg); 3070 arg_list=CDR(arg_list); 3071 } 3072 3073 3074 // now store all the values and put them into the symbols 3075 for (f_arg=fun_arg_list; f_arg; f_arg=CDR(f_arg)) 3076 ((LSymbol *)CAR(f_arg))->SetValue((LObject *)l_user_stack.sdata[i++]); 3077 3078 l_user_stack.son=new_start; 3079 } 3080 3081 3082 3083 if (f_arg) 3084 { sym->Print(); lbreak("too many parameter to function\n"); exit(0); } 3085 3086 3087 // now evaluate the function block 3088 while (block_list) 3089 { 3090 ret=CAR(block_list)->Eval(); 3091 block_list=CDR(block_list); 3092 } 3093 3094 long cur_stack=stack_start; 3095 for (f_arg=fun_arg_list; f_arg; f_arg=CDR(f_arg)) 3096 ((LSymbol *)CAR(f_arg))->SetValue((LObject *)l_user_stack.sdata[cur_stack++]); 3097 3098 l_user_stack.son=stack_start; 3042 void *fun_arg_list = fun->arg_list; 3043 void *block_list = fun->block_list; 3044 PtrRef r9(block_list), r10(fun_arg_list); 3045 #endif 3046 3047 // mark the start start, so we can restore when done 3048 long stack_start = l_user_stack.son; 3049 3050 // first push all of the old symbol values 3051 LObject *f_arg = NULL; 3052 PtrRef r18(f_arg); 3053 PtrRef r19(arg_list); 3054 3055 for (f_arg = (LObject *)fun_arg_list; f_arg; f_arg = CDR(f_arg)) 3056 { 3057 LSymbol *s = (LSymbol *)CAR(f_arg); 3058 l_user_stack.push(s->value); 3059 } 3060 3061 // open block so that local vars aren't saved on the stack 3062 { 3063 int new_start = l_user_stack.son; 3064 int i = new_start; 3065 // now push all the values we wish to gather 3066 for (f_arg = (LObject *)fun_arg_list; f_arg; f_arg = CDR(f_arg)) 3067 { 3068 if (!arg_list) 3069 { 3070 Print(); 3071 lbreak("too few parameter to function\n"); 3072 exit(0); 3073 } 3074 l_user_stack.push(CAR(arg_list)->Eval()); 3075 arg_list = (LList *)CDR(arg_list); 3076 } 3077 3078 // now store all the values and put them into the symbols 3079 for (f_arg = (LObject *)fun_arg_list; f_arg; f_arg = CDR(f_arg)) 3080 ((LSymbol *)CAR(f_arg))->SetValue((LObject *)l_user_stack.sdata[i++]); 3081 3082 l_user_stack.son = new_start; 3083 } 3084 3085 if (f_arg) 3086 { 3087 Print(); 3088 lbreak("too many parameter to function\n"); 3089 exit(0); 3090 } 3091 3092 // now evaluate the function block 3093 while (block_list) 3094 { 3095 ret = CAR(block_list)->Eval(); 3096 block_list = CDR(block_list); 3097 } 3098 3099 long cur_stack = stack_start; 3100 for (f_arg = (LObject *)fun_arg_list; f_arg; f_arg = CDR(f_arg)) 3101 ((LSymbol *)CAR(f_arg))->SetValue((LObject *)l_user_stack.sdata[cur_stack++]); 3102 3103 l_user_stack.son = stack_start; 3099 3104 3100 3105 #ifdef L_PROFILE 3101 time_marker end; 3102 sym->time_taken += end.diff_time(&start); 3103 #endif 3104 3105 3106 return ret; 3106 time_marker end; 3107 sym->time_taken += end.diff_time(&start); 3108 #endif 3109 3110 return ret; 3107 3111 } 3108 3112 -
abuse/trunk/src/lisp/lisp.h
r498 r499 118 118 /* Methods */ 119 119 LObject *EvalFunction(void *arg_list); 120 LObject *EvalUserFunction(LList *arg_list); 120 121 121 122 LString *GetName(); … … 220 221 void *lisp_equal(void *n1, void *n2); 221 222 void *eval_block(void *list); 222 void *eval_user_fun(LSymbol *sym, void *arg_list);223 223 void *assoc(void *item, void *list); 224 224 void resize_tmp(int new_size); -
abuse/trunk/src/objects.cpp
r497 r499 524 524 prof1 = new time_marker; 525 525 526 eval_user_fun((LSymbol *)d,am);526 ((LSymbol *)d)->EvalUserFunction(am); 527 527 if (profiling()) 528 528 { … … 1594 1594 prof1=new time_marker; 1595 1595 1596 eval_user_fun((LSymbol *)f,NULL);1596 ((LSymbol *)f)->EvalUserFunction(NULL); 1597 1597 1598 1598 if (profiling()) -
abuse/trunk/src/view.cpp
r497 r499 884 884 game_object *o=current_object; 885 885 current_object=focus; 886 eval_user_fun((LSymbol *)figures[focus->otype]->get_fun(OFUN_CONSTRUCTOR),NULL);886 ((LSymbol *)figures[focus->otype]->get_fun(OFUN_CONSTRUCTOR))->EvalUserFunction(NULL); 887 887 current_object=o; 888 888 }
Note: See TracChangeset
for help on using the changeset viewer.