summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/ifcompiler/initCompiler.H
blob: bcda184c03eba5f4838ab30033fe9538e51b034f (plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*  IBM_PROLOG_BEGIN_TAG
 *  This is an automatically generated prolog.
 *
 *  $Source: src/usr/hwpf/ifcompiler/initCompiler.H $
 *
 *  IBM CONFIDENTIAL
 *
 *  COPYRIGHT International Business Machines Corp. 2010-2012
 *
 *  p1
 *
 *  Object Code Only (OCO) source materials
 *  Licensed Internal Code Source Materials
 *  IBM HostBoot Licensed Internal Code
 *
 *  The source code for this program is not published or other-
 *  wise divested of its trade secrets, irrespective of what has
 *  been deposited with the U.S. Copyright Office.
 *
 *  Origin: 30
 *
 *  IBM_PROLOG_END_TAG
 */
#if !defined(INITCOMPILER_H)
#define INITCOMPILER_H

// Change Log *************************************************************************************
//                                                                      
//  Flag   Track    Userid   Date     Description                
//  ----- -------- -------- -------- -------------------------------------------------------------
//        D754106  dgilbert 06/14/10 Create
//  dg002 SW039868 dgilbert 10/15/10 Add support to filter unneeded inits by EC
//  dg003 D779902  dgilbert 12/08/10 Ability to specify output if file
//                 andrewg  05/24/11 Port over for VPL/PgP
//                 andrewg  09/19/11 Updates based on review
//                 mjjones  11/17/11 Output attribute listing
//                 camvanng 04/12/12 Ability to specify search paths for include files
//                 camvanng 06/27/12 Improve error and debug tracing
// End Change Log *********************************************************************************

/**
 * @file initCompiler.H
 * @brief Compile an initfile into bytecode.
 */

#include <initRpn.H>
#include <initScom.H>
#include <set>
#include <string>
#include <fstream>

using namespace std;


// bison & flex globals

extern int yyline;
extern FILE * yyin;
extern int yyparse();
void yyerror(const char * s);
extern init::ScomList * yyscomlist;
extern vector<string> yyincludepath;
extern vector<string> yyfname;
extern string dbg_fname;

namespace init
{


    extern ostringstream dbg;    // debug (verbose) output
    extern ostringstream erros;  // error output stream
    extern ostringstream stats;  // Misc info to be displayed

    /**
     * Dump the dbg stringstream to a file
     * @param i_fname file to dump dbg stringstream
     */
    void capture_dbg(string i_fname);



    class Parser
    {
        public:

            enum
            {
                IF_TYPE  = 1,
                INITFILE_TYPE = 2
            };

            Parser(int narg, char ** argv);
            ~Parser();

            string listing_fn() { return (binseq_fn()).append(".list"); }
            string attr_listing_fn() { return (binseq_fn()).append(".attr"); }
            string source_fn()  { return iv_source_path; }
            string binseq_fn()  { return iv_outfile; }  //dg003a
            //{ string s(iv_outdir); s.append(iv_initfile); s.append(".if"); return s; } //dg003d

            // File to dump dbg stringstream
            string dbg_fn() {string fname(iv_outdir); fname += iv_initfile + ".dbg"; return fname; }

            uint32_t get_source_type() { return iv_type; }

            ostream & listing_ostream() { return iv_list_ostream; }
            ostream & attr_listing_ostream() { return iv_attr_list_ostream; }

            bool debug_mode() { return iv_dbg; }

        private:
            string iv_prog_name;
            string iv_source_path;
            string iv_initfile;
            string iv_outdir;
            string iv_outfile;    //dg003a
            ofstream iv_list_ostream;
            ofstream iv_attr_list_ostream;
            uint32_t iv_type;
            ScomList * iv_scomlist;
            bool iv_dbg;
            uint32_t iv_ec;             // ec filter (if there is one) dg002a

    };
}

#endif
OpenPOWER on IntegriCloud