File: assignme.c

package info (click to toggle)
icmake 7.21.01-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,856 kB
  • ctags: 1,498
  • sloc: ansic: 7,791; makefile: 3,879; sh: 320; cpp: 83
file content (50 lines) | stat: -rw-r--r-- 1,059 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
                             A S S I G N M E . C
*/

#include "iccomp.h"

ESTRUC_ *assignment(lval, rval, opstr)      /* opstr is '=', or "/=", etc. */
    ESTRUC_
        *lval,
        *rval;
    char
        *opstr;
{
    ESTRUC_
        *tmp;
    size_t
        type,
        value;

    if (!test_type(lval, e_var))
    {
        semantic(lvalue_needed, opstr);
        discard(rval);
        return (lval);
    }

    etoc(rval);                             /* convert rval to code */

                                            /* same types */
    if (lval->type & rval->type & (e_int | e_str | e_list))
    {
        type = lval->type;                  /* save type/idx for return */
        value = lval->evalue;

        gencode(lval, op_copy_var, lval->evalue);
        tmp = catcode(rval, lval);          /* catenate assignment code */

        tmp->evalue = value;                /* set lvalue type and idx */
        tmp->type = type;

        return tmp;
    }

    semantic(type_conflict, opstr);
    discard(rval);

    return lval;
}