Changeset 640ffe6 in mainline for uspace/app/sbi/src/run_expr.c


Ignore:
Timestamp:
2010-05-08T08:15:57Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4039c77
Parents:
1317380 (diff), 051bc69a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~jsvoboda/helenos/sysel. New: cspan printing, boolean ops, enums, constructors etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/sbi/src/run_expr.c

    r1317380 r640ffe6  
    7878static void run_binop_ref(run_t *run, stree_binop_t *binop, rdata_value_t *v1,
    7979    rdata_value_t *v2, rdata_item_t **res);
     80static void run_binop_enum(run_t *run, stree_binop_t *binop, rdata_value_t *v1,
     81    rdata_value_t *v2, rdata_item_t **res);
    8082
    8183static void run_unop(run_t *run, stree_unop_t *unop, rdata_item_t **res);
     84static void run_unop_bool(run_t *run, stree_unop_t *unop, rdata_value_t *val,
     85    rdata_item_t **res);
    8286static void run_unop_int(run_t *run, stree_unop_t *unop, rdata_value_t *val,
    8387    rdata_item_t **res);
     
    8892static void run_new_object(run_t *run, stree_new_t *new_op,
    8993    tdata_item_t *titem, rdata_item_t **res);
     94
     95static void run_object_ctor(run_t *run, rdata_var_t *obj, list_t *arg_vals);
    9096
    9197static void run_access(run_t *run, stree_access_t *access, rdata_item_t **res);
     
    98104static void run_access_object(run_t *run, stree_access_t *access,
    99105    rdata_item_t *arg, rdata_item_t **res);
     106static void run_access_symbol(run_t *run, stree_access_t *access,
     107    rdata_item_t *arg, rdata_item_t **res);
    100108
    101109static void run_call(run_t *run, stree_call_t *call, rdata_item_t **res);
     110static void run_call_args(run_t *run, list_t *args, list_t *arg_vals);
     111
    102112static void run_index(run_t *run, stree_index_t *index, rdata_item_t **res);
    103113static void run_index_array(run_t *run, stree_index_t *index,
     
    189199        rdata_var_t *var;
    190200        rdata_deleg_t *deleg_v;
     201        rdata_symbol_t *symbol_v;
    191202
    192203        run_proc_ar_t *proc_ar;
     
    246257        case sc_csi:
    247258#ifdef DEBUG_RUN_TRACE
    248                 printf("Referencing class.\n");
     259                printf("Referencing CSI.\n");
    249260#endif
    250261                item = rdata_item_new(ic_value);
     
    260271                deleg_v->sym = sym;
    261272                *res = item;
     273                break;
     274        case sc_ctor:
     275                /* It is not possible to reference a constructor explicitly. */
     276                assert(b_false);
     277        case sc_enum:
     278#ifdef DEBUG_RUN_TRACE
     279                printf("Referencing enum.\n");
     280#endif
     281                item = rdata_item_new(ic_value);
     282                value = rdata_value_new();
     283                var = rdata_var_new(vc_symbol);
     284                symbol_v = rdata_symbol_new();
     285
     286                item->u.value = value;
     287                value->var = var;
     288                var->u.symbol_v = symbol_v;
     289
     290                symbol_v->sym = sym;
     291                *res = item;
     292                break;
     293        case sc_deleg:
     294                /* XXX TODO */
     295                printf("Unimplemented: Delegate name reference.\n");
     296                abort();
    262297                break;
    263298        case sc_fun:
     
    329364                *res = item;
    330365                break;
    331         default:
    332                 printf("Referencing symbol class %d unimplemented.\n", sym->sc);
    333                 *res = NULL;
     366        case sc_prop:
     367                /* XXX TODO */
     368                printf("Unimplemented: Property name reference.\n");
     369                abort();
    334370                break;
    335371        }
     
    571607        }
    572608
    573         switch (binop->bc) {
    574         case bo_plus:
    575         case bo_minus:
    576         case bo_mult:
    577         case bo_equal:
    578         case bo_notequal:
    579         case bo_lt:
    580         case bo_gt:
    581         case bo_lt_equal:
    582         case bo_gt_equal:
    583                 /* These are implemented so far. */
    584                 break;
    585         default:
    586                 printf("Unimplemented: Binary operation type %d.\n",
    587                     binop->bc);
    588                 exit(1);
    589         }
    590 
    591609#ifdef DEBUG_RUN_TRACE
    592610        printf("Check binop argument results.\n");
     
    621639                run_binop_ref(run, binop, v1, v2, res);
    622640                break;
     641        case vc_enum:
     642                run_binop_enum(run, binop, v1, v2, res);
     643                break;
    623644        case vc_deleg:
    624645        case vc_array:
    625646        case vc_object:
    626647        case vc_resource:
     648        case vc_symbol:
    627649                assert(b_false);
    628650        }
     
    685707                bool_v->value = (b1 == b_true) || (b2 == b_false);
    686708                break;
     709
     710        case bo_and:
     711                bool_v->value = (b1 == b_true) && (b2 == b_true);
     712                break;
     713        case bo_or:
     714                bool_v->value = (b1 == b_true) || (b2 == b_true);
     715                break;
    687716        }
    688717
     
    753782                bool_v->value = !nf;
    754783                break;
    755         default:
     784
     785        case bo_and:
     786        case bo_or:
    756787                assert(b_false);
    757788        }
     
    832863
    833864        switch (binop->bc) {
     865        case bo_plus:
     866        case bo_minus:
     867        case bo_mult:
     868                assert(b_false);
     869
    834870        case bo_equal:
    835871                bool_v->value = zf;
     
    850886                bool_v->value = !nf;
    851887                break;
    852         default:
     888        case bo_and:
     889        case bo_or:
    853890                assert(b_false);
    854891        }
     
    872909        rdata_var_t *var;
    873910        rdata_string_t *string_v;
     911        rdata_bool_t *bool_v;
     912        bool_t done;
     913        bool_t zf;
    874914
    875915        const char *s1, *s2;
     
    879919        item = rdata_item_new(ic_value);
    880920        value = rdata_value_new();
    881         var = rdata_var_new(vc_string);
    882         string_v = rdata_string_new();
    883921
    884922        item->u.value = value;
    885         value->var = var;
    886         var->u.string_v = string_v;
    887923
    888924        s1 = v1->var->u.string_v->value;
    889925        s2 = v2->var->u.string_v->value;
     926
     927        done = b_true;
    890928
    891929        switch (binop->bc) {
    892930        case bo_plus:
    893931                /* Concatenate strings. */
     932                string_v = rdata_string_new();
    894933                string_v->value = os_str_acat(s1, s2);
     934                break;
     935        default:
     936                done = b_false;
     937                break;
     938        }
     939
     940        if (done) {
     941                var = rdata_var_new(vc_string);
     942                var->u.string_v = string_v;
     943                value->var = var;
     944                *res = item;
     945                return;
     946        }
     947
     948        var = rdata_var_new(vc_bool);
     949        bool_v = rdata_bool_new();
     950        var->u.bool_v = bool_v;
     951        value->var = var;
     952
     953        /* Relational operation. */
     954
     955        zf = os_str_cmp(s1, s2) == 0;
     956
     957        switch (binop->bc) {
     958        case bo_equal:
     959                bool_v->value = zf;
     960                break;
     961        case bo_notequal:
     962                bool_v->value = !zf;
    895963                break;
    896964        default:
     
    9511019}
    9521020
     1021/** Evaluate binary operation on enum arguments.
     1022 *
     1023 * @param run           Runner object
     1024 * @param binop         Binary operation
     1025 * @param v1            Value of first argument
     1026 * @param v2            Value of second argument
     1027 * @param res           Place to store result
     1028 */
     1029static void run_binop_enum(run_t *run, stree_binop_t *binop, rdata_value_t *v1,
     1030    rdata_value_t *v2, rdata_item_t **res)
     1031{
     1032        rdata_item_t *item;
     1033        rdata_value_t *value;
     1034        rdata_var_t *var;
     1035        rdata_bool_t *bool_v;
     1036
     1037        rdata_var_t *ref1, *ref2;
     1038
     1039        (void) run;
     1040
     1041        item = rdata_item_new(ic_value);
     1042        value = rdata_value_new();
     1043        var = rdata_var_new(vc_bool);
     1044        bool_v = rdata_bool_new();
     1045
     1046        item->u.value = value;
     1047        value->var = var;
     1048        var->u.bool_v = bool_v;
     1049
     1050        ref1 = v1->var->u.ref_v->vref;
     1051        ref2 = v2->var->u.ref_v->vref;
     1052
     1053        switch (binop->bc) {
     1054        case bo_equal:
     1055                bool_v->value = (ref1 == ref2);
     1056                break;
     1057        case bo_notequal:
     1058                bool_v->value = (ref1 != ref2);
     1059                break;
     1060        default:
     1061                /* Should have been caught by static typing. */
     1062                assert(b_false);
     1063        }
     1064
     1065        *res = item;
     1066}
    9531067
    9541068/** Evaluate unary operation.
     
    9811095
    9821096        switch (val->var->vc) {
     1097        case vc_bool:
     1098                run_unop_bool(run, unop, val, res);
     1099                break;
    9831100        case vc_int:
    9841101                run_unop_int(run, unop, val, res);
     
    9931110}
    9941111
     1112/** Evaluate unary operation on bool argument.
     1113 *
     1114 * @param run           Runner object
     1115 * @param unop          Unary operation
     1116 * @param val           Value of argument
     1117 * @param res           Place to store result
     1118 */
     1119static void run_unop_bool(run_t *run, stree_unop_t *unop, rdata_value_t *val,
     1120    rdata_item_t **res)
     1121{
     1122        rdata_item_t *item;
     1123        rdata_value_t *value;
     1124        rdata_var_t *var;
     1125        rdata_bool_t *bool_v;
     1126
     1127        (void) run;
     1128
     1129        item = rdata_item_new(ic_value);
     1130        value = rdata_value_new();
     1131        var = rdata_var_new(vc_bool);
     1132        bool_v = rdata_bool_new();
     1133
     1134        item->u.value = value;
     1135        value->var = var;
     1136        var->u.bool_v = bool_v;
     1137
     1138        switch (unop->uc) {
     1139        case uo_plus:
     1140        case uo_minus:
     1141                assert(b_false);
     1142
     1143        case uo_not:
     1144                bool_v->value = !val->var->u.bool_v->value;
     1145                break;
     1146        }
     1147
     1148        *res = item;
     1149}
     1150
    9951151/** Evaluate unary operation on int argument.
    9961152 *
     
    10271183                    &int_v->value);
    10281184                break;
     1185        case uo_not:
     1186                assert(b_false);
    10291187        }
    10301188
    10311189        *res = item;
    10321190}
    1033 
    10341191
    10351192/** Evaluate @c new operation.
     
    11861343{
    11871344        stree_csi_t *csi;
     1345        rdata_item_t *obj_i;
     1346        list_t arg_vals;
    11881347
    11891348#ifdef DEBUG_RUN_TRACE
    11901349        printf("Create new object.\n");
    11911350#endif
    1192         (void) new_op;
    1193 
    11941351        /* Lookup object CSI. */
    11951352        assert(titem->tic == tic_tobject);
    11961353        csi = titem->u.tobject->csi;
    11971354
     1355        /* Evaluate constructor arguments. */
     1356        run_call_args(run, &new_op->ctor_args, &arg_vals);
     1357        if (run_is_bo(run)) {
     1358                *res = NULL;
     1359                return;
     1360        }
     1361
    11981362        /* Create CSI instance. */
    11991363        run_new_csi_inst(run, csi, res);
     1364
     1365        /* Run the constructor. */
     1366        run_dereference(run, *res, NULL, &obj_i);
     1367        assert(obj_i->ic == ic_address);
     1368        assert(obj_i->u.address->ac == ac_var);
     1369        run_object_ctor(run, obj_i->u.address->u.var_a->vref, &arg_vals);
    12001370}
    12011371
     
    12561426                run_access_object(run, access, arg, res);
    12571427                break;
    1258         default:
     1428        case vc_symbol:
     1429                run_access_symbol(run, access, arg, res);
     1430                break;
     1431
     1432        case vc_bool:
     1433        case vc_char:
     1434        case vc_enum:
     1435        case vc_int:
     1436        case vc_string:
     1437        case vc_array:
     1438        case vc_resource:
    12591439                printf("Unimplemented: Using access operator ('.') "
    12601440                    "with unsupported data type (value/%d).\n", vc);
     
    12761456
    12771457        /* Implicitly dereference. */
    1278         run_dereference(run, arg, &darg);
     1458        run_dereference(run, arg, access->arg->cspan, &darg);
    12791459
    12801460        if (run->thread_ar->bo_mode != bm_none) {
     
    13961576                printf("Error: Accessing object member which is a delegate.\n");
    13971577                exit(1);
     1578        case sc_enum:
     1579                printf("Error: Accessing object member which is an enum.\n");
     1580                exit(1);
     1581        case sc_ctor:
     1582                /* It is not possible to reference a constructor explicitly. */
     1583                assert(b_false);
    13981584        case sc_fun:
    13991585                /* Construct anonymous delegate. */
     
    14421628}
    14431629
     1630/** Evaluate symbol member acccess.
     1631 *
     1632 * @param run           Runner object
     1633 * @param access        Access operation
     1634 * @param arg           Evaluated base expression
     1635 * @param res           Place to store result
     1636 */
     1637static void run_access_symbol(run_t *run, stree_access_t *access,
     1638    rdata_item_t *arg, rdata_item_t **res)
     1639{
     1640        rdata_item_t *arg_vi;
     1641        rdata_value_t *arg_val;
     1642        rdata_symbol_t *symbol_v;
     1643        stree_embr_t *embr;
     1644
     1645        rdata_item_t *ritem;
     1646        rdata_value_t *rvalue;
     1647        rdata_var_t *rvar;
     1648        rdata_enum_t *enum_v;
     1649
     1650#ifdef DEBUG_RUN_TRACE
     1651        printf("Run symbol access operation.\n");
     1652#endif
     1653        run_cvt_value_item(run, arg, &arg_vi);
     1654        arg_val = arg_vi->u.value;
     1655        assert(arg_val->var->vc == vc_symbol);
     1656
     1657        symbol_v = arg_val->var->u.symbol_v;
     1658
     1659        /* XXX Port CSI symbol reference to using vc_symbol */
     1660        assert(symbol_v->sym->sc == sc_enum);
     1661
     1662        embr = stree_enum_find_mbr(symbol_v->sym->u.enum_d,
     1663            access->member_name);
     1664
     1665        /* Member existence should be ensured by static type checking. */
     1666        assert(embr != NULL);
     1667
     1668#ifdef DEBUG_RUN_TRACE
     1669        printf("Found enum member '%s'.\n",
     1670            strtab_get_str(access->member_name->sid));
     1671#endif
     1672        ritem = rdata_item_new(ic_value);
     1673        rvalue = rdata_value_new();
     1674        rvar = rdata_var_new(vc_enum);
     1675        enum_v = rdata_enum_new();
     1676
     1677        ritem->u.value = rvalue;
     1678        rvalue->var = rvar;
     1679        rvar->u.enum_v = enum_v;
     1680        enum_v->value = embr;
     1681
     1682        *res = ritem;
     1683}
     1684
    14441685/** Call a function.
    14451686 *
     
    14551696        rdata_deleg_t *deleg_v;
    14561697        list_t arg_vals;
    1457         list_node_t *node;
    1458         stree_expr_t *arg;
    1459         rdata_item_t *rarg_i, *rarg_vi;
    14601698
    14611699        stree_fun_t *fun;
     
    14991737#endif
    15001738        /* Evaluate function arguments. */
     1739        run_call_args(run, &call->args, &arg_vals);
     1740        if (run_is_bo(run)) {
     1741                *res = NULL;
     1742                return;
     1743        }
     1744
     1745        fun = symbol_to_fun(deleg_v->sym);
     1746        assert(fun != NULL);
     1747
     1748        /* Create procedure activation record. */
     1749        run_proc_ar_create(run, deleg_v->obj, fun->proc, &proc_ar);
     1750
     1751        /* Fill in argument values. */
     1752        run_proc_ar_set_args(run, proc_ar, &arg_vals);
     1753
     1754        /* Run the function. */
     1755        run_proc(run, proc_ar, res);
     1756
     1757        if (!run_is_bo(run) && fun->sig->rtype != NULL && *res == NULL) {
     1758                printf("Error: Function '");
     1759                symbol_print_fqn(deleg_v->sym);
     1760                printf("' did not return a value.\n");
     1761                exit(1);
     1762        }
     1763
     1764#ifdef DEBUG_RUN_TRACE
     1765        printf("Returned from function call.\n");
     1766#endif
     1767}
     1768
     1769/** Evaluate call arguments.
     1770 *
     1771 * Evaluate arguments to function or constructor.
     1772 *
     1773 * @param run           Runner object
     1774 * @param args          Real arguments (list of stree_expr_t)
     1775 * @param arg_vals      Address of uninitialized list to store argument values
     1776 *                      (list of rdata_item_t).
     1777 */
     1778static void run_call_args(run_t *run, list_t *args, list_t *arg_vals)
     1779{
     1780        list_node_t *arg_n;
     1781        stree_expr_t *arg;
     1782        rdata_item_t *rarg_i, *rarg_vi;
     1783
     1784        /* Evaluate function arguments. */
     1785        list_init(arg_vals);
     1786        arg_n = list_first(args);
     1787
     1788        while (arg_n != NULL) {
     1789                arg = list_node_data(arg_n, stree_expr_t *);
     1790                run_expr(run, arg, &rarg_i);
     1791                if (run_is_bo(run))
     1792                        return;
     1793
     1794                run_cvt_value_item(run, rarg_i, &rarg_vi);
     1795
     1796                list_append(arg_vals, rarg_vi);
     1797                arg_n = list_next(args, arg_n);
     1798        }
     1799}
     1800
     1801/** Run index operation.
     1802 *
     1803 * Evaluate operation per the indexing ('[', ']') operator.
     1804 *
     1805 * @param run           Runner object
     1806 * @param index         Index operation
     1807 * @param res           Place to store result
     1808 */
     1809static void run_index(run_t *run, stree_index_t *index, rdata_item_t **res)
     1810{
     1811        rdata_item_t *rbase;
     1812        rdata_item_t *base_i;
     1813        list_node_t *node;
     1814        stree_expr_t *arg;
     1815        rdata_item_t *rarg_i, *rarg_vi;
     1816        var_class_t vc;
     1817        list_t arg_vals;
     1818
     1819#ifdef DEBUG_RUN_TRACE
     1820        printf("Run index operation.\n");
     1821#endif
     1822        run_expr(run, index->base, &rbase);
     1823        if (run_is_bo(run)) {
     1824                *res = NULL;
     1825                return;
     1826        }
     1827
     1828        vc = run_item_get_vc(run, rbase);
     1829
     1830        /* Implicitly dereference. */
     1831        if (vc == vc_ref) {
     1832                run_dereference(run, rbase, index->base->cspan, &base_i);
     1833                if (run_is_bo(run)) {
     1834                        *res = NULL;
     1835                        return;
     1836                }
     1837        } else {
     1838                base_i = rbase;
     1839        }
     1840
     1841        vc = run_item_get_vc(run, base_i);
     1842
     1843        /* Evaluate arguments (indices). */
     1844        node = list_first(&index->args);
    15011845        list_init(&arg_vals);
    1502         node = list_first(&call->args);
    15031846
    15041847        while (node != NULL) {
     
    15131856
    15141857                list_append(&arg_vals, rarg_vi);
    1515                 node = list_next(&call->args, node);
    1516         }
    1517 
    1518         fun = symbol_to_fun(deleg_v->sym);
    1519         assert(fun != NULL);
    1520 
    1521         /* Create procedure activation record. */
    1522         run_proc_ar_create(run, deleg_v->obj, fun->proc, &proc_ar);
    1523 
    1524         /* Fill in argument values. */
    1525         run_proc_ar_set_args(run, proc_ar, &arg_vals);
    1526 
    1527         /* Run the function. */
    1528         run_proc(run, proc_ar, res);
    1529 
    1530 #ifdef DEBUG_RUN_TRACE
    1531         printf("Returned from function call.\n");
    1532 #endif
    1533 }
    1534 
    1535 /** Run index operation.
    1536  *
    1537  * Evaluate operation per the indexing ('[', ']') operator.
    1538  *
    1539  * @param run           Runner object
    1540  * @param index         Index operation
    1541  * @param res           Place to store result
    1542  */
    1543 static void run_index(run_t *run, stree_index_t *index, rdata_item_t **res)
    1544 {
    1545         rdata_item_t *rbase;
    1546         rdata_item_t *base_i;
    1547         list_node_t *node;
    1548         stree_expr_t *arg;
    1549         rdata_item_t *rarg_i, *rarg_vi;
    1550         var_class_t vc;
    1551         list_t arg_vals;
    1552 
    1553 #ifdef DEBUG_RUN_TRACE
    1554         printf("Run index operation.\n");
    1555 #endif
    1556         run_expr(run, index->base, &rbase);
    1557         if (run_is_bo(run)) {
    1558                 *res = NULL;
    1559                 return;
    1560         }
    1561 
    1562         vc = run_item_get_vc(run, rbase);
    1563 
    1564         /* Implicitly dereference. */
    1565         if (vc == vc_ref) {
    1566                 run_dereference(run, rbase, &base_i);
    1567         } else {
    1568                 base_i = rbase;
    1569         }
    1570 
    1571         vc = run_item_get_vc(run, base_i);
    1572 
    1573         /* Evaluate arguments (indices). */
    1574         node = list_first(&index->args);
    1575         list_init(&arg_vals);
    1576 
    1577         while (node != NULL) {
    1578                 arg = list_node_data(node, stree_expr_t *);
    1579                 run_expr(run, arg, &rarg_i);
    1580                 if (run_is_bo(run)) {
    1581                         *res = NULL;
    1582                         return;
    1583                 }
    1584 
    1585                 run_cvt_value_item(run, rarg_i, &rarg_vi);
    1586 
    1587                 list_append(&arg_vals, rarg_vi);
    15881858
    15891859                node = list_next(&index->args, node);
     
    16341904#endif
    16351905        (void) run;
    1636         (void) index;
    16371906
    16381907        assert(base->ic == ic_address);
     
    16761945                        /* Raise Error.OutOfBounds */
    16771946                        run_raise_exc(run,
    1678                             run->program->builtin->error_outofbounds);
     1947                            run->program->builtin->error_outofbounds,
     1948                            index->expr->cspan);
     1949                        /* XXX It should be cspan of the argument. */
    16791950                        *res = run_recovery_item(run);
    16801951                        return;
     
    18142085#endif
    18152086        (void) run;
    1816         (void) index;
    18172087
    18182088        run_cvt_value_item(run, base, &base_vi);
     
    18662136#endif
    18672137                /* Raise Error.OutOfBounds */
    1868                 run_raise_exc(run, run->program->builtin->error_outofbounds);
     2138                run_raise_exc(run, run->program->builtin->error_outofbounds,
     2139                    index->expr->cspan);
    18692140                *res = run_recovery_item(run);
    18702141                return;
     
    19702241        }
    19712242
    1972         run_dereference(run, rarg_vi, &rarg_di);
     2243        run_dereference(run, rarg_vi, NULL, &rarg_di);
    19732244
    19742245        /* Now we should have a variable address. */
     
    20482319        case vc_ref:
    20492320        case vc_deleg:
     2321        case vc_enum:
    20502322        case vc_array:
    20512323        case vc_object:
    20522324        case vc_resource:
     2325        case vc_symbol:
    20532326                assert(b_false);
    20542327        }
     
    21472420}
    21482421
     2422/** Run constructor on an object.
     2423 *
     2424 * @param run           Runner object
     2425 * @param obj           Object to run constructor on
     2426 * @param arg_vals      Argument values (list of rdata_item_t)
     2427 */
     2428static void run_object_ctor(run_t *run, rdata_var_t *obj, list_t *arg_vals)
     2429{
     2430        stree_ident_t *ctor_ident;
     2431        stree_symbol_t *csi_sym;
     2432        stree_csi_t *csi;
     2433        stree_symbol_t *ctor_sym;
     2434        stree_ctor_t *ctor;
     2435        run_proc_ar_t *proc_ar;
     2436        rdata_item_t *res;
     2437
     2438        csi_sym = obj->u.object_v->class_sym;
     2439        csi = symbol_to_csi(csi_sym);
     2440        assert(csi != NULL);
     2441
     2442#ifdef DEBUG_RUN_TRACE
     2443        printf("Run object constructor from CSI '");
     2444        symbol_print_fqn(csi_sym);
     2445        printf("'.\n");
     2446#endif
     2447        ctor_ident = stree_ident_new();
     2448        ctor_ident->sid = strtab_get_sid(CTOR_IDENT);
     2449
     2450        /* Find constructor. */
     2451        ctor_sym = symbol_search_csi_no_base(run->program, csi, ctor_ident);
     2452        if (ctor_sym == NULL) {
     2453#ifdef DEBUG_RUN_TRACE
     2454                printf("No constructor found.\n");
     2455#endif
     2456                return;
     2457        }
     2458
     2459        ctor = symbol_to_ctor(ctor_sym);
     2460        assert(ctor != NULL);
     2461
     2462        /* Create procedure activation record. */
     2463        run_proc_ar_create(run, obj, ctor->proc, &proc_ar);
     2464
     2465        /* Fill in argument values. */
     2466        run_proc_ar_set_args(run, proc_ar, arg_vals);
     2467
     2468        /* Run the procedure. */
     2469        run_proc(run, proc_ar, &res);
     2470
     2471        /* Constructor does not return a value. */
     2472        assert(res == NULL);
     2473
     2474#ifdef DEBUG_RUN_TRACE
     2475        printf("Returned from constructor..\n");
     2476#endif
     2477}
     2478
    21492479/** Return boolean value of an item.
    21502480 *
Note: See TracChangeset for help on using the changeset viewer.