Changeset 0f8e4ac


Ignore:
Timestamp:
Jun 16, 2016, 12:24:39 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
25296a3
Parents:
f4bc57c
Message:

change Label from a string typedef to a class

Location:
src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    rf4bc57c r0f8e4ac  
    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

    rf4bc57c r0f8e4ac  
    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

    rf4bc57c r0f8e4ac  
    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

    rf4bc57c r0f8e4ac  
    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

    rf4bc57c r0f8e4ac  
    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

    rf4bc57c r0f8e4ac  
    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

    rf4bc57c r0f8e4ac  
    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/Parser/ParseNode.h

    rf4bc57c r0f8e4ac  
    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

    rf4bc57c r0f8e4ac  
    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.h

    rf4bc57c r0f8e4ac  
    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

    rf4bc57c r0f8e4ac  
    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

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

    rf4bc57c r0f8e4ac  
    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.