source: src/ControlStruct/LabelFixer.h @ 4b0f997

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 4b0f997 was 62e5546, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

Removed warnings when compiling with clang

  • Property mode set to 100644
File size: 3.3 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
[4e06c1e]12// Last Modified On : Tue Jul 12 17:36:16 2016
13// Update Count     : 33
[51587aa]14//
[a08ba92]15
[51b7345]16#ifndef LABEL_FIXER_H
17#define LABEL_FIXER_H
18
[d3b7937]19#include "Common/utility.h"
[51b7345]20#include "SynTree/SynTree.h"
21#include "SynTree/Visitor.h"
[0f8e4ac]22#include "SynTree/Label.h"
[51b7345]23#include "LabelGenerator.h"
24#include <map>
25
26namespace ControlStruct {
[82dd287]27        /// normalizes label definitions and generates multi-level exit labels
[62e5546]28        class LabelFixer final : public Visitor {
[a08ba92]29                typedef Visitor Parent;
[d9a0e76]30          public:
[a08ba92]31                LabelFixer( LabelGenerator *gen = 0 );
32
33                std::map < Label, Statement * > *resolveJumps() throw ( SemanticError );
34
[62e5546]35                using Visitor::visit;
36
[a08ba92]37                // Declarations
[62e5546]38                virtual void visit( FunctionDecl *functionDecl ) override;
[a08ba92]39
40                // Statements
41                void visit( Statement *stmt );
42
[62e5546]43                virtual void visit( CompoundStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
44                virtual void visit( NullStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
45                virtual void visit( ExprStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
46                virtual void visit( IfStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
47                virtual void visit( WhileStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
48                virtual void visit( ForStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
49                virtual void visit( SwitchStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
50                virtual void visit( CaseStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
51                virtual void visit( ReturnStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
52                virtual void visit( TryStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
53                virtual void visit( CatchStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
54                virtual void visit( DeclStmt *stmt ) override { visit( (Statement *)stmt ); return Parent::visit( stmt ); }
55                virtual void visit( BranchStmt *branchStmt ) override;
56                virtual void visit( UntypedExpr *untyped ) override;
[a08ba92]57
58                Label setLabelsDef( std::list< Label > &, Statement *definition );
[1869adf]59                template< typename UsageNode >
60                void setLabelsUsg( Label, UsageNode *usage = 0 );
[d9a0e76]61
62          private:
[a08ba92]63                class Entry {
[1869adf]64                        public:
65                        Entry( Statement *to ) : definition( to ) {}
[a08ba92]66                        bool defined() { return ( definition != 0 ); }
67                        bool insideLoop();
68
69                        Label get_label() const { return label; }
[be5aa1b]70                        void set_label( Label lab ) { label = lab; }
71
[a08ba92]72                        Statement *get_definition() const { return definition; }
[be5aa1b]73                        void set_definition( Statement *def ) { definition = def; }
[a08ba92]74
75                  private:
[0f8e4ac]76                        Label label;
[a08ba92]77                        Statement *definition;
78                };
[0f8e4ac]79
[a08ba92]80                std::map < Label, Entry *> labelTable;
81                LabelGenerator *generator;
[d9a0e76]82        };
[51b7345]83} // namespace ControlStruct
84
[d9a0e76]85#endif // LABEL_FIXER_H
[51b7345]86
[51587aa]87// Local Variables: //
88// tab-width: 4 //
89// mode: c++ //
90// compile-command: "make install" //
91// End: //
Note: See TracBrowser for help on using the repository browser.