diff options
author | Chris Lattner <sabre@nondot.org> | 2001-07-28 17:48:55 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-07-28 17:48:55 +0000 |
commit | 93750fa4f8dac54383c2dcad48a313e6e2d03598 (patch) | |
tree | 7be9644c8ff1b569c075c92b2f2aeceec3b88657 /lib/AsmParser/ParserInternals.h | |
parent | 0add2d33e414c9627cf5e656760a890101a8ce1e (diff) |
* Enable the use of escaped literal strings
* Unresolved variable names now have the correct line number for their
error messages
* Rename Def* to Value*
* Check for symbol table collisions before inserting values
* Remove the STRING keyword
* Enable the use of string literals to initialize constant arrays
* Enable the use of extended constants in more locations: eg ret [int] [4, 5]
* Allow method prototypes to appear in the constant pool of the program
* Support varargs methods better. Enable varargs methods with 0 fixed
arguments
* Allow the entire method prototype to optionally be specified in a call inst
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/ParserInternals.h')
-rw-r--r-- | lib/AsmParser/ParserInternals.h | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/lib/AsmParser/ParserInternals.h b/lib/AsmParser/ParserInternals.h index 1f6bafce15..0a99e4d238 100644 --- a/lib/AsmParser/ParserInternals.h +++ b/lib/AsmParser/ParserInternals.h @@ -31,15 +31,27 @@ extern string CurFilename; Module *RunVMAsmParser(const string &Filename, FILE *F); +// UnEscapeLexed - Run through the specified buffer and change \xx codes to the +// appropriate character. If AllowNull is set to false, a \00 value will cause +// an exception to be thrown. +// +// If AllowNull is set to true, the return value of the function points to the +// last character of the string in memory. +// +char *UnEscapeLexed(char *Buffer, bool AllowNull = false); + + // ThrowException - Wrapper around the ParseException class that automatically // fills in file line number and column number and options info. // // This also helps me because I keep typing 'throw new ParseException' instead // of just 'throw ParseException'... sigh... // -static inline void ThrowException(const string &message) { +static inline void ThrowException(const string &message, + int LineNo = -1) { + if (LineNo == -1) LineNo = llvmAsmlineno; // TODO: column number in exception - throw ParseException(CurFilename, message, llvmAsmlineno); + throw ParseException(CurFilename, message, LineNo); } // ValID - Represents a reference of a definition of some sort. This may either @@ -111,13 +123,15 @@ struct ValID { template<class SuperType> -class PlaceholderDef : public SuperType { +class PlaceholderValue : public SuperType { ValID D; - // TODO: Placeholder def should hold Line #/Column # of definition in case - // there is an error resolving the defintition! + int LineNum; public: - PlaceholderDef(const Type *Ty, const ValID &d) : SuperType(Ty), D(d) {} + PlaceholderValue(const Type *Ty, const ValID &d) : SuperType(Ty), D(d) { + LineNum = llvmAsmlineno; + } ValID &getDef() { return D; } + int getLineNum() const { return LineNum; } }; struct InstPlaceHolderHelper : public Instruction { @@ -140,17 +154,23 @@ struct MethPlaceHolderHelper : public Method { } }; -typedef PlaceholderDef<InstPlaceHolderHelper> DefPlaceHolder; -typedef PlaceholderDef<BBPlaceHolderHelper> BBPlaceHolder; -typedef PlaceholderDef<MethPlaceHolderHelper> MethPlaceHolder; -//typedef PlaceholderDef<ModulePlaceHolderHelper> ModulePlaceHolder; - -static inline ValID &getValIDFromPlaceHolder(Value *Def) { - switch (Def->getType()->getPrimitiveID()) { - case Type::LabelTyID: return ((BBPlaceHolder*)Def)->getDef(); - case Type::MethodTyID: return ((MethPlaceHolder*)Def)->getDef(); -//case Type::ModuleTyID: return ((ModulePlaceHolder*)Def)->getDef(); - default: return ((DefPlaceHolder*)Def)->getDef(); +typedef PlaceholderValue<InstPlaceHolderHelper> ValuePlaceHolder; +typedef PlaceholderValue<BBPlaceHolderHelper> BBPlaceHolder; +typedef PlaceholderValue<MethPlaceHolderHelper> MethPlaceHolder; + +static inline ValID &getValIDFromPlaceHolder(Value *Val) { + switch (Val->getType()->getPrimitiveID()) { + case Type::LabelTyID: return ((BBPlaceHolder*)Val)->getDef(); + case Type::MethodTyID: return ((MethPlaceHolder*)Val)->getDef(); + default: return ((ValuePlaceHolder*)Val)->getDef(); + } +} + +static inline int getLineNumFromPlaceHolder(Value *Val) { + switch (Val->getType()->getPrimitiveID()) { + case Type::LabelTyID: return ((BBPlaceHolder*)Val)->getLineNum(); + case Type::MethodTyID: return ((MethPlaceHolder*)Val)->getLineNum(); + default: return ((ValuePlaceHolder*)Val)->getLineNum(); } } |