Changeset dbc733e for src/SynTree


Ignore:
Timestamp:
Sep 1, 2017, 9:53:19 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
f43df73
Parents:
ba2a68b (diff), b0dfbc4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg2:software/cfa/cfa-cc

Location:
src/SynTree
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/AddressExpr.cc

    rba2a68b rdbc733e  
    7070}
    7171
     72LabelAddressExpr::LabelAddressExpr( const Label &arg ) : arg( arg ) {
     73        // label address always has type void *
     74        result = new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) );
     75}
     76LabelAddressExpr::LabelAddressExpr( const LabelAddressExpr & other ) : Expression( other ), arg( other.arg ) {}
     77LabelAddressExpr::~LabelAddressExpr() {}
     78
     79void LabelAddressExpr::print( std::ostream & os, int indent ) const {
     80        os << "Address of label:" << std::endl << std::string( indent+2, ' ' ) << arg;
     81}
     82
    7283// Local Variables: //
    7384// tab-width: 4 //
  • src/SynTree/Expression.h

    rba2a68b rdbc733e  
    2424#include "Constant.h"             // for Constant
    2525#include "Initializer.h"          // for Designation (ptr only), Initializer
     26#include "Label.h"                // for Label
    2627#include "Mutator.h"              // for Mutator
    2728#include "SynTree.h"              // for UniqueId
     
    173174};
    174175
    175 // xxx - this doesn't appear to actually be hooked in anywhere. We should use this instead of the "&&"" UntypedExpr hack
     176// GCC &&label
     177// https://gcc.gnu.org/onlinedocs/gcc-3.4.2/gcc/Labels-as-Values.html
    176178class LabelAddressExpr : public Expression {
    177179  public:
    178         Expression * arg;
    179 
    180         LabelAddressExpr( Expression * arg );
     180        Label arg;
     181
     182        LabelAddressExpr( const Label &arg );
    181183        LabelAddressExpr( const LabelAddressExpr & other );
    182184        virtual ~LabelAddressExpr();
    183 
    184         Expression * get_arg() const { return arg; }
    185         void set_arg(Expression * newValue ) { arg = newValue; }
    186185
    187186        virtual LabelAddressExpr * clone() const { return new LabelAddressExpr( * this ); }
  • src/SynTree/Mutator.cc

    rba2a68b rdbc733e  
    246246        labelAddressExpr->set_env( maybeMutate( labelAddressExpr->get_env(), *this ) );
    247247        labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) );
    248         labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) );
    249248        return labelAddressExpr;
    250249}
  • src/SynTree/Statement.cc

    rba2a68b rdbc733e  
    8989
    9090BranchStmt::BranchStmt( std::list<Label> labels, Label target, Type type ) throw ( SemanticError ) :
    91         Statement( labels ), originalTarget( target ), target( target ), computedTarget( NULL ), type( type ) {
     91        Statement( labels ), originalTarget( target ), target( target ), computedTarget( nullptr ), type( type ) {
    9292        //actually this is a syntactic error signaled by the parser
    93         if ( type == BranchStmt::Goto && target.empty() )
     93        if ( type == BranchStmt::Goto && target.empty() ) {
    9494                throw SemanticError("goto without target");
     95        }
    9596}
    9697
    9798BranchStmt::BranchStmt( std::list<Label> labels, Expression *computedTarget, Type type ) throw ( SemanticError ) :
    9899        Statement( labels ), computedTarget( computedTarget ), type( type ) {
    99         if ( type != BranchStmt::Goto || computedTarget == 0 )
     100        if ( type != BranchStmt::Goto || computedTarget == nullptr ) {
    100101                throw SemanticError("Computed target not valid in branch statement");
     102        }
    101103}
    102104
    103105void BranchStmt::print( std::ostream &os, int indent ) const {
    104106        os << string( indent, ' ' ) << "Branch (" << brType[type] << ")" << endl ;
     107        if ( target != "" ) os << string( indent+2, ' ' ) << "with target: " << target << endl;
     108        if ( originalTarget != "" ) os << string( indent+2, ' ' ) << "with original target: " << originalTarget << endl;
     109        if ( computedTarget != nullptr ) os << string( indent+2, ' ' ) << "with computed target: " << computedTarget << endl;
    105110}
    106111
  • src/SynTree/Visitor.cc

    rba2a68b rdbc733e  
    205205void Visitor::visit( LabelAddressExpr *labAddressExpr ) {
    206206        maybeAccept( labAddressExpr->get_result(), *this );
    207         maybeAccept( labAddressExpr->get_arg(), *this );
    208207}
    209208
Note: See TracChangeset for help on using the changeset viewer.