~ubuntu-branches/ubuntu/raring/verilator/raring-proposed

« back to all changes in this revision

Viewing changes to src/V3AstNodes.h

  • Committer: Package Import Robot
  • Author(s): أحمد المحمودي (Ahmed El-Mahmoudy)
  • Date: 2013-01-13 11:25:29 UTC
  • mfrom: (1.2.16)
  • Revision ID: package-import@ubuntu.com-20130113112529-1jn3n8rbf8glvu2c
Tags: 3.844-1
* New upstream release.
* debian/copyright: Updated copyright years.
* Refresh patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
//
7
7
//*************************************************************************
8
8
//
9
 
// Copyright 2003-2012 by Wilson Snyder.  This program is free software; you can
 
9
// Copyright 2003-2013 by Wilson Snyder.  This program is free software; you can
10
10
// redistribute it and/or modify it under the terms of either the GNU
11
11
// Lesser General Public License Version 3 or the Perl Artistic License
12
12
// Version 2.0.
1367
1367
private:
1368
1368
    AstParseRefExp      m_expect;               // Type we think it should resolve to
1369
1369
    string              m_name;
1370
 
    bool                m_start;                // Start of parseref stack
1371
1370
public:
1372
1371
    AstParseRef(FileLine* fl, AstParseRefExp expect, const string& name, AstNode* lhsp, AstNodeFTaskRef* ftaskrefp)
1373
 
        :AstNode(fl), m_expect(expect), m_name(name) { setNOp1p(lhsp); setNOp2p(ftaskrefp); m_start=false; }
 
1372
        :AstNode(fl), m_expect(expect), m_name(name) { setNOp1p(lhsp); setNOp2p(ftaskrefp); }
1374
1373
    ASTNODE_NODE_FUNCS(ParseRef, PARSEREF)
1375
1374
    virtual void dump(ostream& str);
1376
1375
    virtual string name() const { return m_name; }              // * = Var name
1377
1376
    virtual V3Hash sameHash() const { return V3Hash(V3Hash(m_expect),V3Hash(m_name)); }
1378
 
    virtual bool same(AstNode* samep) const { return expect() == samep->castParseRef()->expect() && m_name==samep->castParseRef()->m_name; }
 
1377
    virtual bool same(AstNode* samep) const {
 
1378
        return (expect() == samep->castParseRef()->expect()
 
1379
                && m_name==samep->castParseRef()->m_name); }
1379
1380
    virtual string emitVerilog() { V3ERROR_NA; return ""; }
1380
1381
    virtual string emitC() { V3ERROR_NA; return ""; }
1381
1382
    virtual void name(const string& name)       { m_name = name; }
1385
1386
    AstNode*    lhsp()          const { return op1p(); }        // op1 = List of statements
1386
1387
    AstNode*    ftaskrefp()     const { return op2p(); }        // op2 = Function/task reference
1387
1388
    void ftaskrefp(AstNodeFTaskRef* nodep) { setNOp2p(nodep); } // op2 = Function/task reference
1388
 
    bool start() const { return m_start; }
1389
 
    void start(bool flag) { m_start = flag; }
 
1389
};
 
1390
 
 
1391
struct AstPackageRef : public AstNode {
 
1392
private:
 
1393
    AstPackage* m_packagep;     // Package hierarchy
 
1394
public:
 
1395
    AstPackageRef(FileLine* fl, AstPackage* packagep)
 
1396
        : AstNode(fl), m_packagep(packagep) {}
 
1397
    ASTNODE_NODE_FUNCS(PackageRef, PACKAGEREF)
 
1398
    // METHODS
 
1399
    virtual bool broken() const { return !m_packagep || !m_packagep->brokeExists(); }
 
1400
    virtual void cloneRelink() { if (m_packagep && m_packagep->clonep()) {
 
1401
        m_packagep = m_packagep->clonep()->castPackage();
 
1402
    }}
 
1403
    virtual bool same(AstNode* samep) const {
 
1404
        return (m_packagep==samep->castPackageRef()->m_packagep); }
 
1405
    virtual V3Hash sameHash() const { return V3Hash(V3Hash(m_packagep)); }
 
1406
    virtual void dump(ostream& str=cout);
 
1407
    AstPackage* packagep() const { return m_packagep; }
 
1408
    void packagep(AstPackage* nodep) { m_packagep=nodep; }
1390
1409
};
1391
1410
 
1392
1411
struct AstDot : public AstNode {
1393
1412
    // A dot separating paths in an AstXRef, AstFuncRef or AstTaskRef
1394
1413
    // These are eliminated in the link stage
1395
 
private:
1396
 
    bool                m_start;                // Start of parseref stack
1397
1414
public:
1398
1415
    AstDot(FileLine* fl, AstNode* lhsp, AstNode* rhsp)
1399
 
        :AstNode(fl) { setOp1p(lhsp); setOp2p(rhsp); m_start=false; }
 
1416
        :AstNode(fl) { setOp1p(lhsp); setOp2p(rhsp); }
1400
1417
    ASTNODE_NODE_FUNCS(Dot, DOT)
 
1418
    static AstNode* newIfPkg(FileLine*fl, AstPackage* packagep, AstNode* rhsp) {  // For parser, make only if non-null package
 
1419
        if (!packagep) return rhsp;
 
1420
        return new AstDot(fl, new AstPackageRef(fl, packagep), rhsp);
 
1421
    }
1401
1422
    virtual void dump(ostream& str);
1402
1423
    virtual string emitVerilog() { V3ERROR_NA; return ""; }
1403
1424
    virtual string emitC() { V3ERROR_NA; return ""; }
1404
1425
    AstNode* lhsp() const { return op1p(); }
1405
1426
    AstNode* rhsp() const { return op2p(); }
1406
 
    bool start() const { return m_start; }
1407
 
    void start(bool flag) { m_start = flag; }
1408
1427
};
1409
1428
 
1410
1429
//######################################################################
1474
1493
    class Initial {};           // for creator type-overload selection
1475
1494
    class Settle {};            // for creator type-overload selection
1476
1495
    class Never {};             // for creator type-overload selection
1477
 
    AstSenItem(FileLine* fl, AstEdgeType edgeType, AstNodeVarRef* varrefp)
1478
 
        : AstNodeSenItem(fl), m_edgeType(edgeType) {
1479
 
        setOp1p(varrefp);
1480
 
    }
1481
 
    AstSenItem(FileLine* fl, AstEdgeType edgeType, AstParseRef* varrefp)
 
1496
    AstSenItem(FileLine* fl, AstEdgeType edgeType, AstNode* varrefp)
1482
1497
        : AstNodeSenItem(fl), m_edgeType(edgeType) {
1483
1498
        setOp1p(varrefp);
1484
1499
    }
1913
1928
    bool hidden() const { return m_hidden; }
1914
1929
};
1915
1930
 
1916
 
struct AstDisplay : public AstNode {
 
1931
struct AstDisplay : public AstNodeStmt {
1917
1932
    // Parents: stmtlist
1918
1933
    // Children: file which must be a varref
1919
1934
    // Children: SFORMATF to generate print string
1921
1936
    AstDisplayType      m_displayType;
1922
1937
public:
1923
1938
    AstDisplay(FileLine* fileline, AstDisplayType dispType, const string& text, AstNode* filep, AstNode* exprsp)
1924
 
        : AstNode (fileline) {
 
1939
        : AstNodeStmt (fileline) {
1925
1940
        setOp1p(new AstSFormatF(fileline,text,true,exprsp));
1926
1941
        setNOp3p(filep);
1927
1942
        m_displayType = dispType;
1976
1991
    void        lhsp(AstNode* nodep) { setOp3p(nodep); }
1977
1992
};
1978
1993
 
1979
 
struct AstSysIgnore : public AstNode {
 
1994
struct AstSysIgnore : public AstNodeStmt {
1980
1995
    // Parents: stmtlist
1981
1996
    // Children: varrefs or exprs
1982
1997
    AstSysIgnore(FileLine* fileline, AstNode* exprsp)
1983
 
        : AstNode (fileline) { addNOp1p(exprsp); }
 
1998
        : AstNodeStmt (fileline) { addNOp1p(exprsp); }
1984
1999
    ASTNODE_NODE_FUNCS(SysIgnore, SYSIGNORE)
1985
2000
    virtual string verilogKwd() const { return "$ignored"; }
1986
2001
    virtual bool isGateOptimizable() const { return false; }  // Though deleted before opt