Changeset d0febca in mainline
- Timestamp:
- 2010-03-13T12:04:37Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7715994
- Parents:
- 94d484a
- Location:
- uspace/app/sbi/src
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sbi/src/builtin.c
r94d484a rd0febca 27 27 */ 28 28 29 /** @file Builtin functions. */29 /** @file Builtin procedures. */ 30 30 31 31 #include <stdio.h> … … 42 42 #include "builtin.h" 43 43 44 static stree_symbol_t *builtin_declare_fun(stree_csi_t *csi, c har *name);45 static void builtin_fun_add_arg(stree_symbol_t *fun_sym, c har *name);46 static void builtin_fun_add_vararg(stree_symbol_t *fun_sym, c har *name);44 static stree_symbol_t *builtin_declare_fun(stree_csi_t *csi, const char *name); 45 static void builtin_fun_add_arg(stree_symbol_t *fun_sym, const char *name); 46 static void builtin_fun_add_vararg(stree_symbol_t *fun_sym, const char *name); 47 47 48 48 static void builtin_write_line(run_t *run); … … 54 54 /** Declare builtin symbols in the program. 55 55 * 56 * Declares symbols that will be hooked to builtin interpreter functions.56 * Declares symbols that will be hooked to builtin interpreter procedures. 57 57 */ 58 58 void builtin_declare(stree_program_t *program) … … 80 80 list_append(&program->module->members, modm); 81 81 82 /* Declare builtin functions. */82 /* Declare builtin procedures. */ 83 83 84 84 bi_write_line = builtin_declare_fun(csi, "WriteLine"); … … 89 89 } 90 90 91 void builtin_run_ fun(run_t *run, stree_symbol_t *fun_sym)91 void builtin_run_proc(run_t *run, stree_symbol_t *proc_sym) 92 92 { 93 93 #ifdef DEBUG_RUN_TRACE 94 printf("Run builtin function.\n");94 printf("Run builtin procedure.\n"); 95 95 #endif 96 if ( fun_sym == bi_write_line) {96 if (proc_sym == bi_write_line) { 97 97 builtin_write_line(run); 98 } else if ( fun_sym == bi_exec) {98 } else if (proc_sym == bi_exec) { 99 99 builtin_exec(run); 100 100 } else { … … 104 104 105 105 /** Declare a builtin function in @a csi. */ 106 static stree_symbol_t *builtin_declare_fun(stree_csi_t *csi, c har *name)106 static stree_symbol_t *builtin_declare_fun(stree_csi_t *csi, const char *name) 107 107 { 108 108 stree_ident_t *ident; … … 133 133 134 134 /** Add one formal parameter to function. */ 135 static void builtin_fun_add_arg(stree_symbol_t *fun_sym, c har *name)136 { 137 stree_ fun_arg_t *fun_arg;135 static void builtin_fun_add_arg(stree_symbol_t *fun_sym, const char *name) 136 { 137 stree_proc_arg_t *proc_arg; 138 138 stree_fun_t *fun; 139 139 … … 141 141 assert(fun != NULL); 142 142 143 fun_arg = stree_fun_arg_new();144 fun_arg->name = stree_ident_new();145 fun_arg->name->sid = strtab_get_sid(name);146 fun_arg->type = NULL; /* XXX */147 148 list_append(&fun->args, fun_arg);143 proc_arg = stree_proc_arg_new(); 144 proc_arg->name = stree_ident_new(); 145 proc_arg->name->sid = strtab_get_sid(name); 146 proc_arg->type = NULL; /* XXX */ 147 148 list_append(&fun->args, proc_arg); 149 149 } 150 150 151 151 /** Add variadic formal parameter to function. */ 152 static void builtin_fun_add_vararg(stree_symbol_t *fun_sym, c har *name)153 { 154 stree_ fun_arg_t *fun_arg;152 static void builtin_fun_add_vararg(stree_symbol_t *fun_sym, const char *name) 153 { 154 stree_proc_arg_t *proc_arg; 155 155 stree_fun_t *fun; 156 156 … … 158 158 assert(fun != NULL); 159 159 160 fun_arg = stree_fun_arg_new();161 fun_arg->name = stree_ident_new();162 fun_arg->name->sid = strtab_get_sid(name);163 fun_arg->type = NULL; /* XXX */164 165 fun->varg = fun_arg;160 proc_arg = stree_proc_arg_new(); 161 proc_arg->name = stree_ident_new(); 162 proc_arg->name->sid = strtab_get_sid(name); 163 proc_arg->type = NULL; /* XXX */ 164 165 fun->varg = proc_arg; 166 166 } 167 167 -
uspace/app/sbi/src/builtin.h
r94d484a rd0febca 33 33 34 34 void builtin_declare(stree_program_t *program); 35 void builtin_run_ fun(run_t *run, stree_symbol_t *fun_sym);35 void builtin_run_proc(run_t *run, stree_symbol_t *proc_sym); 36 36 37 37 #endif -
uspace/app/sbi/src/os/helenos.c
r94d484a rd0febca 75 75 } 76 76 77 /** Get character from string at the given index. */ 78 int os_str_get_char(const char *str, int index, int *out_char) 79 { 80 size_t offset; 81 int i; 82 wchar_t c; 83 84 if (index < 0) 85 return EINVAL; 86 87 offset = 0; 88 for (i = 0; i <= index; ++i) { 89 c = str_decode(str, &offset, STR_NO_LIMIT); 90 if (c == '\0') 91 return EINVAL; 92 if (c == U_SPECIAL) 93 return EIO; 94 } 95 96 *out_char = (int) c; 97 return EOK; 98 } 99 77 100 /** Simple command execution. */ 78 101 int os_exec(char *const cmd[]) -
uspace/app/sbi/src/os/os.h
r94d484a rd0febca 33 33 int os_str_cmp(const char *a, const char *b); 34 34 char *os_str_dup(const char *str); 35 int os_str_get_char(const char *str, int index, int *out_char); 35 36 int os_exec(char *const cmd[]); 36 37 -
uspace/app/sbi/src/os/posix.c
r94d484a rd0febca 79 79 } 80 80 81 /** Get character from string at the given index. */ 82 int os_str_get_char(const char *str, int index, int *out_char) 83 { 84 size_t len; 85 86 len = strlen(str); 87 if (index < 0 || (size_t) index >= len) 88 return EINVAL; 89 90 *out_char = str[index]; 91 return EOK; 92 } 93 81 94 /** Simple command execution. */ 82 95 int os_exec(char *const cmd[]) -
uspace/app/sbi/src/parse.c
r94d484a rd0febca 55 55 static stree_prop_t *parse_prop(parse_t *parse); 56 56 57 static stree_ fun_arg_t *parse_fun_arg(parse_t *parse);57 static stree_proc_arg_t *parse_proc_arg(parse_t *parse); 58 58 static stree_arg_attr_t *parse_arg_attr(parse_t *parse); 59 59 … … 227 227 { 228 228 stree_fun_t *fun; 229 stree_ fun_arg_t *arg;229 stree_proc_arg_t *arg; 230 230 231 231 fun = stree_fun_new(); … … 241 241 /* Parse formal parameters. */ 242 242 while (b_true) { 243 arg = parse_ fun_arg(parse);243 arg = parse_proc_arg(parse); 244 244 if (stree_arg_has_attr(arg, aac_packed)) { 245 245 fun->varg = arg; … … 292 292 { 293 293 stree_prop_t *prop; 294 stree_ident_t *ident; 295 stree_proc_arg_t *arg; 294 296 295 297 prop = stree_prop_new(); 298 list_init(&prop->args); 296 299 297 300 lmatch(parse, lc_prop); 298 prop->name = parse_ident(parse); 301 302 if (lcur_lc(parse) == lc_self) { 303 /* Indexed property set */ 304 305 /* Use some name that is impossible as identifier. */ 306 ident = stree_ident_new(); 307 ident->sid = strtab_get_sid(INDEXER_IDENT); 308 prop->name = ident; 309 310 lskip(parse); 311 lmatch(parse, lc_lsbr); 312 313 /* Parse formal parameters. */ 314 while (b_true) { 315 arg = parse_proc_arg(parse); 316 if (stree_arg_has_attr(arg, aac_packed)) { 317 prop->varg = arg; 318 break; 319 } else { 320 list_append(&prop->args, arg); 321 } 322 323 if (lcur_lc(parse) == lc_rsbr) 324 break; 325 326 lmatch(parse, lc_scolon); 327 } 328 329 lmatch(parse, lc_rsbr); 330 } else { 331 /* Named property */ 332 prop->name = parse_ident(parse); 333 } 334 299 335 lmatch(parse, lc_colon); 300 336 prop->type = parse_texpr(parse); 301 337 lmatch(parse, lc_is); 338 339 while (lcur_lc(parse) != lc_end) { 340 switch (lcur_lc(parse)) { 341 case lc_get: 342 lskip(parse); 343 lmatch(parse, lc_is); 344 if (prop->getter_body != NULL) { 345 printf("Error: Duplicate getter.\n"); 346 exit(1); 347 } 348 prop->getter_body = parse_block(parse); 349 lmatch(parse, lc_end); 350 break; 351 case lc_set: 352 lskip(parse); 353 prop->setter_arg_name = parse_ident(parse); 354 lmatch(parse, lc_is); 355 if (prop->setter_body != NULL) { 356 printf("Error: Duplicate setter.\n"); 357 exit(1); 358 } 359 prop->setter_body = parse_block(parse); 360 lmatch(parse, lc_end); 361 break; 362 default: 363 lunexpected_error(parse); 364 } 365 } 366 302 367 lmatch(parse, lc_end); 303 368 … … 306 371 307 372 /** Parse formal function argument. */ 308 static stree_ fun_arg_t *parse_fun_arg(parse_t *parse)309 { 310 stree_ fun_arg_t *arg;373 static stree_proc_arg_t *parse_proc_arg(parse_t *parse) 374 { 375 stree_proc_arg_t *arg; 311 376 stree_arg_attr_t *attr; 312 377 313 arg = stree_ fun_arg_new();378 arg = stree_proc_arg_new(); 314 379 arg->name = parse_ident(parse); 315 380 lmatch(parse, lc_colon); -
uspace/app/sbi/src/rdata.c
r94d484a rd0febca 64 64 } 65 65 66 rdata_address_t *rdata_address_new(void) 66 rdata_addr_var_t *rdata_addr_var_new(void) 67 { 68 rdata_addr_var_t *addr_var; 69 70 addr_var = calloc(1, sizeof(rdata_addr_var_t)); 71 if (addr_var == NULL) { 72 printf("Memory allocation failed.\n"); 73 exit(1); 74 } 75 76 return addr_var; 77 } 78 79 rdata_aprop_named_t *rdata_aprop_named_new(void) 80 { 81 rdata_aprop_named_t *aprop_named; 82 83 aprop_named = calloc(1, sizeof(rdata_aprop_named_t)); 84 if (aprop_named == NULL) { 85 printf("Memory allocation failed.\n"); 86 exit(1); 87 } 88 89 return aprop_named; 90 } 91 92 rdata_aprop_indexed_t *rdata_aprop_indexed_new(void) 93 { 94 rdata_aprop_indexed_t *aprop_indexed; 95 96 aprop_indexed = calloc(1, sizeof(rdata_aprop_indexed_t)); 97 if (aprop_indexed == NULL) { 98 printf("Memory allocation failed.\n"); 99 exit(1); 100 } 101 102 return aprop_indexed; 103 } 104 105 rdata_addr_prop_t *rdata_addr_prop_new(aprop_class_t apc) 106 { 107 rdata_addr_prop_t *addr_prop; 108 109 addr_prop = calloc(1, sizeof(rdata_addr_prop_t)); 110 if (addr_prop == NULL) { 111 printf("Memory allocation failed.\n"); 112 exit(1); 113 } 114 115 addr_prop->apc = apc; 116 return addr_prop; 117 } 118 119 rdata_address_t *rdata_address_new(address_class_t ac) 67 120 { 68 121 rdata_address_t *address; … … 74 127 } 75 128 129 address->ac = ac; 76 130 return address; 77 131 } … … 349 403 } 350 404 351 /** Convert item to value item. 352 * 353 * If @a item is a value, we just return a copy. If @a item is an address, 354 * we read from the address. 405 /** Read data from a variable. 406 * 407 * Return value stored in variable @a var. 355 408 */ 356 void rdata_cvt_value_item(rdata_item_t *item, rdata_item_t **ritem) 357 { 358 rdata_value_t *value; 359 360 /* 361 * This can happen when trying to use output of a function which 362 * does not return a value. 363 */ 364 if (item == NULL) { 365 printf("Error: Sub-expression has no value.\n"); 366 exit(1); 367 } 368 369 /* Address item. Perform read operation. */ 370 if (item->ic == ic_address) { 371 rdata_address_read(item->u.address, ritem); 372 return; 373 } 374 375 /* It already is a value, we can share the @c var. */ 376 value = rdata_value_new(); 377 value->var = item->u.value->var; 378 *ritem = rdata_item_new(ic_value); 379 (*ritem)->u.value = value; 380 } 381 382 /** Return reference to a variable. 383 * 384 * Constructs a reference (value item) pointing to @a var. 385 */ 386 void rdata_reference(rdata_var_t *var, rdata_item_t **res) 387 { 388 rdata_ref_t *ref; 389 rdata_var_t *ref_var; 390 rdata_value_t *ref_value; 391 rdata_item_t *ref_item; 392 393 /* Create reference to the variable. */ 394 ref = rdata_ref_new(); 395 ref_var = rdata_var_new(vc_ref); 396 ref->vref = var; 397 ref_var->u.ref_v = ref; 398 399 /* Construct value of the reference to return. */ 400 ref_item = rdata_item_new(ic_value); 401 ref_value = rdata_value_new(); 402 ref_item->u.value = ref_value; 403 ref_value->var = ref_var; 404 405 *res = ref_item; 406 } 407 408 /** Return address of reference target. 409 * 410 * Takes a reference (address or value) and returns the address (item) of 411 * the target of the reference. 412 */ 413 void rdata_dereference(rdata_item_t *ref, rdata_item_t **ritem) 414 { 415 rdata_item_t *ref_val; 416 rdata_item_t *item; 417 rdata_address_t *address; 418 419 #ifdef DEBUG_RUN_TRACE 420 printf("run_dereference()\n"); 421 #endif 422 rdata_cvt_value_item(ref, &ref_val); 423 assert(ref_val->u.value->var->vc == vc_ref); 424 425 item = rdata_item_new(ic_address); 426 address = rdata_address_new(); 427 item->u.address = address; 428 address->vref = ref_val->u.value->var->u.ref_v->vref; 429 430 if (address->vref == NULL) { 431 printf("Error: Accessing null reference.\n"); 432 exit(1); 433 } 434 435 #ifdef DEBUG_RUN_TRACE 436 printf("vref set to %p\n", address->vref); 437 #endif 438 *ritem = item; 439 } 440 441 /** Read data from an address. 442 * 443 * Return value stored in a variable at the specified address. 444 */ 445 void rdata_address_read(rdata_address_t *address, rdata_item_t **ritem) 409 void rdata_var_read(rdata_var_t *var, rdata_item_t **ritem) 446 410 { 447 411 rdata_value_t *value; 448 412 rdata_var_t *rvar; 449 413 450 /* Perform a shallow copy of @ cvar. */451 rdata_var_copy( address->vref, &rvar);414 /* Perform a shallow copy of @a var. */ 415 rdata_var_copy(var, &rvar); 452 416 453 417 value = rdata_value_new(); … … 455 419 *ritem = rdata_item_new(ic_value); 456 420 (*ritem)->u.value = value; 457 }458 459 /** Write data to an address.460 *461 * Store @a value to the variable at @a address.462 */463 void rdata_address_write(rdata_address_t *address, rdata_value_t *value)464 {465 rdata_var_write(address->vref, value);466 421 } 467 422 … … 492 447 } 493 448 449 /** Get item var-class. 450 * 451 * Get var-class of @a item, regardless whether it is a value or address. 452 * (I.e. the var class of the value or variable at the given address). 453 */ 454 var_class_t rdata_item_get_vc(rdata_item_t *item) 455 { 456 var_class_t vc; 457 458 switch (item->ic) { 459 case ic_value: 460 vc = item->u.value->var->vc; 461 break; 462 case ic_address: 463 switch (item->u.address->ac) { 464 case ac_var: 465 vc = item->u.address->u.var_a->vref->vc; 466 break; 467 case ac_prop: 468 printf("Unimplemented: Get property address " 469 "varclass.\n"); 470 exit(1); 471 default: 472 assert(b_false); 473 } 474 break; 475 default: 476 assert(b_false); 477 } 478 479 return vc; 480 } 481 494 482 /** Determine if CSI @a a is derived from CSI described by type item @a tb. */ 495 483 bool_t rdata_is_csi_derived_from_ti(stree_csi_t *a, rdata_titem_t *tb) … … 530 518 static void rdata_address_print(rdata_address_t *address) 531 519 { 532 rdata_var_print(address->vref); 520 switch (address->ac) { 521 case ac_var: 522 rdata_var_print(address->u.var_a->vref); 523 break; 524 case ac_prop: 525 printf("Warning: Unimplemented: Print property address.\n"); 526 break; 527 } 533 528 } 534 529 -
uspace/app/sbi/src/rdata.h
r94d484a rd0febca 33 33 34 34 rdata_item_t *rdata_item_new(item_class_t ic); 35 rdata_address_t *rdata_address_new(void); 35 rdata_addr_var_t *rdata_addr_var_new(void); 36 rdata_aprop_named_t *rdata_aprop_named_new(void); 37 rdata_aprop_indexed_t *rdata_aprop_indexed_new(void); 38 rdata_addr_prop_t *rdata_addr_prop_new(aprop_class_t apc); 39 rdata_address_t *rdata_address_new(address_class_t ac); 36 40 rdata_value_t *rdata_value_new(void); 41 37 42 rdata_var_t *rdata_var_new(var_class_t vc); 38 43 rdata_ref_t *rdata_ref_new(void); … … 51 56 void rdata_var_copy(rdata_var_t *src, rdata_var_t **dest); 52 57 53 void rdata_cvt_value_item(rdata_item_t *item, rdata_item_t **ritem); 54 void rdata_reference(rdata_var_t *var, rdata_item_t **res); 55 void rdata_dereference(rdata_item_t *ref, rdata_item_t **ritem); 56 void rdata_address_read(rdata_address_t *address, rdata_item_t **ritem); 57 void rdata_address_write(rdata_address_t *address, rdata_value_t *value); 58 void rdata_var_read(rdata_var_t *var, rdata_item_t **ritem); 58 59 void rdata_var_write(rdata_var_t *var, rdata_value_t *value); 59 60 61 var_class_t rdata_item_get_vc(rdata_item_t *item); 60 62 bool_t rdata_is_csi_derived_from_ti(stree_csi_t *a, rdata_titem_t *tb); 61 63 -
uspace/app/sbi/src/rdata_t.h
r94d484a rd0febca 131 131 } rdata_var_t; 132 132 133 /** Address item. */ 134 typedef struct rdata_address { 133 /** Address class */ 134 typedef enum { 135 /** Variable address */ 136 ac_var, 137 138 /** Property address */ 139 ac_prop 140 } address_class_t; 141 142 /** Variable address */ 143 typedef struct { 135 144 /** Targeted variable */ 136 145 rdata_var_t *vref; 146 } rdata_addr_var_t; 147 148 /** Named property address */ 149 typedef struct { 150 /** Delegate to the property */ 151 rdata_deleg_t *prop_d; 152 } rdata_aprop_named_t; 153 154 /** Indexed property address */ 155 typedef struct { 156 /** Delegate to the object (or CSI) which is being indexed. */ 157 rdata_deleg_t *object_d; 158 159 /** Arguments (indices) */ 160 list_t args; /* of rdata_item_t */ 161 } rdata_aprop_indexed_t; 162 163 typedef enum { 164 /* Named property address */ 165 apc_named, 166 167 /* Indexed property address */ 168 apc_indexed 169 } aprop_class_t; 170 171 /** Property address. 172 * 173 * When accessing part of a property that is non-scalar and mutable, 174 * a read-modify-write (or get-modify-set) operation is necessary. 175 * To accomodate this, the address item must hold a temporary copy of the 176 * property value. 177 */ 178 typedef struct { 179 aprop_class_t apc; 180 181 /** Temporary copy of property value or @c NULL when not used. */ 182 struct rdata_value *tvalue; 183 184 /** 185 * Points to the specific var node within @c tvalue that is addressed 186 * or @c NULL when @c tvalue is not used. 187 */ 188 rdata_var_t *tpos; 189 190 union { 191 rdata_aprop_named_t *named; 192 rdata_aprop_indexed_t *indexed; 193 } u; 194 } rdata_addr_prop_t; 195 196 /** Address item */ 197 typedef struct rdata_address { 198 address_class_t ac; 199 200 union { 201 rdata_addr_var_t *var_a; 202 rdata_addr_prop_t *prop_a; 203 } u; 137 204 } rdata_address_t; 138 205 -
uspace/app/sbi/src/run.c
r94d484a rd0febca 58 58 static bool_t run_exc_match(run_t *run, stree_except_t *except_c); 59 59 60 static void run_aprop_read(run_t *run, rdata_addr_prop_t *addr_prop, 61 rdata_item_t **ritem); 62 static void run_aprop_write(run_t *run, rdata_addr_prop_t *addr_prop, 63 rdata_value_t *value); 64 60 65 /** Initialize runner instance. */ 61 66 void run_init(run_t *run) … … 71 76 stree_ident_t *fake_ident; 72 77 list_t main_args; 73 run_ fun_ar_t *fun_ar;78 run_proc_ar_t *proc_ar; 74 79 rdata_item_t *res; 75 80 … … 79 84 /* Initialize thread activation record. */ 80 85 run->thread_ar = run_thread_ar_new(); 81 list_init(&run->thread_ar-> fun_ar);86 list_init(&run->thread_ar->proc_ar); 82 87 run->thread_ar->bo_mode = bm_none; 83 88 … … 103 108 /* Run function @c main. */ 104 109 list_init(&main_args); 105 run_ fun_ar_create(run, NULL, main_fun, &fun_ar);106 run_ fun_ar_set_args(run, fun_ar, &main_args);107 run_ fun(run, fun_ar, &res);110 run_proc_ar_create(run, NULL, main_fun_sym, main_fun->body, &proc_ar); 111 run_proc_ar_set_args(run, proc_ar, &main_args); 112 run_proc(run, proc_ar, &res); 108 113 109 114 /* Check for unhandled exceptions. */ … … 115 120 } 116 121 117 /** Run member function */ 118 void run_fun(run_t *run, run_fun_ar_t *fun_ar, rdata_item_t **res) 119 { 120 stree_symbol_t *fun_sym; 121 stree_fun_t *fun; 122 /** Run procedure. */ 123 void run_proc(run_t *run, run_proc_ar_t *proc_ar, rdata_item_t **res) 124 { 125 stree_symbol_t *proc_sym; 122 126 list_node_t *node; 123 127 124 fun_sym = fun_ar->fun_sym; 125 fun = symbol_to_fun(fun_sym); 126 assert(fun != NULL); 128 proc_sym = proc_ar->proc_sym; 127 129 128 130 #ifdef DEBUG_RUN_TRACE 129 131 printf("Start executing function '"); 130 symbol_print_fqn(run->program, fun_sym);132 symbol_print_fqn(run->program, proc_sym); 131 133 printf("'.\n"); 132 134 #endif 133 /* Add functionAR to the stack. */134 list_append(&run->thread_ar-> fun_ar, fun_ar);135 136 /* Run main functionblock. */137 if ( fun->body!= NULL) {138 run_block(run, fun->body);135 /* Add procedure AR to the stack. */ 136 list_append(&run->thread_ar->proc_ar, proc_ar); 137 138 /* Run main procedure block. */ 139 if (proc_ar->proc_block != NULL) { 140 run_block(run, proc_ar->proc_block); 139 141 } else { 140 builtin_run_ fun(run, fun_sym);142 builtin_run_proc(run, proc_sym); 141 143 } 142 144 … … 146 148 printf("Error: Misplaced 'break' statement.\n"); 147 149 exit(1); 148 case bm_ fun:150 case bm_proc: 149 151 run->thread_ar->bo_mode = bm_none; 150 152 break; … … 154 156 155 157 #ifdef DEBUG_RUN_TRACE 156 printf("Done executing function'");157 symbol_print_fqn(run->program, fun_sym);158 printf("Done executing procedure '"); 159 symbol_print_fqn(run->program, proc_sym); 158 160 printf("'.\n"); 159 161 160 162 run_print_fun_bt(run); 161 163 #endif 162 /* Remove function activation record from the stack. */ 163 node = list_last(&run->thread_ar->fun_ar); 164 assert(list_node_data(node, run_fun_ar_t *) == fun_ar); 165 list_remove(&run->thread_ar->fun_ar, node); 166 167 *res = fun_ar->retval; 164 /* Remove procedure activation record from the stack. */ 165 node = list_last(&run->thread_ar->proc_ar); 166 assert(list_node_data(node, run_proc_ar_t *) == proc_ar); 167 list_remove(&run->thread_ar->proc_ar, node); 168 169 /* Procedure should not return an address. */ 170 assert(proc_ar->retval == NULL || proc_ar->retval->ic == ic_value); 171 *res = proc_ar->retval; 168 172 } 169 173 … … 171 175 static void run_block(run_t *run, stree_block_t *block) 172 176 { 173 run_ fun_ar_t *fun_ar;177 run_proc_ar_t *proc_ar; 174 178 run_block_ar_t *block_ar; 175 179 list_node_t *node; … … 185 189 186 190 /* Add block activation record to the stack. */ 187 fun_ar = run_get_current_fun_ar(run);188 list_append(& fun_ar->block_ar, block_ar);191 proc_ar = run_get_current_proc_ar(run); 192 list_append(&proc_ar->block_ar, block_ar); 189 193 190 194 node = list_first(&block->stats); … … 204 208 205 209 /* Remove block activation record from the stack. */ 206 node = list_last(& fun_ar->block_ar);210 node = list_last(&proc_ar->block_ar); 207 211 assert(list_node_data(node, run_block_ar_t *) == block_ar); 208 list_remove(& fun_ar->block_ar, node);212 list_remove(&proc_ar->block_ar, node); 209 213 } 210 214 … … 357 361 #endif 358 362 run_expr(run, raise_s->expr, &rexpr); 359 r data_cvt_value_item(rexpr, &rexpr_vi);363 run_cvt_value_item(run, rexpr, &rexpr_vi); 360 364 361 365 /* Store expression result in thread AR. */ … … 370 374 { 371 375 rdata_item_t *rexpr; 372 run_fun_ar_t *fun_ar; 376 rdata_item_t *rexpr_vi; 377 run_proc_ar_t *proc_ar; 373 378 374 379 #ifdef DEBUG_RUN_TRACE … … 376 381 #endif 377 382 run_expr(run, return_s->expr, &rexpr); 383 run_cvt_value_item(run, rexpr, &rexpr_vi); 378 384 379 385 /* Store expression result in function AR. */ 380 fun_ar = run_get_current_fun_ar(run);381 fun_ar->retval = rexpr;382 383 /* Force control to ascend and leave the function. */386 proc_ar = run_get_current_proc_ar(run); 387 proc_ar->retval = rexpr_vi; 388 389 /* Force control to ascend and leave the procedure. */ 384 390 if (run->thread_ar->bo_mode == bm_none) 385 run->thread_ar->bo_mode = bm_ fun;391 run->thread_ar->bo_mode = bm_proc; 386 392 } 387 393 … … 501 507 rdata_var_t *run_local_vars_lookup(run_t *run, sid_t name) 502 508 { 503 run_ fun_ar_t *fun_ar;509 run_proc_ar_t *proc_ar; 504 510 run_block_ar_t *block_ar; 505 511 rdata_var_t *var; 506 512 list_node_t *node; 507 513 508 fun_ar = run_get_current_fun_ar(run);509 node = list_last(& fun_ar->block_ar);514 proc_ar = run_get_current_proc_ar(run); 515 node = list_last(&proc_ar->block_ar); 510 516 511 517 /* Walk through all block activation records. */ … … 516 522 return var; 517 523 518 node = list_prev(& fun_ar->block_ar, node);524 node = list_prev(&proc_ar->block_ar, node); 519 525 } 520 526 … … 524 530 525 531 /** Get current function activation record. */ 526 run_ fun_ar_t *run_get_current_fun_ar(run_t *run)532 run_proc_ar_t *run_get_current_proc_ar(run_t *run) 527 533 { 528 534 list_node_t *node; 529 535 530 node = list_last(&run->thread_ar-> fun_ar);531 return list_node_data(node, run_ fun_ar_t *);536 node = list_last(&run->thread_ar->proc_ar); 537 return list_node_data(node, run_proc_ar_t *); 532 538 } 533 539 … … 535 541 run_block_ar_t *run_get_current_block_ar(run_t *run) 536 542 { 537 run_ fun_ar_t *fun_ar;543 run_proc_ar_t *proc_ar; 538 544 list_node_t *node; 539 545 540 fun_ar = run_get_current_fun_ar(run);541 542 node = list_last(& fun_ar->block_ar);546 proc_ar = run_get_current_proc_ar(run); 547 548 node = list_last(&proc_ar->block_ar); 543 549 return list_node_data(node, run_block_ar_t *); 544 550 } … … 547 553 stree_csi_t *run_get_current_csi(run_t *run) 548 554 { 549 run_ fun_ar_t *fun_ar;550 551 fun_ar = run_get_current_fun_ar(run);552 return fun_ar->fun_sym->outer_csi;555 run_proc_ar_t *proc_ar; 556 557 proc_ar = run_get_current_proc_ar(run); 558 return proc_ar->proc_sym->outer_csi; 553 559 } 554 560 … … 600 606 601 607 /** Construct a function AR. */ 602 void run_fun_ar_create(run_t *run, rdata_var_t *obj, stree_fun_t *fun, 603 run_fun_ar_t **rfun_ar) 604 { 605 run_fun_ar_t *fun_ar; 608 void run_proc_ar_create(run_t *run, rdata_var_t *obj, stree_symbol_t *proc_sym, 609 stree_block_t *proc_block, run_proc_ar_t **rproc_ar) 610 { 611 run_proc_ar_t *proc_ar; 612 run_block_ar_t *block_ar; 606 613 607 614 (void) run; 608 615 609 616 /* Create function activation record. */ 610 fun_ar = run_fun_ar_new(); 611 fun_ar->obj = obj; 612 fun_ar->fun_sym = fun_to_symbol(fun); 613 list_init(&fun_ar->block_ar); 614 615 fun_ar->retval = NULL; 616 617 *rfun_ar = fun_ar; 618 } 619 620 /** Fill arguments in a function AR. */ 621 void run_fun_ar_set_args(run_t *run, run_fun_ar_t *fun_ar, list_t *args) 617 proc_ar = run_proc_ar_new(); 618 proc_ar->obj = obj; 619 proc_ar->proc_sym = proc_sym; 620 proc_ar->proc_block = proc_block; 621 list_init(&proc_ar->block_ar); 622 623 proc_ar->retval = NULL; 624 625 /* Create special block activation record to hold function arguments. */ 626 block_ar = run_block_ar_new(); 627 intmap_init(&block_ar->vars); 628 list_append(&proc_ar->block_ar, block_ar); 629 630 *rproc_ar = proc_ar; 631 } 632 633 /** Fill arguments in a procedure AR. 634 * 635 * When invoking a procedure this is used to store the argument values 636 * in the activation record. 637 */ 638 void run_proc_ar_set_args(run_t *run, run_proc_ar_t *proc_ar, list_t *arg_vals) 622 639 { 623 640 stree_fun_t *fun; 641 stree_prop_t *prop; 642 list_t *args; 643 stree_proc_arg_t *varg; 644 624 645 run_block_ar_t *block_ar; 625 list_node_t *rarg_n, *farg_n; 646 list_node_t *block_ar_n; 647 list_node_t *rarg_n, *parg_n; 626 648 list_node_t *cn; 627 649 rdata_item_t *rarg; 628 stree_ fun_arg_t *farg;650 stree_proc_arg_t *parg; 629 651 rdata_var_t *var; 630 652 rdata_var_t *ref_var; … … 633 655 int n_vargs, idx; 634 656 635 /* AR should have been created with run_fun_ar_create(). */ 636 assert(fun_ar->fun_sym != NULL); 637 assert(list_is_empty(&fun_ar->block_ar)); 638 639 fun = symbol_to_fun(fun_ar->fun_sym); 640 assert(fun != NULL); 641 642 /* Create special block activation record to hold function arguments. */ 643 block_ar = run_block_ar_new(); 644 intmap_init(&block_ar->vars); 645 list_append(&fun_ar->block_ar, block_ar); 657 /* AR should have been created with run_proc_ar_create(). */ 658 assert(proc_ar->proc_sym != NULL); 659 660 /* 661 * The procedure being activated should be a member function or 662 * property getter/setter. 663 */ 664 switch (proc_ar->proc_sym->sc) { 665 case sc_fun: 666 fun = symbol_to_fun(proc_ar->proc_sym); 667 args = &fun->args; 668 varg = fun->varg; 669 break; 670 case sc_prop: 671 prop = symbol_to_prop(proc_ar->proc_sym); 672 args = &prop->args; 673 varg = prop->varg; 674 break; 675 default: 676 assert(b_false); 677 } 678 679 /* Fetch first block activation record. */ 680 block_ar_n = list_first(&proc_ar->block_ar); 681 assert(block_ar_n != NULL); 682 block_ar = list_node_data(block_ar_n, run_block_ar_t *); 646 683 647 684 /* Declare local variables to hold argument values. */ 648 rarg_n = list_first(arg s);649 farg_n = list_first(&fun->args);650 651 while ( farg_n != NULL) {685 rarg_n = list_first(arg_vals); 686 parg_n = list_first(args); 687 688 while (parg_n != NULL) { 652 689 if (rarg_n == NULL) { 653 690 printf("Error: Too few arguments to function '"); 654 symbol_print_fqn(run->program, fun_ar->fun_sym);691 symbol_print_fqn(run->program, proc_ar->proc_sym); 655 692 printf("'.\n"); 656 693 exit(1); … … 658 695 659 696 rarg = list_node_data(rarg_n, rdata_item_t *); 660 farg = list_node_data(farg_n, stree_fun_arg_t *);697 parg = list_node_data(parg_n, stree_proc_arg_t *); 661 698 662 699 assert(rarg->ic == ic_value); … … 666 703 667 704 /* Declare variable using name of formal argument. */ 668 intmap_set(&block_ar->vars, farg->name->sid, var);669 670 rarg_n = list_next(arg s, rarg_n);671 farg_n = list_next(&fun->args, farg_n);672 } 673 674 if ( fun->varg != NULL) {705 intmap_set(&block_ar->vars, parg->name->sid, var); 706 707 rarg_n = list_next(arg_vals, rarg_n); 708 parg_n = list_next(args, parg_n); 709 } 710 711 if (varg != NULL) { 675 712 /* Function is variadic. Count number of variadic arguments. */ 676 713 cn = rarg_n; … … 678 715 while (cn != NULL) { 679 716 n_vargs += 1; 680 cn = list_next(arg s, cn);717 cn = list_next(arg_vals, cn); 681 718 } 682 719 … … 695 732 rdata_var_write(array->element[idx], rarg->u.value); 696 733 697 rarg_n = list_next(arg s, rarg_n);734 rarg_n = list_next(arg_vals, rarg_n); 698 735 idx += 1; 699 736 } … … 709 746 710 747 /* Declare variable using name of formal argument. */ 711 intmap_set(&block_ar->vars, fun->varg->name->sid,748 intmap_set(&block_ar->vars, varg->name->sid, 712 749 ref_var); 713 750 } … … 716 753 if (rarg_n != NULL) { 717 754 printf("Error: Too many arguments to function '"); 718 symbol_print_fqn(run->program, fun_ar->fun_sym);755 symbol_print_fqn(run->program, proc_ar->proc_sym); 719 756 printf("'.\n"); 720 757 exit(1); 721 758 } 759 } 760 761 /** Fill setter argument in a procedure AR. 762 * 763 * When invoking a setter this is used to store its argument value in its 764 * procedure activation record. 765 */ 766 void run_proc_ar_set_setter_arg(run_t *run, run_proc_ar_t *proc_ar, 767 rdata_item_t *arg_val) 768 { 769 stree_prop_t *prop; 770 run_block_ar_t *block_ar; 771 list_node_t *block_ar_n; 772 rdata_var_t *var; 773 774 (void) run; 775 776 /* AR should have been created with run_proc_ar_create(). */ 777 assert(proc_ar->proc_sym != NULL); 778 779 /* The procedure being activated should be a property setter. */ 780 prop = symbol_to_prop(proc_ar->proc_sym); 781 assert(prop != NULL); 782 783 /* Fetch first block activation record. */ 784 block_ar_n = list_first(&proc_ar->block_ar); 785 assert(block_ar_n != NULL); 786 block_ar = list_node_data(block_ar_n, run_block_ar_t *); 787 788 assert(arg_val->ic == ic_value); 789 790 /* Construct a variable from the argument value. */ 791 run_value_item_to_var(arg_val, &var); 792 793 /* Declare variable using name of formal argument. */ 794 intmap_set(&block_ar->vars, prop->setter_arg_name->sid, var); 722 795 } 723 796 … … 726 799 { 727 800 list_node_t *node; 728 run_ fun_ar_t *fun_ar;801 run_proc_ar_t *proc_ar; 729 802 730 803 printf("Backtrace:\n"); 731 node = list_last(&run->thread_ar-> fun_ar);804 node = list_last(&run->thread_ar->proc_ar); 732 805 while (node != NULL) { 733 806 printf(" * "); 734 fun_ar = list_node_data(node, run_fun_ar_t *);735 symbol_print_fqn(run->program, fun_ar->fun_sym);807 proc_ar = list_node_data(node, run_proc_ar_t *); 808 symbol_print_fqn(run->program, proc_ar->proc_sym); 736 809 printf("\n"); 737 810 738 node = list_prev(&run->thread_ar->fun_ar, node); 739 } 740 } 811 node = list_prev(&run->thread_ar->proc_ar, node); 812 } 813 } 814 815 /** Convert item to value item. 816 * 817 * If @a item is a value, we just return a copy. If @a item is an address, 818 * we read from the address. 819 */ 820 void run_cvt_value_item(run_t *run, rdata_item_t *item, rdata_item_t **ritem) 821 { 822 rdata_value_t *value; 823 824 /* 825 * This can happen when trying to use output of a function which 826 * does not return a value. 827 */ 828 if (item == NULL) { 829 printf("Error: Sub-expression has no value.\n"); 830 exit(1); 831 } 832 833 /* Address item. Perform read operation. */ 834 if (item->ic == ic_address) { 835 run_address_read(run, item->u.address, ritem); 836 return; 837 } 838 839 /* It already is a value, we can share the @c var. */ 840 value = rdata_value_new(); 841 value->var = item->u.value->var; 842 *ritem = rdata_item_new(ic_value); 843 (*ritem)->u.value = value; 844 } 845 846 847 /** Read data from an address. 848 * 849 * Return value stored in a variable at the specified address. 850 */ 851 void run_address_read(run_t *run, rdata_address_t *address, 852 rdata_item_t **ritem) 853 { 854 (void) run; 855 856 switch (address->ac) { 857 case ac_var: 858 rdata_var_read(address->u.var_a->vref, ritem); 859 break; 860 case ac_prop: 861 run_aprop_read(run, address->u.prop_a, ritem); 862 break; 863 } 864 865 assert((*ritem)->ic == ic_value); 866 } 867 868 /** Write data to an address. 869 * 870 * Store @a value to the variable at @a address. 871 */ 872 void run_address_write(run_t *run, rdata_address_t *address, 873 rdata_value_t *value) 874 { 875 (void) run; 876 877 switch (address->ac) { 878 case ac_var: 879 rdata_var_write(address->u.var_a->vref, value); 880 break; 881 case ac_prop: 882 run_aprop_write(run, address->u.prop_a, value); 883 break; 884 } 885 } 886 887 static void run_aprop_read(run_t *run, rdata_addr_prop_t *addr_prop, 888 rdata_item_t **ritem) 889 { 890 rdata_deleg_t *deleg; 891 rdata_var_t *obj; 892 stree_symbol_t *prop_sym; 893 stree_prop_t *prop; 894 895 run_proc_ar_t *proc_ar; 896 897 #ifdef DEBUG_RUN_TRACE 898 printf("Read from property.\n"); 899 #endif 900 /* 901 * If @c tvalue is present, we need to use the relevant part from that 902 * instead of re-reading the whole thing. 903 */ 904 if (addr_prop->tvalue != NULL) { 905 printf("Unimplemented: Property field access.\n"); 906 exit(1); 907 } 908 909 if (addr_prop->apc == apc_named) 910 deleg = addr_prop->u.named->prop_d; 911 else 912 deleg = addr_prop->u.indexed->object_d; 913 914 obj = deleg->obj; 915 prop_sym = deleg->sym; 916 prop = symbol_to_prop(prop_sym); 917 assert(prop != NULL); 918 919 if (prop->getter_body == NULL) { 920 printf("Error: Property is not readable.\n"); 921 exit(1); 922 } 923 924 /* Create procedure activation record. */ 925 run_proc_ar_create(run, obj, prop_sym, prop->getter_body, &proc_ar); 926 927 /* Fill in arguments (indices). */ 928 if (addr_prop->apc == apc_indexed) { 929 run_proc_ar_set_args(run, proc_ar, 930 &addr_prop->u.indexed->args); 931 } 932 933 /* Run getter. */ 934 run_proc(run, proc_ar, ritem); 935 936 #ifdef DEBUG_RUN_TRACE 937 printf("Getter returns "); 938 rdata_item_print(*ritem); 939 printf(".\n"); 940 printf("Done reading from property.\n"); 941 #endif 942 } 943 944 static void run_aprop_write(run_t *run, rdata_addr_prop_t *addr_prop, 945 rdata_value_t *value) 946 { 947 rdata_deleg_t *deleg; 948 rdata_var_t *obj; 949 stree_symbol_t *prop_sym; 950 stree_prop_t *prop; 951 952 run_proc_ar_t *proc_ar; 953 rdata_item_t *vitem; 954 rdata_item_t *ritem; 955 956 #ifdef DEBUG_RUN_TRACE 957 printf("Write to property.\n"); 958 #endif 959 /* If @c tvalue is present, we need to modify it and write it back. */ 960 if (addr_prop->tvalue != NULL) { 961 printf("Unimplemented: Read-modify-write property access.\n"); 962 exit(1); 963 } 964 965 if (addr_prop->apc == apc_named) 966 deleg = addr_prop->u.named->prop_d; 967 else 968 deleg = addr_prop->u.indexed->object_d; 969 970 obj = deleg->obj; 971 prop_sym = deleg->sym; 972 prop = symbol_to_prop(prop_sym); 973 assert(prop != NULL); 974 975 if (prop->setter_body == NULL) { 976 printf("Error: Property is not writable.\n"); 977 exit(1); 978 } 979 980 vitem = rdata_item_new(ic_value); 981 vitem->u.value = value; 982 983 /* Create procedure activation record. */ 984 run_proc_ar_create(run, obj, prop_sym, prop->setter_body, &proc_ar); 985 986 /* Fill in arguments (indices). */ 987 if (addr_prop->apc == apc_indexed) { 988 run_proc_ar_set_args(run, proc_ar, 989 &addr_prop->u.indexed->args); 990 } 991 992 /* Fill in value argument for setter. */ 993 run_proc_ar_set_setter_arg(run, proc_ar, vitem); 994 995 /* Run setter. */ 996 run_proc(run, proc_ar, &ritem); 997 998 /* Setter should not return a value. */ 999 assert(ritem == NULL); 1000 1001 #ifdef DEBUG_RUN_TRACE 1002 printf("Done writing to property.\n"); 1003 #endif 1004 } 1005 1006 /** Return reference to a variable. 1007 * 1008 * Constructs a reference (value item) pointing to @a var. 1009 */ 1010 void run_reference(run_t *run, rdata_var_t *var, rdata_item_t **res) 1011 { 1012 rdata_ref_t *ref; 1013 rdata_var_t *ref_var; 1014 rdata_value_t *ref_value; 1015 rdata_item_t *ref_item; 1016 1017 (void) run; 1018 1019 /* Create reference to the variable. */ 1020 ref = rdata_ref_new(); 1021 ref_var = rdata_var_new(vc_ref); 1022 ref->vref = var; 1023 ref_var->u.ref_v = ref; 1024 1025 /* Construct value of the reference to return. */ 1026 ref_item = rdata_item_new(ic_value); 1027 ref_value = rdata_value_new(); 1028 ref_item->u.value = ref_value; 1029 ref_value->var = ref_var; 1030 1031 *res = ref_item; 1032 } 1033 1034 /** Return address of reference target. 1035 * 1036 * Takes a reference (address or value) and returns the address (item) of 1037 * the target of the reference. 1038 */ 1039 void run_dereference(run_t *run, rdata_item_t *ref, rdata_item_t **ritem) 1040 { 1041 rdata_item_t *ref_val; 1042 rdata_item_t *item; 1043 rdata_address_t *address; 1044 rdata_addr_var_t *addr_var; 1045 1046 #ifdef DEBUG_RUN_TRACE 1047 printf("run_dereference()\n"); 1048 #endif 1049 run_cvt_value_item(run, ref, &ref_val); 1050 assert(ref_val->u.value->var->vc == vc_ref); 1051 1052 item = rdata_item_new(ic_address); 1053 address = rdata_address_new(ac_var); 1054 addr_var = rdata_addr_var_new(); 1055 item->u.address = address; 1056 address->u.var_a = addr_var; 1057 addr_var->vref = ref_val->u.value->var->u.ref_v->vref; 1058 1059 if (addr_var->vref == NULL) { 1060 printf("Error: Accessing null reference.\n"); 1061 exit(1); 1062 } 1063 1064 #ifdef DEBUG_RUN_TRACE 1065 printf("vref set to %p\n", addr_var->vref); 1066 #endif 1067 *ritem = item; 1068 } 1069 741 1070 742 1071 run_thread_ar_t *run_thread_ar_new(void) … … 753 1082 } 754 1083 755 run_ fun_ar_t *run_fun_ar_new(void)756 { 757 run_ fun_ar_t *fun_ar;758 759 fun_ar = calloc(1, sizeof(run_fun_ar_t));760 if ( fun_ar == NULL) {1084 run_proc_ar_t *run_proc_ar_new(void) 1085 { 1086 run_proc_ar_t *proc_ar; 1087 1088 proc_ar = calloc(1, sizeof(run_proc_ar_t)); 1089 if (proc_ar == NULL) { 761 1090 printf("Memory allocation failed.\n"); 762 1091 exit(1); 763 1092 } 764 1093 765 return fun_ar;1094 return proc_ar; 766 1095 } 767 1096 -
uspace/app/sbi/src/run.h
r94d484a rd0febca 34 34 void run_init(run_t *run); 35 35 void run_program(run_t *run, stree_program_t *prog); 36 void run_ fun(run_t *run, run_fun_ar_t *fun_ar, rdata_item_t **res);36 void run_proc(run_t *run, run_proc_ar_t *proc_ar, rdata_item_t **res); 37 37 38 38 void run_print_fun_bt(run_t *run); 39 39 40 40 rdata_var_t *run_local_vars_lookup(run_t *run, sid_t name); 41 run_ fun_ar_t *run_get_current_fun_ar(run_t *run);41 run_proc_ar_t *run_get_current_proc_ar(run_t *run); 42 42 run_block_ar_t *run_get_current_block_ar(run_t *run); 43 43 stree_csi_t *run_get_current_csi(run_t *run); 44 44 45 45 void run_value_item_to_var(rdata_item_t *item, rdata_var_t **var); 46 void run_fun_ar_set_args(run_t *run, run_fun_ar_t *fun_ar, list_t *args); 47 void run_fun_ar_create(run_t *run, rdata_var_t *obj, stree_fun_t *fun, 48 run_fun_ar_t **rfun_ar); 46 void run_proc_ar_set_args(run_t *run, run_proc_ar_t *proc_ar, 47 list_t *arg_vals); 48 void run_proc_ar_set_setter_arg(run_t *run, run_proc_ar_t *proc_ar, 49 rdata_item_t *arg_val); 50 void run_proc_ar_create(run_t *run, rdata_var_t *obj, stree_symbol_t *proc_sym, 51 stree_block_t *proc_block, run_proc_ar_t **rproc_ar); 52 53 void run_cvt_value_item(run_t *run, rdata_item_t *item, rdata_item_t **ritem); 54 void run_address_read(run_t *run, rdata_address_t *address, 55 rdata_item_t **ritem); 56 void run_address_write(run_t *run, rdata_address_t *address, 57 rdata_value_t *value); 58 void run_reference(run_t *run, rdata_var_t *var, rdata_item_t **res); 59 void run_dereference(run_t *run, rdata_item_t *ref, rdata_item_t **ritem); 49 60 50 61 run_thread_ar_t *run_thread_ar_new(void); 51 run_ fun_ar_t *run_fun_ar_new(void);62 run_proc_ar_t *run_proc_ar_new(void); 52 63 run_block_ar_t *run_block_ar_new(void); 53 64 -
uspace/app/sbi/src/run_expr.c
r94d484a rd0febca 41 41 #include "run_texpr.h" 42 42 #include "symbol.h" 43 #include "stree.h" 43 44 #include "strtab.h" 44 45 … … 87 88 static void run_call(run_t *run, stree_call_t *call, rdata_item_t **res); 88 89 static void run_index(run_t *run, stree_index_t *index, rdata_item_t **res); 90 static void run_index_array(run_t *run, stree_index_t *index, 91 rdata_item_t *base, list_t *args, rdata_item_t **res); 92 static void run_index_object(run_t *run, stree_index_t *index, 93 rdata_item_t *base, list_t *args, rdata_item_t **res); 94 static void run_index_string(run_t *run, stree_index_t *index, 95 rdata_item_t *base, list_t *args, rdata_item_t **res); 89 96 static void run_assign(run_t *run, stree_assign_t *assign, rdata_item_t **res); 90 97 … … 143 150 rdata_item_t *item; 144 151 rdata_address_t *address; 152 rdata_addr_var_t *addr_var; 145 153 rdata_value_t *value; 146 154 rdata_var_t *var; 147 155 rdata_deleg_t *deleg_v; 148 156 149 run_ fun_ar_t *fun_ar;157 run_proc_ar_t *proc_ar; 150 158 stree_symbol_t *csi_sym; 151 159 stree_csi_t *csi; … … 164 172 /* Found a local variable. */ 165 173 item = rdata_item_new(ic_address); 166 address = rdata_address_new(); 174 address = rdata_address_new(ac_var); 175 addr_var = rdata_addr_var_new(); 167 176 168 177 item->u.address = address; 169 address->vref = var; 178 address->u.var_a = addr_var; 179 addr_var->vref = var; 170 180 171 181 *res = item; … … 181 191 182 192 /* Determine currently active object or CSI. */ 183 fun_ar = run_get_current_fun_ar(run);184 if ( fun_ar->obj != NULL) {185 assert( fun_ar->obj->vc == vc_object);186 obj = fun_ar->obj->u.object_v;193 proc_ar = run_get_current_proc_ar(run); 194 if (proc_ar->obj != NULL) { 195 assert(proc_ar->obj->vc == vc_object); 196 obj = proc_ar->obj->u.object_v; 187 197 csi_sym = obj->class_sym; 188 198 csi = symbol_to_csi(csi_sym); 189 199 assert(csi != NULL); 190 200 } else { 191 csi = fun_ar->fun_sym->outer_csi;201 csi = proc_ar->proc_sym->outer_csi; 192 202 obj = NULL; 193 203 } … … 238 248 var->u.deleg_v = deleg_v; 239 249 240 deleg_v->obj = fun_ar->obj;250 deleg_v->obj = proc_ar->obj; 241 251 deleg_v->sym = sym; 242 252 … … 270 280 /* Return address of the variable. */ 271 281 item = rdata_item_new(ic_address); 272 address = rdata_address_new(); 282 address = rdata_address_new(ac_var); 283 addr_var = rdata_addr_var_new(); 273 284 274 285 item->u.address = address; 275 address->vref = member_var; 286 address->u.var_a = addr_var; 287 addr_var->vref = member_var; 276 288 277 289 *res = item; … … 393 405 rdata_item_t **res) 394 406 { 395 run_ fun_ar_t *fun_ar;407 run_proc_ar_t *proc_ar; 396 408 397 409 #ifdef DEBUG_RUN_TRACE … … 399 411 #endif 400 412 (void) self_ref; 401 fun_ar = run_get_current_fun_ar(run);413 proc_ar = run_get_current_proc_ar(run); 402 414 403 415 /* Return reference to the currently active object. */ 404 r data_reference(fun_ar->obj, res);416 run_reference(run, proc_ar->obj, res); 405 417 } 406 418 … … 438 450 #endif 439 451 440 r data_cvt_value_item(rarg1_i, &rarg1_vi);441 r data_cvt_value_item(rarg2_i, &rarg2_vi);452 run_cvt_value_item(run, rarg1_i, &rarg1_vi); 453 run_cvt_value_item(run, rarg2_i, &rarg2_vi); 442 454 443 455 v1 = rarg1_vi->u.value; … … 687 699 /* Evaluate extent argument. */ 688 700 run_expr(run, expr, &rexpr); 689 r data_cvt_value_item(rexpr, &rexpr_vi);701 run_cvt_value_item(run, rexpr, &rexpr_vi); 690 702 assert(rexpr_vi->ic == ic_value); 691 703 rexpr_var = rexpr_vi->u.value->var; … … 727 739 728 740 /* Create reference to the new array. */ 729 r data_reference(array_var, res);741 run_reference(run, array_var, res); 730 742 } 731 743 … … 782 794 783 795 /* Create reference to the new object. */ 784 r data_reference(obj_var, res);796 run_reference(run, obj_var, res); 785 797 } 786 798 … … 811 823 printf("Run access operation on pre-evaluated base.\n"); 812 824 #endif 813 switch (arg->ic) { 814 case ic_value: 815 vc = arg->u.value->var->vc; 816 break; 817 case ic_address: 818 vc = arg->u.address->vref->vc; 819 break; 820 default: 821 /* Silence warning. */ 822 abort(); 823 } 825 vc = rdata_item_get_vc(arg); 824 826 825 827 switch (vc) { … … 847 849 848 850 /* Implicitly dereference. */ 849 r data_dereference(arg, &darg);851 run_dereference(run, arg, &darg); 850 852 851 853 /* Try again. */ … … 865 867 printf("Run delegate access operation.\n"); 866 868 #endif 867 r data_cvt_value_item(arg, &arg_vi);869 run_cvt_value_item(run, arg, &arg_vi); 868 870 arg_val = arg_vi->u.value; 869 871 assert(arg_val->var->vc == vc_deleg); … … 906 908 { 907 909 stree_symbol_t *member; 910 rdata_var_t *object_var; 908 911 rdata_object_t *object; 909 912 rdata_item_t *ritem; 910 913 rdata_address_t *address; 914 rdata_addr_var_t *addr_var; 915 rdata_addr_prop_t *addr_prop; 916 rdata_aprop_named_t *aprop_named; 917 rdata_deleg_t *deleg_p; 911 918 912 919 rdata_value_t *value; … … 918 925 #endif 919 926 assert(arg->ic == ic_address); 920 assert(arg->u.value->var->vc == vc_object); 921 922 object = arg->u.value->var->u.object_v; 927 assert(arg->u.address->ac == ac_var); 928 assert(arg->u.address->u.var_a->vref->vc == vc_object); 929 930 object_var = arg->u.address->u.var_a->vref; 931 object = object_var->u.object_v; 923 932 924 933 member = symbol_search_csi(run->program, object->class_sym->u.csi, … … 953 962 var->u.deleg_v = deleg_v; 954 963 955 deleg_v->obj = arg->u. value->var;964 deleg_v->obj = arg->u.address->u.var_a->vref; 956 965 deleg_v->sym = member; 957 966 break; … … 959 968 /* Construct variable address item. */ 960 969 ritem = rdata_item_new(ic_address); 961 address = rdata_address_new(); 970 address = rdata_address_new(ac_var); 971 addr_var = rdata_addr_var_new(); 962 972 ritem->u.address = address; 963 964 address->vref = intmap_get(&object->fields, 973 address->u.var_a = addr_var; 974 975 addr_var->vref = intmap_get(&object->fields, 965 976 access->member_name->sid); 966 assert(addr ess->vref != NULL);977 assert(addr_var->vref != NULL); 967 978 break; 968 979 case sc_prop: 969 printf("Unimplemented: Accessing object property.\n"); 970 exit(1); 980 /* Construct named property address. */ 981 ritem = rdata_item_new(ic_address); 982 address = rdata_address_new(ac_prop); 983 addr_prop = rdata_addr_prop_new(apc_named); 984 aprop_named = rdata_aprop_named_new(); 985 ritem->u.address = address; 986 address->u.prop_a = addr_prop; 987 addr_prop->u.named = aprop_named; 988 989 deleg_p = rdata_deleg_new(); 990 deleg_p->obj = object_var; 991 deleg_p->sym = member; 992 addr_prop->u.named->prop_d = deleg_p; 993 break; 971 994 } 972 995 … … 985 1008 986 1009 stree_fun_t *fun; 987 run_ fun_ar_t *fun_ar;1010 run_proc_ar_t *proc_ar; 988 1011 989 1012 #ifdef DEBUG_RUN_TRACE … … 1017 1040 arg = list_node_data(node, stree_expr_t *); 1018 1041 run_expr(run, arg, &rarg_i); 1019 r data_cvt_value_item(rarg_i, &rarg_vi);1042 run_cvt_value_item(run, rarg_i, &rarg_vi); 1020 1043 1021 1044 list_append(&arg_vals, rarg_vi); … … 1026 1049 assert(fun != NULL); 1027 1050 1028 /* Create function activation record. */ 1029 run_fun_ar_create(run, deleg_v->obj, fun, &fun_ar); 1051 /* Create procedure activation record. */ 1052 run_proc_ar_create(run, deleg_v->obj, deleg_v->sym, fun->body, 1053 &proc_ar); 1030 1054 1031 1055 /* Fill in argument values. */ 1032 run_ fun_ar_set_args(run, fun_ar, &arg_vals);1056 run_proc_ar_set_args(run, proc_ar, &arg_vals); 1033 1057 1034 1058 /* Run the function. */ 1035 run_ fun(run, fun_ar, res);1059 run_proc(run, proc_ar, res); 1036 1060 1037 1061 #ifdef DEBUG_RUN_TRACE … … 1048 1072 stree_expr_t *arg; 1049 1073 rdata_item_t *rarg_i, *rarg_vi; 1074 var_class_t vc; 1075 list_t arg_vals; 1076 1077 #ifdef DEBUG_RUN_TRACE 1078 printf("Run index operation.\n"); 1079 #endif 1080 run_expr(run, index->base, &rbase); 1081 1082 vc = rdata_item_get_vc(rbase); 1083 1084 /* Implicitly dereference. */ 1085 if (vc == vc_ref) { 1086 run_dereference(run, rbase, &base_i); 1087 } else { 1088 base_i = rbase; 1089 } 1090 1091 vc = rdata_item_get_vc(base_i); 1092 1093 /* Evaluate arguments (indices). */ 1094 node = list_first(&index->args); 1095 list_init(&arg_vals); 1096 1097 while (node != NULL) { 1098 arg = list_node_data(node, stree_expr_t *); 1099 run_expr(run, arg, &rarg_i); 1100 run_cvt_value_item(run, rarg_i, &rarg_vi); 1101 1102 list_append(&arg_vals, rarg_vi); 1103 1104 node = list_next(&index->args, node); 1105 } 1106 1107 switch (vc) { 1108 case vc_array: 1109 run_index_array(run, index, base_i, &arg_vals, res); 1110 break; 1111 case vc_object: 1112 run_index_object(run, index, base_i, &arg_vals, res); 1113 break; 1114 case vc_string: 1115 run_index_string(run, index, base_i, &arg_vals, res); 1116 break; 1117 default: 1118 printf("Error: Indexing object of bad type (%d).\n", vc); 1119 exit(1); 1120 } 1121 } 1122 1123 /** Run index operation on array. */ 1124 static void run_index_array(run_t *run, stree_index_t *index, 1125 rdata_item_t *base, list_t *args, rdata_item_t **res) 1126 { 1127 list_node_t *node; 1050 1128 rdata_array_t *array; 1051 var_class_t vc;1129 rdata_item_t *arg; 1052 1130 1053 1131 int i; … … 1057 1135 rdata_item_t *ritem; 1058 1136 rdata_address_t *address; 1059 1060 #ifdef DEBUG_RUN_TRACE 1061 printf("Run index operation.\n"); 1062 #endif 1063 run_expr(run, index->base, &rbase); 1064 1065 switch (rbase->ic) { 1066 case ic_value: 1067 vc = rbase->u.value->var->vc; 1068 break; 1069 case ic_address: 1070 vc = rbase->u.address->vref->vc; 1071 break; 1072 default: 1073 /* Silence warning. */ 1074 abort(); 1075 } 1076 1077 if (vc != vc_ref) { 1078 printf("Error: Base of index operation is not a reference.\n"); 1079 exit(1); 1080 } 1081 1082 rdata_dereference(rbase, &base_i); 1083 assert(base_i->ic == ic_address); 1084 1085 if (base_i->u.value->var->vc != vc_array) { 1086 printf("Error: Indexing something which is not an array.\n"); 1087 exit(1); 1088 } 1089 1090 array = base_i->u.value->var->u.array_v; 1091 1092 /* Evaluate arguments (indices). */ 1093 node = list_first(&index->args); 1137 rdata_addr_var_t *addr_var; 1138 1139 #ifdef DEBUG_RUN_TRACE 1140 printf("Run array index operation.\n"); 1141 #endif 1142 (void) run; 1143 (void) index; 1144 1145 assert(base->ic == ic_address); 1146 assert(base->u.address->ac == ac_var); 1147 assert(base->u.address->u.var_a->vref->vc == vc_array); 1148 array = base->u.address->u.var_a->vref->u.array_v; 1094 1149 1095 1150 /* … … 1099 1154 elem_index = 0; 1100 1155 1156 node = list_first(args); 1101 1157 i = 0; 1158 1102 1159 while (node != NULL) { 1103 1160 if (i >= array->rank) { … … 1107 1164 } 1108 1165 1109 arg = list_node_data(node, stree_expr_t *); 1110 run_expr(run, arg, &rarg_i); 1111 rdata_cvt_value_item(rarg_i, &rarg_vi); 1112 assert(rarg_vi->ic == ic_value); 1113 1114 if (rarg_vi->u.value->var->vc != vc_int) { 1166 arg = list_node_data(node, rdata_item_t *); 1167 assert(arg->ic == ic_value); 1168 1169 if (arg->u.value->var->vc != vc_int) { 1115 1170 printf("Error: Array index is not an integer.\n"); 1116 1171 exit(1); 1117 1172 } 1118 1173 1119 arg_val = rarg_vi->u.value->var->u.int_v->value;1174 arg_val = arg->u.value->var->u.int_v->value; 1120 1175 1121 1176 if (arg_val < 0 || arg_val >= array->extent[i]) { … … 1127 1182 elem_index = elem_index * array->extent[i] + arg_val; 1128 1183 1129 node = list_next( &index->args, node);1184 node = list_next(args, node); 1130 1185 i += 1; 1131 1186 } … … 1139 1194 /* Construct variable address item. */ 1140 1195 ritem = rdata_item_new(ic_address); 1141 address = rdata_address_new(); 1196 address = rdata_address_new(ac_var); 1197 addr_var = rdata_addr_var_new(); 1142 1198 ritem->u.address = address; 1143 1144 address->vref = array->element[elem_index]; 1199 address->u.var_a = addr_var; 1200 1201 addr_var->vref = array->element[elem_index]; 1145 1202 1146 1203 *res = ritem; 1147 1204 } 1205 1206 /** Index an object (via its indexer). */ 1207 static void run_index_object(run_t *run, stree_index_t *index, 1208 rdata_item_t *base, list_t *args, rdata_item_t **res) 1209 { 1210 rdata_item_t *ritem; 1211 rdata_address_t *address; 1212 rdata_addr_prop_t *addr_prop; 1213 rdata_aprop_indexed_t *aprop_indexed; 1214 rdata_var_t *obj_var; 1215 stree_csi_t *obj_csi; 1216 rdata_deleg_t *object_d; 1217 stree_symbol_t *indexer_sym; 1218 stree_ident_t *indexer_ident; 1219 1220 list_node_t *node; 1221 rdata_item_t *arg; 1222 1223 #ifdef DEBUG_RUN_TRACE 1224 printf("Run object index operation.\n"); 1225 #endif 1226 (void) run; 1227 (void) index; 1228 1229 /* Construct property address item. */ 1230 ritem = rdata_item_new(ic_address); 1231 address = rdata_address_new(ac_prop); 1232 addr_prop = rdata_addr_prop_new(apc_indexed); 1233 aprop_indexed = rdata_aprop_indexed_new(); 1234 ritem->u.address = address; 1235 address->u.prop_a = addr_prop; 1236 addr_prop->u.indexed = aprop_indexed; 1237 1238 if (base->ic != ic_address || base->u.address->ac != ac_var) { 1239 /* XXX Several other cases can occur. */ 1240 printf("Unimplemented: Indexing object varclass via something " 1241 "which is not a simple variable reference.\n"); 1242 exit(1); 1243 } 1244 1245 /* Find indexer symbol. */ 1246 obj_var = base->u.address->u.var_a->vref; 1247 assert(obj_var->vc == vc_object); 1248 indexer_ident = stree_ident_new(); 1249 indexer_ident->sid = strtab_get_sid(INDEXER_IDENT); 1250 obj_csi = symbol_to_csi(obj_var->u.object_v->class_sym); 1251 assert(obj_csi != NULL); 1252 indexer_sym = symbol_search_csi(run->program, obj_csi, indexer_ident); 1253 1254 /* Construct delegate. */ 1255 object_d = rdata_deleg_new(); 1256 object_d->obj = obj_var; 1257 object_d->sym = indexer_sym; 1258 aprop_indexed->object_d = object_d; 1259 1260 /* Copy list of argument values. */ 1261 list_init(&aprop_indexed->args); 1262 1263 node = list_first(args); 1264 while (node != NULL) { 1265 arg = list_node_data(node, rdata_item_t *); 1266 list_append(&aprop_indexed->args, arg); 1267 node = list_next(args, node); 1268 } 1269 1270 *res = ritem; 1271 } 1272 1273 /** Run index operation on string. */ 1274 static void run_index_string(run_t *run, stree_index_t *index, 1275 rdata_item_t *base, list_t *args, rdata_item_t **res) 1276 { 1277 list_node_t *node; 1278 rdata_string_t *string; 1279 rdata_item_t *base_vi; 1280 rdata_item_t *arg; 1281 1282 int i; 1283 int elem_index; 1284 int arg_val; 1285 int rc; 1286 1287 rdata_value_t *value; 1288 rdata_var_t *cvar; 1289 rdata_item_t *ritem; 1290 int cval; 1291 1292 #ifdef DEBUG_RUN_TRACE 1293 printf("Run string index operation.\n"); 1294 #endif 1295 (void) run; 1296 (void) index; 1297 1298 run_cvt_value_item(run, base, &base_vi); 1299 assert(base_vi->u.value->var->vc == vc_string); 1300 string = base->u.value->var->u.string_v; 1301 1302 /* 1303 * Linear index of the desired element. Elements are stored in 1304 * lexicographic order with the last index changing the fastest. 1305 */ 1306 node = list_first(args); 1307 elem_index = 0; 1308 1309 i = 0; 1310 while (node != NULL) { 1311 if (i >= 1) { 1312 printf("Error: Too many indices string.\n"); 1313 exit(1); 1314 } 1315 1316 arg = list_node_data(node, rdata_item_t *); 1317 assert(arg->ic == ic_value); 1318 1319 if (arg->u.value->var->vc != vc_int) { 1320 printf("Error: String index is not an integer.\n"); 1321 exit(1); 1322 } 1323 1324 arg_val = arg->u.value->var->u.int_v->value; 1325 elem_index = arg_val; 1326 1327 node = list_next(args, node); 1328 i += 1; 1329 } 1330 1331 if (i < 1) { 1332 printf("Error: Too few indices for string.\n"); 1333 exit(1); 1334 } 1335 1336 rc = os_str_get_char(string->value, elem_index, &cval); 1337 if (rc != EOK) { 1338 printf("Error: String index (value: %d) is out of range.\n", 1339 arg_val); 1340 exit(1); 1341 } 1342 1343 /* Construct character value. */ 1344 ritem = rdata_item_new(ic_value); 1345 value = rdata_value_new(); 1346 ritem->u.value = value; 1347 1348 cvar = rdata_var_new(vc_int); 1349 cvar->u.int_v = rdata_int_new(); 1350 cvar->u.int_v->value = cval; 1351 value->var = cvar; 1352 1353 *res = ritem; 1354 } 1355 1148 1356 1149 1357 /** Execute assignment. */ … … 1160 1368 run_expr(run, assign->src, &rsrc_i); 1161 1369 1162 rdata_cvt_value_item(rsrc_i, &rsrc_vi); 1370 run_cvt_value_item(run, rsrc_i, &rsrc_vi); 1371 assert(rsrc_vi->ic == ic_value); 1163 1372 src_val = rsrc_vi->u.value; 1164 1373 … … 1169 1378 } 1170 1379 1171 r data_address_write(rdest_i->u.address, rsrc_vi->u.value);1380 run_address_write(run, rdest_i->u.address, rsrc_vi->u.value); 1172 1381 1173 1382 *res = NULL; … … 1187 1396 1188 1397 (void) run; 1189 r data_cvt_value_item(item, &vitem);1398 run_cvt_value_item(run, item, &vitem); 1190 1399 1191 1400 assert(vitem->ic == ic_value); -
uspace/app/sbi/src/run_t.h
r94d484a rd0febca 44 44 45 45 46 /** Functionactivation record46 /** Procedure activation record 47 47 * 48 * One is created whenever a function is invoked. 48 * A procedure can be a member function, a named property or an indexed 49 * property. A procedure activation record is created whenever a procedure 50 * is invoked. 49 51 */ 50 typedef struct run_ fun_ar {51 /** Object on which the member functionis being invoked or @c NULL. */52 typedef struct run_proc_ar { 53 /** Object on which the procedure is being invoked or @c NULL. */ 52 54 struct rdata_var *obj; 53 55 54 /** Definition of function being invoked */ 55 struct stree_symbol *fun_sym; 56 /** Definition of function or property being invoked */ 57 struct stree_symbol *proc_sym; 58 59 /** Main block of procedure being invoked */ 60 struct stree_block *proc_block; 56 61 57 62 /** Block activation records */ 58 63 list_t block_ar; /* of run_block_ar_t */ 59 64 60 /** Functionreturn value or @c NULL if not set. */65 /** Procedure return value or @c NULL if not set. */ 61 66 struct rdata_item *retval; 62 } run_ fun_ar_t;67 } run_proc_ar_t; 63 68 64 69 /** Bailout mode … … 73 78 bm_stat, 74 79 75 /** Return from function*/76 bm_ fun,80 /** Return from procedure */ 81 bm_proc, 77 82 78 83 /** Exception */ … … 86 91 typedef struct run_thread_ar { 87 92 /** Function activation records */ 88 list_t fun_ar; /* of run_fun_ar_t */93 list_t proc_ar; /* of run_proc_ar_t */ 89 94 90 95 /** Bailout mode */ -
uspace/app/sbi/src/stree.c
r94d484a rd0febca 136 136 } 137 137 138 stree_ fun_arg_t *stree_fun_arg_new(void)139 { 140 stree_ fun_arg_t *fun_arg;141 142 fun_arg = calloc(1, sizeof(stree_fun_arg_t));143 if ( fun_arg == NULL) {144 printf("Memory allocation failed.\n"); 145 exit(1); 146 } 147 148 return fun_arg;138 stree_proc_arg_t *stree_proc_arg_new(void) 139 { 140 stree_proc_arg_t *proc_arg; 141 142 proc_arg = calloc(1, sizeof(stree_proc_arg_t)); 143 if (proc_arg == NULL) { 144 printf("Memory allocation failed.\n"); 145 exit(1); 146 } 147 148 return proc_arg; 149 149 } 150 150 … … 561 561 562 562 /** Determine if argument @a arg has attribute of class @a aac. */ 563 bool_t stree_arg_has_attr(stree_ fun_arg_t *arg, arg_attr_class_t aac)563 bool_t stree_arg_has_attr(stree_proc_arg_t *arg, arg_attr_class_t aac) 564 564 { 565 565 list_node_t *node; -
uspace/app/sbi/src/stree.h
r94d484a rd0febca 40 40 stree_prop_t *stree_prop_new(void); 41 41 42 stree_ fun_arg_t *stree_fun_arg_new(void);42 stree_proc_arg_t *stree_proc_arg_new(void); 43 43 stree_arg_attr_t *stree_arg_attr_new(arg_attr_class_t aac); 44 44 … … 79 79 stree_program_t *stree_program_new(void); 80 80 81 bool_t stree_arg_has_attr(stree_ fun_arg_t *arg, arg_attr_class_t aac);81 bool_t stree_arg_has_attr(stree_proc_arg_t *arg, arg_attr_class_t aac); 82 82 bool_t stree_is_csi_derived_from_csi(stree_csi_t *a, stree_csi_t *b); 83 83 -
uspace/app/sbi/src/stree_t.h
r94d484a rd0febca 270 270 271 271 /** Statement block */ 272 typedef struct {272 typedef struct stree_block { 273 273 /** List of statements in the block */ 274 274 list_t stats; /* of stree_stat_t */ … … 327 327 stree_block_t *finally_block; 328 328 } stree_wef_t; 329 330 329 331 330 /** Statement class */ … … 378 377 /* Attributes */ 379 378 list_t attr; /* of stree_arg_attr_t */ 380 } stree_ fun_arg_t;379 } stree_proc_arg_t; 381 380 382 381 /** Member function declaration */ … … 389 388 390 389 /** Formal parameters */ 391 list_t args; /* of stree_ fun_arg_t */390 list_t args; /* of stree_proc_arg_t */ 392 391 393 392 /** Variadic argument or @c NULL if none. */ 394 stree_ fun_arg_t *varg;393 stree_proc_arg_t *varg; 395 394 396 395 /** Return type */ … … 413 412 struct stree_symbol *symbol; 414 413 stree_texpr_t *type; 414 415 stree_block_t *getter_body; 416 stree_ident_t *setter_arg_name; 417 stree_block_t *setter_body; 418 419 /** Formal parameters (for indexed properties) */ 420 list_t args; /* of stree_proc_arg_t */ 421 422 /** Variadic argument or @c NULL if none. */ 423 stree_proc_arg_t *varg; 415 424 } stree_prop_t; 425 426 /** 427 * Fake identifier used with indexed properties. (Mostly for error messages.) 428 */ 429 #define INDEXER_IDENT "$indexer" 416 430 417 431 typedef enum { -
uspace/app/sbi/src/strtab.c
r94d484a rd0febca 49 49 } 50 50 51 sid_t strtab_get_sid(c har *str)51 sid_t strtab_get_sid(const char *str) 52 52 { 53 53 list_node_t *node; -
uspace/app/sbi/src/strtab.h
r94d484a rd0febca 33 33 34 34 void strtab_init(void); 35 sid_t strtab_get_sid(c har *str);35 sid_t strtab_get_sid(const char *str); 36 36 char *strtab_get_str(sid_t sid); 37 37
Note:
See TracChangeset
for help on using the changeset viewer.