File: pushs.c

package info (click to toggle)
icmake 7.18.00-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 2,840 kB
  • sloc: ansic: 7,784; makefile: 3,811; sh: 319; cpp: 83
file content (38 lines) | stat: -rw-r--r-- 1,095 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
/*
\funcref{fun\_push\_strconst} {void fun\_push\_strconst ()}
    {}
    {}
    {getint16(), getstring(), error(), push()}
    {}
    {funpushs.c}
    {

        This function is called when a string constant is to be pushed onto the
        stack. The offset of the string to be pushed, relative to the strings
        section of the binary makefile, is expected to follow the opcode. This
        relative offset is an {\em UNS16} variable.

        A variable of type {\em e\_str} and with field {\em vu.str} set to
        a duplicate of the string constant is pushed.

    }
*/

#include "opcodefun.ih"

void fun_push_strconst()
{
    register char *str = getstring(infile, headerp->offset[0], 
                                           (size_t)getint16(infile));
    
    if (str == (char *)-1)
        error ("cannot get string, opcode at %s", hexstring (curoffs, 4));

    {
                                        /* str is allocated by getstring() */
        STRINGVAR_ tmp = *stringConstructor_cP(str);
        push(&tmp);
        stringDestructor(&tmp);
        free(str);
    }
}