/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 * 
 * Author: pgess <v.melnychenko@xreate.org>
 * 
 * dfapass.h
 * Data Flow Graph building pass
 */

#ifndef DFGPASS_H
#define DFGPASS_H

#include "abstractpass.h"
#include "analysis/dfagraph.h"

namespace xreate {
    class ClaspLayer;
}

namespace xreate { namespace dfa {
class DfaExpressionProcessor;

/** \brief Data Flow Analysis Pass(%DFA) */
class DFAPass: public AbstractPass<SymbolPacked> {
    friend class DfaExpressionProcessor;
    
public:
    DFAPass(PassManager* manager);
    
    SymbolPacked processSymbol(const Symbol& symbol, PassContext context, const std::string& hintSymbol="") override;
    SymbolPacked process(CodeScope* scope, PassContext context, const std::string& hintBlockDecl="") override;

    void init();
    void run() override;
    void finish() override;
    
private:
    struct 
    {
      DFAGraph* graph;
    } __context;
    
    std::map<Operator, Expression> __signatures;		//DFA data for particular operators
    ClaspLayer* clasp;
};

}}  //end of xreate::dfa  namespace

#endif
