Changeset 39e8406 in mainline for uspace/app/sbi/src/run_texpr.c


Ignore:
Timestamp:
2010-03-20T21:57:13Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b535aeb
Parents:
6ba20a6b
Message:

Update SBI to rev. 128.

File:
1 edited

Legend:

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

    r6ba20a6b r39e8406  
    2929/** @file Evaluates type expressions. */
    3030
     31#include <assert.h>
    3132#include <stdlib.h>
    3233#include "list.h"
    3334#include "mytypes.h"
    34 #include "rdata.h"
    35 #include "run.h"
    3635#include "symbol.h"
     36#include "tdata.h"
    3737
    3838#include "run_texpr.h"
    3939
    40 static void run_taccess(run_t *run, stree_taccess_t *taccess,
    41     rdata_titem_t **res);
    42 static void run_tindex(run_t *run, stree_tindex_t *tindex,
    43     rdata_titem_t **res);
    44 static void run_tliteral(run_t *run, stree_tliteral_t *tliteral,
    45     rdata_titem_t **res);
    46 static void run_tnameref(run_t *run, stree_tnameref_t *tnameref,
    47     rdata_titem_t **res);
    48 
    49 void run_texpr(run_t *run, stree_texpr_t *texpr, rdata_titem_t **res)
     40static void run_taccess(stree_program_t *prog, stree_csi_t *ctx,
     41    stree_taccess_t *taccess, tdata_item_t **res);
     42static void run_tindex(stree_program_t *prog, stree_csi_t *ctx,
     43    stree_tindex_t *tindex, tdata_item_t **res);
     44static void run_tliteral(stree_program_t *prog, stree_csi_t *ctx,
     45    stree_tliteral_t *tliteral, tdata_item_t **res);
     46static void run_tnameref(stree_program_t *prog, stree_csi_t *ctx,
     47    stree_tnameref_t *tnameref, tdata_item_t **res);
     48
     49void run_texpr(stree_program_t *prog, stree_csi_t *ctx, stree_texpr_t *texpr,
     50    tdata_item_t **res)
    5051{
    5152        switch (texpr->tc) {
    5253        case tc_taccess:
    53                 run_taccess(run, texpr->u.taccess, res);
     54                run_taccess(prog, ctx, texpr->u.taccess, res);
    5455                break;
    5556        case tc_tindex:
    56                 run_tindex(run, texpr->u.tindex, res);
     57                run_tindex(prog, ctx, texpr->u.tindex, res);
    5758                break;
    5859        case tc_tliteral:
    59                 run_tliteral(run, texpr->u.tliteral, res);
     60                run_tliteral(prog, ctx, texpr->u.tliteral, res);
    6061                break;
    6162        case tc_tnameref:
    62                 run_tnameref(run, texpr->u.tnameref, res);
     63                run_tnameref(prog, ctx, texpr->u.tnameref, res);
    6364                break;
    6465        case tc_tapply:
     
    6970}
    7071
    71 static void run_taccess(run_t *run, stree_taccess_t *taccess,
    72     rdata_titem_t **res)
     72static void run_taccess(stree_program_t *prog, stree_csi_t *ctx,
     73    stree_taccess_t *taccess, tdata_item_t **res)
    7374{
    7475        stree_symbol_t *sym;
    75         rdata_titem_t *targ_i;
    76         rdata_titem_t *titem;
    77         rdata_tcsi_t *tcsi;
     76        tdata_item_t *targ_i;
     77        tdata_item_t *titem;
     78        tdata_object_t *tobject;
    7879        stree_csi_t *base_csi;
    7980
     
    8283#endif
    8384        /* Evaluate base type. */
    84         run_texpr(run, taccess->arg, &targ_i);
    85 
    86         if (targ_i->tic != tic_tcsi) {
    87                 printf("Error: Using '.' with type which is not CSI.\n");
     85        run_texpr(prog, ctx, taccess->arg, &targ_i);
     86
     87        if (targ_i->tic != tic_tobject) {
     88                printf("Error: Using '.' with type which is not an object.\n");
    8889                exit(1);
    8990        }
    9091
    9192        /* Get base CSI. */
    92         base_csi = targ_i->u.tcsi->csi;
    93 
    94         sym = symbol_lookup_in_csi(run->program, base_csi,
    95             taccess->member_name);
     93        base_csi = targ_i->u.tobject->csi;
     94
     95        sym = symbol_lookup_in_csi(prog, base_csi, taccess->member_name);
    9696        if (sym->sc != sc_csi) {
    9797                printf("Error: Symbol '");
    98                 symbol_print_fqn(run->program, sym);
     98                symbol_print_fqn(sym);
    9999                printf("' is not a CSI.\n");
    100100                exit(1);
     
    102102
    103103        /* Construct type item. */
    104         titem = rdata_titem_new(tic_tcsi);
    105         tcsi = rdata_tcsi_new();
    106         titem->u.tcsi = tcsi;
    107 
    108         tcsi->csi = sym->u.csi;
    109 
    110         *res = titem;
    111 }
    112 
    113 static void run_tindex(run_t *run, stree_tindex_t *tindex, rdata_titem_t **res)
    114 {
    115         rdata_titem_t *base_ti;
    116         rdata_titem_t *titem;
    117         rdata_tarray_t *tarray;
     104        titem = tdata_item_new(tic_tobject);
     105        tobject = tdata_object_new();
     106        titem->u.tobject = tobject;
     107
     108        tobject->static_ref = b_false;
     109        tobject->csi = sym->u.csi;
     110
     111        *res = titem;
     112}
     113
     114static void run_tindex(stree_program_t *prog, stree_csi_t *ctx,
     115    stree_tindex_t *tindex, tdata_item_t **res)
     116{
     117        tdata_item_t *base_ti;
     118        tdata_item_t *titem;
     119        tdata_array_t *tarray;
    118120        stree_expr_t *arg_expr;
    119121        list_node_t *arg_node;
     
    123125#endif
    124126        /* Evaluate base type. */
    125         run_texpr(run, tindex->base_type, &base_ti);
    126 
    127         /* Construct type item. */
    128         titem = rdata_titem_new(tic_tarray);
    129         tarray = rdata_tarray_new();
     127        run_texpr(prog, ctx, tindex->base_type, &base_ti);
     128
     129        /* Construct type item. */
     130        titem = tdata_item_new(tic_tarray);
     131        tarray = tdata_array_new();
    130132        titem->u.tarray = tarray;
    131133
     
    146148}
    147149
    148 static void run_tliteral(run_t *run, stree_tliteral_t *tliteral,
    149     rdata_titem_t **res)
    150 {
    151         rdata_titem_t *titem;
    152         rdata_tprimitive_t *tprimitive;
     150static void run_tliteral(stree_program_t *prog, stree_csi_t *ctx,
     151    stree_tliteral_t *tliteral, tdata_item_t **res)
     152{
     153        tdata_item_t *titem;
     154        tdata_primitive_t *tprimitive;
     155        tprimitive_class_t tpc;
    153156
    154157#ifdef DEBUG_RUN_TRACE
    155158        printf("Evaluating type literal.\n");
    156159#endif
    157 
    158         (void) run;
     160        (void) prog;
     161        (void) ctx;
    159162        (void) tliteral;
    160163
    161         /* Construct type item. */
    162         titem = rdata_titem_new(tic_tprimitive);
    163         tprimitive = rdata_tprimitive_new();
     164        switch (tliteral->tlc) {
     165        case tlc_int: tpc = tpc_int; break;
     166        case tlc_string: tpc = tpc_string; break;
     167        }
     168
     169        /* Construct type item. */
     170        titem = tdata_item_new(tic_tprimitive);
     171        tprimitive = tdata_primitive_new(tpc);
    164172        titem->u.tprimitive = tprimitive;
    165173
     
    167175}
    168176
    169 static void run_tnameref(run_t *run, stree_tnameref_t *tnameref,
    170     rdata_titem_t **res)
    171 {
    172         stree_csi_t *current_csi;
     177static void run_tnameref(stree_program_t *prog, stree_csi_t *ctx,
     178    stree_tnameref_t *tnameref, tdata_item_t **res)
     179{
    173180        stree_symbol_t *sym;
    174         rdata_titem_t *titem;
    175         rdata_tcsi_t *tcsi;
     181        tdata_item_t *titem;
     182        tdata_object_t *tobject;
    176183
    177184#ifdef DEBUG_RUN_TRACE
    178185        printf("Evaluating type name reference.\n");
    179186#endif
    180         current_csi = run_get_current_csi(run);
    181         sym = symbol_lookup_in_csi(run->program, current_csi, tnameref->name);
     187        sym = symbol_lookup_in_csi(prog, ctx, tnameref->name);
    182188
    183189        if (sym->sc != sc_csi) {
    184190                printf("Error: Symbol '");
    185                 symbol_print_fqn(run->program, sym);
     191                symbol_print_fqn(sym);
    186192                printf("' is not a CSI.\n");
    187193                exit(1);
     
    189195
    190196        /* Construct type item. */
    191         titem = rdata_titem_new(tic_tcsi);
    192         tcsi = rdata_tcsi_new();
    193         titem->u.tcsi = tcsi;
    194 
    195         tcsi->csi = sym->u.csi;
    196 
    197         *res = titem;
    198 }
     197        titem = tdata_item_new(tic_tobject);
     198        tobject = tdata_object_new();
     199        titem->u.tobject = tobject;
     200
     201        tobject->static_ref = b_false;
     202        tobject->csi = sym->u.csi;
     203
     204        *res = titem;
     205}
Note: See TracChangeset for help on using the changeset viewer.