Ignore:
Timestamp:
Jul 16, 2015, 3:46:58 PM (4 years ago)
Author:
nmedfort
Message:

First attempt to add arguments to Call objects. Currently non-functioning in Pablo_Compiler.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/builder.cpp

    r4680 r4681  
    2727PabloAST * result = mExprTable.findUnaryOrCall(std::move(functor), TYPE, ARGS)
    2828
     29#define MAKE_UNARY_VARIABLE(NAME, TYPE, ARGS...) \
     30struct __##NAME { \
     31    inline PabloAST * operator()(PabloAST * arg, const std::vector<PabloAST *> & args) { \
     32        return mPb->NAME(arg, args); \
     33    } \
     34    inline __##NAME(PabloBlock * pb) : mPb(pb) {} \
     35private: \
     36    PabloBlock * mPb; \
     37}; \
     38__##NAME functor(mPb); \
     39PabloAST * result = mExprTable.findUnaryVariableOrCall(std::move(functor), TYPE, ARGS)
     40
     41
    2942#define MAKE_BINARY(NAME, TYPE, ARGS...) \
    3043struct __##NAME { \
     
    7588PabloAST * result = mExprTable.findTernaryOrCall(std::move(functor), TYPE, ARGS)
    7689
    77 
    78 Call * PabloBuilder::createCall(Prototype * prototype) {
    79     MAKE_UNARY(createCall, PabloAST::ClassTypeId::Call, prototype);
     90#define MAKE_VARIABLE(NAME, TYPE, ARGS) \
     91struct __##NAME { \
     92    inline PabloAST * operator()(PabloAST * arg) { \
     93        return mPb->NAME(arg); \
     94    } \
     95    inline __##NAME(PabloBlock * pb) : mPb(pb) {} \
     96private: \
     97    PabloBlock * mPb; \
     98}; \
     99__##NAME functor(mPb); \
     100PabloAST * result = mExprTable.findUnaryOrCall(std::move(functor), TYPE, ARGS)
     101
     102
     103Call * PabloBuilder::createCall(Prototype * prototype, const std::vector<Var *> & args) {
     104    if (args.size() != cast<Prototype>(prototype)->getNumOfParameters()) {
     105        throw std::runtime_error("Invalid number of arguments passed into Call object!");
     106    }
     107    MAKE_UNARY_VARIABLE(createCall, PabloAST::ClassTypeId::Call, prototype, reinterpret_cast<const std::vector<PabloAST *> &>(args));
    80108    return cast<Call>(result);
    81109}
Note: See TracChangeset for help on using the changeset viewer.