Skip to content

Commit

Permalink
minor PrimOp code enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
stepancheg committed Mar 30, 2013
1 parent 9313b1f commit b65cd86
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions compiler/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,8 +914,8 @@ EnvPtr ForeignStatement::getEnv() {

static map<int, string> primOpNames;

llvm::StringRef primOpName(const PrimOpPtr& x) {
map<int, string>::iterator i = primOpNames.find(x->primOpCode);
llvm::StringRef primOpName(PrimOpCode op) {
map<int, string>::iterator i = primOpNames.find(op);
assert(i != primOpNames.end());
return i->second;
}
Expand Down
10 changes: 7 additions & 3 deletions compiler/loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,16 @@ enum PrimOpCode {
};

struct PrimOp : public Object {
int primOpCode;
PrimOp(int primOpCode)
const PrimOpCode primOpCode;
PrimOp(PrimOpCode primOpCode)
: Object(PRIM_OP), primOpCode(primOpCode) {}
};

llvm::StringRef primOpName(const PrimOpPtr& x);
llvm::StringRef primOpName(PrimOpCode op);

static inline llvm::StringRef primOpName(const PrimOpPtr& x) {
return primOpName(x->primOpCode);
}

}

Expand Down

0 comments on commit b65cd86

Please sign in to comment.