#include "ir/ir.h"
#include "sema/sema.h"

using namespace std;
using namespace empathy;
using namespace empathy::util;

int main( int argc, char** argv )
{
    // Just a dumping place for simple test code for now.
    auto gg = TVEC( TSTR( "bar" ), TSID( gg ), VECOFLENGTH( N ), REPEAT( ANYTERM( U ) ) );
    cout << gg << endl;

    ir::Trie<> testTrie;
    testTrie = Merge( testTrie, gg );
    testTrie = Merge( testTrie, TVEC( TSID( blah ), TSTR( "bar" ) ) );
    testTrie = Merge( testTrie, TVEC( TSID( foo ), TSTR( "bar" ) ) );
    testTrie = Merge( testTrie, TVEC( TSID( blah ), TSTR( "meh" ) ) );
    auto testTrie2 = testTrie;
    testTrie = Merge( testTrie, TSTR( "bar" ) );
    testTrie = Merge( testTrie, TSTR( "foo" ) );
    testTrie = Merge( testTrie, TVEC() );
    testTrie = Merge( testTrie, TVEC( TSID( gg ) ) );

    ir::GraphVizDump( "dump2.dot", testTrie );

    for( auto&& t : Enumerate( testTrie ) )
        cout << t << endl;

    cout << Compare( testTrie, testTrie2 ) << endl;
    cout << Compare( testTrie2, testTrie2 ) << endl;
    cout << Compare( testTrie, testTrie ) << endl;

    cout << "\n";

    sema::Hole testHole1( "A"_sid );
    sema::Hole testHole2( 1234 );
    auto holeExpr1 = sema::HoleToIRExpr( testHole1 );
    cout << holeExpr1 << endl;
    auto holeExpr2 = sema::HoleToIRExpr( testHole2 );
    cout << holeExpr2 << endl;

    auto testHole = sema::HoleFromIRExpr( holeExpr1 );
    cout << testHole.has_value() << endl;
    cout << sema::HoleToIRExpr( *testHole ) << endl;

    testHole = sema::HoleFromIRExpr( holeExpr2 );
    cout << testHole.has_value() << endl;
    cout << sema::HoleToIRExpr( *testHole ) << endl;

    return EXIT_SUCCESS;
}
