aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode/Reader
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Bytecode/Reader')
-rw-r--r--lib/Bytecode/Reader/ConstantReader.cpp4
-rw-r--r--lib/Bytecode/Reader/Reader.cpp17
2 files changed, 9 insertions, 12 deletions
diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp
index b85bd887ef..dd47d1c2cf 100644
--- a/lib/Bytecode/Reader/ConstantReader.cpp
+++ b/lib/Bytecode/Reader/ConstantReader.cpp
@@ -156,7 +156,7 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf,
unsigned Slot;
if (read_vbr(Buf, EndBuf, Slot)) return true;
Value *V = getValue(AT->getElementType(), Slot, false);
- if (!V || V->getValueType() != Value::ConstantVal)
+ if (!V || !V->isConstant())
return true;
Elements.push_back((ConstPoolVal*)V);
}
@@ -173,7 +173,7 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf,
unsigned Slot;
if (read_vbr(Buf, EndBuf, Slot)) return true;
Value *V = getValue(ET[i], Slot, false);
- if (!V || V->getValueType() != Value::ConstantVal)
+ if (!V || !V->isConstant())
return true;
Elements.push_back((ConstPoolVal*)V);
}
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index c3f4c907fe..e8bf17e604 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -46,11 +46,8 @@ const Type *BytecodeParser::getType(unsigned ID) {
const Value *D = getValue(Type::TypeTy, ID, false);
if (D == 0) return 0;
- assert(D->getType() == Type::TypeTy &&
- D->getValueType() == Value::ConstantVal);
-
-
- return ((const ConstPoolType*)D)->getValue();;
+ assert(D->getType() == Type::TypeTy);
+ return ((const ConstPoolType*)D->castConstantAsserting())->getValue();
}
bool BytecodeParser::insertValue(Value *Def, vector<ValueList> &ValueTab) {
@@ -63,7 +60,7 @@ bool BytecodeParser::insertValue(Value *Def, vector<ValueList> &ValueTab) {
//cerr << "insertValue Values[" << type << "][" << ValueTab[type].size()
// << "] = " << Def << endl;
- if (type == Type::TypeTyID && Def->getValueType() == Value::ConstantVal) {
+ if (type == Type::TypeTyID && Def->isConstant()) {
const Type *Ty = ((const ConstPoolType*)Def)->getValue();
unsigned ValueOffset = FirstDerivedTyID;
@@ -123,7 +120,7 @@ Value *BytecodeParser::getValue(const Type *Ty, unsigned oNum, bool Create) {
bool BytecodeParser::postResolveValues(ValueTable &ValTab) {
bool Error = false;
- for (unsigned ty = 0; ty < ValTab.size(); ty++) {
+ for (unsigned ty = 0; ty < ValTab.size(); ++ty) {
ValueList &DL = ValTab[ty];
unsigned Size;
while ((Size = DL.size())) {
@@ -180,7 +177,7 @@ bool BytecodeParser::ParseSymbolTable(const uchar *&Buf, const uchar *EndBuf) {
const Type *Ty = getType(Typ);
if (Ty == 0) return true;
- for (unsigned i = 0; i < NumEntries; i++) {
+ for (unsigned i = 0; i < NumEntries; ++i) {
// Symtab entry: [def slot #][name]
unsigned slot;
if (read_vbr(Buf, EndBuf, slot)) return true;
@@ -211,7 +208,7 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf,
const MethodType::ParamTypes &Params = MTy->getParamTypes();
for (MethodType::ParamTypes::const_iterator It = Params.begin();
- It != Params.end(); It++) {
+ It != Params.end(); ++It) {
MethodArgument *MA = new MethodArgument(*It);
if (insertValue(MA, Values)) { delete M; return true; }
M->getArgumentList().push_back(MA);
@@ -267,7 +264,7 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf,
Value *MethPHolder = getValue(MTy, MethSlot, false);
assert(MethPHolder && "Something is broken no placeholder found!");
- assert(MethPHolder->getValueType() == Value::MethodVal && "Not a method?");
+ assert(MethPHolder->isMethod() && "Not a method?");
unsigned type; // Type slot
assert(!getTypeSlot(MTy, type) && "How can meth type not exist?");