source: src/ControlStruct/LabelFixer.h @ a882b68

ADTast-experimental
Last change on this file since a882b68 was f8965f4, checked in by Thierry Delisle <tdelisle@…>, 2 years ago

Removed unnecessary throw lists

  • Property mode set to 100644
File size: 2.0 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
[51ec1ab]12// Last Modified On : Mon Jan 31 22:28:04 2022
13// Update Count     : 35
[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 {
[51ec1ab]28// normalizes label definitions and generates multi-level exit labels
29class LabelGenerator;
[d180746]30
[51ec1ab]31class LabelFixer final : public WithGuards {
32  public:
33        LabelFixer( LabelGenerator *gen = 0 );
[a08ba92]34
[f8965f4]35        std::map < Label, Statement * > *resolveJumps();
[a08ba92]36
[51ec1ab]37        // Declarations
38        void previsit( FunctionDecl *functionDecl );
39        void postvisit( FunctionDecl *functionDecl );
[a08ba92]40
[51ec1ab]41        // Statements
42        void previsit( Statement *stmt );
43        void previsit( BranchStmt *branchStmt );
[1fbeebd]44
[51ec1ab]45        // Expressions
46        void previsit( LabelAddressExpr *addrExpr );
[a08ba92]47
[51ec1ab]48        Label setLabelsDef( std::list< Label > &, Statement *definition );
49        template< typename UsageNode >
50        void setLabelsUsg( Label, UsageNode *usage = 0 );
[d9a0e76]51
[51ec1ab]52  private:
53        class Entry {
54                public:
55                Entry( Statement *to ) : definition( to ) {}
56                bool defined() { return ( definition != 0 ); }
57                bool insideLoop();
[be5aa1b]58
[51ec1ab]59                Label get_label() const { return label; }
60                void set_label( Label lab ) { label = lab; }
[a08ba92]61
[51ec1ab]62                Statement *get_definition() const { return definition; }
63                void set_definition( Statement *def ) { definition = def; }
[0f8e4ac]64
[51ec1ab]65          private:
66                Label label;
67                Statement *definition;
[d9a0e76]68        };
[51ec1ab]69
70        std::map < Label, Entry *> labelTable;
71        LabelGenerator *generator;
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.