Changeset d0febca in mainline for uspace/app/sbi/src/run.c
- Timestamp:
- 2010-03-13T12:04:37Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7715994
- Parents:
- 94d484a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.