//
// The LLVM Compiler Infrastructure
//
-// This file was developed by Chris Lattner and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//
//===----------------------------------------------------------------------===//
+#include <algorithm>
+
#include "TGParser.h"
#include "Record.h"
#include "llvm/ADT/StringExtras.h"
if (RV->setValue(V))
return Error(Loc, "Value '" + ValName + "' of type '" +
RV->getType()->getAsString() +
- "' is incompatible with initializer ''"); // FIXME: Add init!
+ "' is incompatible with initializer '" + V->getAsString() +"'");
return false;
}
/// AddSubClass - Add SubClass as a subclass to CurRec, resolving its template
/// args as SubClass's template arguments.
-bool TGParser::AddSubClass(Record *CurRec, class SubClassReference &SubClass) {
+bool TGParser::AddSubClass(Record *CurRec, SubClassReference &SubClass) {
Record *SC = SubClass.Rec;
// Add all of the values in the subclass into the current class.
const std::vector<RecordVal> &Vals = SC->getValues();
/// RangePiece ::= INTVAL '-' INTVAL
/// RangePiece ::= INTVAL INTVAL
bool TGParser::ParseRangePiece(std::vector<unsigned> &Ranges) {
- assert(Lex.getCode() == tgtok::IntVal && "Invalid range");
- int Start = Lex.getCurIntVal();
- int End;
+ if (Lex.getCode() != tgtok::IntVal) {
+ TokError("expected integer or bitrange");
+ return true;
+ }
+ int64_t Start = Lex.getCurIntVal();
+ int64_t End;
if (Start < 0)
return TokError("invalid range, cannot be negative");
TokError("expected integer in bits<n> type");
return 0;
}
- unsigned Val = Lex.getCurIntVal();
+ uint64_t Val = Lex.getCurIntVal();
if (Lex.Lex() != tgtok::greater) { // Eat count.
TokError("expected '>' at end of bits<n> type");
return 0;
for (unsigned i = 0, e = Vals.size(); i != e; ++i) {
Init *Bit = Vals[i]->convertInitializerTo(new BitRecTy());
if (Bit == 0) {
- // FIXME: Include value in error.
- Error(BraceLoc, "Element #" + utostr(i) + " ("/* << *Vals[i]
- <<*/ ") is not convertable to a bit");
+ Error(BraceLoc, "Element #" + utostr(i) + " (" + Vals[i]->getAsString()+
+ ") is not convertable to a bit");
return 0;
}
Result->setBit(Vals.size()-i-1, Bit);
}
case tgtok::l_paren: { // Value ::= '(' IDValue DagArgList ')'
Lex.Lex(); // eat the '('
+ if (Lex.getCode() != tgtok::Id) {
+ TokError("expected identifier in dag init");
+ return 0;
+ }
+
Init *Operator = ParseIDValue(CurRec);
if (Operator == 0) return 0;
return 0;
}
if (!Result->getFieldType(Lex.getCurStrVal())) {
- // FIXME INCLUDE VALUE IN ERROR.
TokError("Cannot access field '" + Lex.getCurStrVal() + "' of value '" +
- /*<< *$1 <<*/ "'");
+ Result->getAsString() + "'");
return 0;
}
Result = new FieldInit(Result, Lex.getCurStrVal());