Changes in / [f6ed7fd:4b5857f]


Ignore:
Location:
src
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rf6ed7fd r4b5857f  
    806806
    807807                for ( std::list< Label >::iterator i = l.begin(); i != l.end(); i++ )
    808                         str += *i + ": ";
     808                        str += (*i).get_name() + ": ";
    809809
    810810                return str;
  • src/ControlStruct/LabelFixer.cc

    rf6ed7fd r4b5857f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // LabelFixer.cc -- 
     7// LabelFixer.cc --
    88//
    99// Author           : Rodolfo G. Esteves
     
    8686
    8787
    88         // sets the definition of the labelTable entry to be the provided 
     88        // sets the definition of the labelTable entry to be the provided
    8989        // statement for every label in the list parameter. Happens for every kind of statement
    9090        Label LabelFixer::setLabelsDef( std::list< Label > &llabel, Statement *definition ) {
     
    101101                        } else if ( labelTable[ *i ]->defined() ) {
    102102                                // defined twice, error
    103                                 throw SemanticError( "Duplicate definition of label: " + *i );
     103                                throw SemanticError( "Duplicate definition of label: " + (*i).get_name() );
    104104                        }       else {
    105105                                // used previously, but undefined until now -> link with this entry
     
    109109                } // for
    110110
    111                 // produce one of the labels attached to this statement to be 
     111                // produce one of the labels attached to this statement to be
    112112                // temporarily used as the canonical label
    113113                return labelTable[ llabel.front() ]->get_label();
     
    130130                for ( std::map< Label, Entry * >::iterator i = labelTable.begin(); i != labelTable.end(); ++i ) {
    131131                        if ( ! i->second->defined() ) {
    132                                 throw SemanticError( "Use of undefined label: " + i->first );
     132                                throw SemanticError( "Use of undefined label: " + i->first.get_name() );
    133133                        }
    134134                        (*ret)[ i->first ] = i->second->get_definition();
  • src/ControlStruct/LabelFixer.h

    rf6ed7fd r4b5857f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // LabelFixer.h -- 
     7// LabelFixer.h --
    88//
    99// Author           : Rodolfo G. Esteves
     
    2020#include "SynTree/SynTree.h"
    2121#include "SynTree/Visitor.h"
     22#include "SynTree/Label.h"
    2223#include "LabelGenerator.h"
    23 
    2424#include <map>
    2525
     
    7474
    7575                  private:
    76                         Label label; 
     76                        Label label;
    7777                        Statement *definition;
    7878                };
    79                  
     79
    8080                std::map < Label, Entry *> labelTable;
    8181                LabelGenerator *generator;
  • src/ControlStruct/LabelGenerator.cc

    rf6ed7fd r4b5857f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // LabelGenerator.cc -- 
     7// LabelGenerator.cc --
    88//
    99// Author           : Rodolfo G. Esteves
     
    1818
    1919#include "LabelGenerator.h"
     20#include "SynTree/Label.h"
    2021
    2122namespace ControlStruct {
  • src/ControlStruct/MLEMutator.h

    rf6ed7fd r4b5857f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // MLEMutator.h -- 
     7// MLEMutator.h --
    88//
    99// Author           : Rodolfo G. Esteves
     
    2323#include "SynTree/SynTree.h"
    2424#include "SynTree/Mutator.h"
     25#include "SynTree/Label.h"
    2526
    2627#include "LabelGenerator.h"
     
    3839                Statement *mutate( BranchStmt *branchStmt ) throw ( SemanticError );
    3940
    40                 Statement *mutate( CaseStmt *caseStmt ); 
     41                Statement *mutate( CaseStmt *caseStmt );
    4142                Statement *mutate( SwitchStmt *switchStmt );
    4243                Statement *mutate( ChooseStmt *switchStmt );
     
    7980                Statement *handleLoopStmt( LoopClass *loopStmt );
    8081
    81                 template< typename SwitchClass > 
     82                template< typename SwitchClass >
    8283                Statement *handleSwitchStmt( SwitchClass *switchStmt );
    8384
  • src/GenPoly/Specialize.cc

    rf6ed7fd r4b5857f  
    9999                } // if
    100100                // create new thunk with same signature as formal type (C linkage, empty body)
    101                 FunctionDecl *thunkFunc = new FunctionDecl( thunkNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, newType, new CompoundStmt( std::list< std::string >() ), false, false );
     101                FunctionDecl *thunkFunc = new FunctionDecl( thunkNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, newType, new CompoundStmt( noLabels ), false, false );
    102102                thunkFunc->fixUniqueId();
    103103
  • src/InitTweak/FixInit.cc

    rf6ed7fd r4b5857f  
    281281                PRINT( std::cerr << "Coming out the back..." << impCpCtorExpr << std::endl; )
    282282
    283                 // xxx - some of these aren't necessary, and can be removed once this is stable
     283                // detach fields from wrapper node so that it can be deleted without deleting too much
    284284                dtors.clear();
    285285                tempDecls.clear();
  • src/InitTweak/InitTweak.cc

    rf6ed7fd r4b5857f  
    115115
    116116        namespace {
    117                 template<typename CallExpr>
    118                 std::string funcName( CallExpr * expr ) {
    119                         Expression * func = expr->get_function();
     117                std::string funcName( Expression * func ) {
    120118                        if ( NameExpr * nameExpr = dynamic_cast< NameExpr * >( func ) ) {
    121119                                return nameExpr->get_name();
    122120                        } else if ( VariableExpr * varExpr = dynamic_cast< VariableExpr * >( func ) ) {
    123121                                return varExpr->get_var()->get_name();
     122                        }       else if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( func ) ) {
     123                                return funcName( castExpr->get_arg() );
    124124                        } else {
    125125                                assert( false && "Unexpected expression type being called as a function in call expression" );
     
    130130        std::string getFunctionName( Expression * expr ) {
    131131                if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * >( expr ) ) {
    132                         return funcName( appExpr );
     132                        return funcName( appExpr->get_function() );
    133133                } else if ( UntypedExpr * untypedExpr = dynamic_cast< UntypedExpr * > ( expr ) ) {
    134                         return funcName( untypedExpr );
     134                        return funcName( untypedExpr->get_function() );
    135135                } else {
     136                        std::cerr << expr << std::endl;
    136137                        assert( false && "Unexpected expression type passed to getFunctionName" );
    137138                }
  • src/Parser/ParseNode.h

    rf6ed7fd r4b5857f  
    2828//#include "SynTree/Declaration.h"
    2929#include "Common/UniqueName.h"
     30#include "SynTree/Label.h"
    3031
    3132class ExpressionNode;
     
    284285        virtual void printOneLine( std::ostream &, int indent = 0) const;
    285286
    286         const std::list< std::string > &get_labels() const { return labels; };
     287        const std::list< Label > &get_labels() const { return labels; };
    287288        void append_label( std::string *label ) { labels.push_back( *label ); delete label; }
    288289  private:
    289         std::list< std::string > labels;
     290        std::list< Label > labels;
    290291};
    291292
     
    524525        ExpressionNode *output, *input;
    525526        ConstantNode *clobber;
    526         std::list<std::string> gotolabels;
     527        std::list< Label > gotolabels;
    527528};
    528529
  • src/Parser/StatementNode.cc

    rf6ed7fd r4b5857f  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // StatementNode.cc -- 
     7// StatementNode.cc --
    88//
    99// Author           : Rodolfo G. Esteves
     
    2727
    2828const char *StatementNode::StType[] = {
    29         "Exp",   "If",       "Switch", "Case",    "Default",  "Choose",   "Fallthru", 
    30         "While", "Do",       "For", 
     29        "Exp",   "If",       "Switch", "Case",    "Default",  "Choose",   "Fallthru",
     30        "While", "Do",       "For",
    3131        "Goto",  "Continue", "Break",  "Return",  "Throw",
    3232        "Try",   "Catch",    "Finally", "Asm",
     
    6262StatementNode::StatementNode( Type t, ExpressionNode *ctrl_label, StatementNode *block ) : type( t ), control( ctrl_label ), block( block ), labels( 0 ), target( 0 ), decl( 0 ), isCatchRest ( false ) {
    6363        this->control = ( t == Default ) ? 0 : control;
    64 } 
     64}
    6565
    6666StatementNode::StatementNode( Type t, string *target ) : type( t ), control( 0 ), block( 0 ), labels( 0 ), target( target ), decl( 0 ), isCatchRest ( false ) {}
     
    7474
    7575StatementNode * StatementNode::newCatchStmt( DeclarationNode *d, StatementNode *s, bool catchRestP ) {
    76         StatementNode *ret = new StatementNode( StatementNode::Catch, 0, s ); 
     76        StatementNode *ret = new StatementNode( StatementNode::Catch, 0, s );
    7777        ret->addDeclaration( d );
    7878        ret->setCatchRest( catchRestP );
     
    101101StatementNode *StatementNode::add_label( const std::string *l ) {
    102102        if ( l != 0 ) {
    103                 labels.push_front( *l ); 
     103                labels.push_front( *l );
    104104                delete l;
    105105        } // if
     
    156156                        control->print( os, indent );
    157157                        os << endl;
    158                 } else 
     158                } else
    159159                        os << string( indent, ' ' ) << "Null Statement" << endl;
    160160                break;
     
    177177                if ( block ) {
    178178                        os << string( indent + ParseNode::indent_by, ' ' ) << "Branches of execution: " << endl;
    179                         block->printList( os, indent + 2 * ParseNode::indent_by ); 
     179                        block->printList( os, indent + 2 * ParseNode::indent_by );
    180180                } // if
    181181                if ( target ) {
     
    258258          case Fallthru:
    259259                return new FallthruStmt( labs );
    260           case Case: 
     260          case Case:
    261261                return new CaseStmt( labs, maybeBuild<Expression>(get_control()), branches );
    262262          case Default:
     
    394394                os << string( indent + ParseNode::indent_by, ' ' ) << "Goto Labels:" << endl;
    395395                os << string( indent + 2 * ParseNode::indent_by, ' ' );
    396                 for ( std::list<std::string>::const_iterator i = gotolabels.begin();; ) {
     396                for ( std::list<Label>::const_iterator i = gotolabels.begin();; ) {
    397397                        os << *i;
    398398                        i++;
     
    426426}
    427427
    428 Statement *NullStmtNode::build() const { 
     428Statement *NullStmtNode::build() const {
    429429        return new NullStmt;
    430430}
  • src/SymTab/Autogen.cc

    rf6ed7fd r4b5857f  
    482482                ObjectDecl *dst = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), typeInst->clone() ), 0 );
    483483                if ( typeDecl->get_base() ) {
     484                        // xxx - generate ctor/dtors for typedecls, e.g.
     485                        // otype T = int *;
    484486                        stmts = new CompoundStmt( std::list< Label >() );
    485487                        UntypedExpr *assign = new UntypedExpr( new NameExpr( "?=?" ) );
  • src/SymTab/Autogen.h

    rf6ed7fd r4b5857f  
    2424
    2525namespace SymTab {
    26   static const std::list< std::string > noLabels;
    27 
    2826  /// Generates assignment operators, constructors, and destructor for aggregate types as required
    2927  void autogenerateRoutines( std::list< Declaration * > &translationUnit );
  • src/SynTree/Statement.cc

    rf6ed7fd r4b5857f  
    8787        Statement( labels ), originalTarget( _target ), target( _target ), computedTarget( NULL ), type( _type ) {
    8888        //actually this is a syntactic error signaled by the parser
    89         if ( type == BranchStmt::Goto && target.size() == 0 )
     89        if ( type == BranchStmt::Goto && target.empty() )
    9090                throw SemanticError("goto without target");
    9191}
  • src/SynTree/Statement.h

    rf6ed7fd r4b5857f  
    2222#include "Common/SemanticError.h"
    2323#include "Type.h"
     24#include "Label.h"
    2425
    2526class Statement {
  • src/SynTree/SynTree.h

    rf6ed7fd r4b5857f  
    113113class Constant;
    114114
    115 typedef std::string Label;
     115// typedef std::string Label;
     116class Label;
    116117typedef unsigned int UniqueId;
    117118
Note: See TracChangeset for help on using the changeset viewer.