source: src/ControlStruct/LabelFixer.h @ ea54f1e

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since ea54f1e was a16764a6, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Changed warning system to prepare for toggling warnings

  • Property mode set to 100644
File size: 2.1 KB
RevLine 
[51587aa]1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
[0f8e4ac]7// LabelFixer.h --
[51587aa]8//
[843054c2]9// Author           : Rodolfo G. Esteves
[51587aa]10// Created On       : Mon May 18 07:44:20 2015
[d3b7937]11// Last Modified By : Peter A. Buhr
[6b0b624]12// Last Modified On : Sat Jul 22 09:17:24 2017
13// Update Count     : 34
[51587aa]14//
[a08ba92]15
[6b0b624]16#pragma once
[51b7345]17
[d180746]18#include <list>                    // for list
19#include <map>                     // for map
20
[1fbeebd]21#include "Common/PassVisitor.h"
[d180746]22#include "Common/SemanticError.h"  // for SemanticError
23#include "SynTree/Label.h"         // for Label
24#include "SynTree/Visitor.h"       // for Visitor
25#include "SynTree/SynTree.h"       // for Visitor Nodes
[51b7345]26
27namespace ControlStruct {
[82dd287]28        /// normalizes label definitions and generates multi-level exit labels
[1fbeebd]29        class LabelGenerator;
[d180746]30
[1fbeebd]31        class LabelFixer final : public WithGuards {
[d9a0e76]32          public:
[a08ba92]33                LabelFixer( LabelGenerator *gen = 0 );
34
[a16764a6]35                std::map < Label, Statement * > *resolveJumps() throw ( SemanticErrorException );
[a08ba92]36
37                // Declarations
[1fbeebd]38                void previsit( FunctionDecl *functionDecl );
39                void postvisit( FunctionDecl *functionDecl );
[a08ba92]40
41                // Statements
[1fbeebd]42                void previsit( Statement *stmt );
43                void previsit( BranchStmt *branchStmt );
44
45                // Expressions
46                void previsit( LabelAddressExpr *addrExpr );
[a08ba92]47
48                Label setLabelsDef( std::list< Label > &, Statement *definition );
[1869adf]49                template< typename UsageNode >
50                void setLabelsUsg( Label, UsageNode *usage = 0 );
[d9a0e76]51
52          private:
[a08ba92]53                class Entry {
[1869adf]54                        public:
55                        Entry( Statement *to ) : definition( to ) {}
[a08ba92]56                        bool defined() { return ( definition != 0 ); }
57                        bool insideLoop();
58
59                        Label get_label() const { return label; }
[be5aa1b]60                        void set_label( Label lab ) { label = lab; }
61
[a08ba92]62                        Statement *get_definition() const { return definition; }
[be5aa1b]63                        void set_definition( Statement *def ) { definition = def; }
[a08ba92]64
65                  private:
[0f8e4ac]66                        Label label;
[a08ba92]67                        Statement *definition;
68                };
[0f8e4ac]69
[a08ba92]70                std::map < Label, Entry *> labelTable;
71                LabelGenerator *generator;
[d9a0e76]72        };
[51b7345]73} // namespace ControlStruct
74
[51587aa]75// Local Variables: //
76// tab-width: 4 //
77// mode: c++ //
78// compile-command: "make install" //
79// End: //
Note: See TracBrowser for help on using the repository browser.