mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-03 08:51:43 +00:00
Remove dependence on command line library. Silly anyway.
llvm-svn: 271
This commit is contained in:
parent
31f1e5ffa3
commit
350f414175
@ -12,19 +12,19 @@
|
||||
// The useful interface defined by this file... Parse an ascii file, and return
|
||||
// the internal representation in a nice slice'n'dice'able representation.
|
||||
//
|
||||
Module *ParseAssemblyFile(const ToolCommandLine &Opts) throw (ParseException) {
|
||||
Module *ParseAssemblyFile(const string &Filename) throw (ParseException) {
|
||||
FILE *F = stdin;
|
||||
|
||||
if (Opts.getInputFilename() != "-")
|
||||
F = fopen(Opts.getInputFilename().c_str(), "r");
|
||||
if (Filename != "-")
|
||||
F = fopen(Filename.c_str(), "r");
|
||||
|
||||
if (F == 0) {
|
||||
throw ParseException(Opts, string("Could not open file '") +
|
||||
Opts.getInputFilename() + "'");
|
||||
throw ParseException(Filename, string("Could not open file '") +
|
||||
Filename + "'");
|
||||
}
|
||||
|
||||
// TODO: If this throws an exception, F is not closed.
|
||||
Module *Result = RunVMAsmParser(Opts, F);
|
||||
Module *Result = RunVMAsmParser(Filename, F);
|
||||
|
||||
if (F != stdin)
|
||||
fclose(F);
|
||||
@ -38,7 +38,7 @@ Module *ParseAssemblyFile(const ToolCommandLine &Opts) throw (ParseException) {
|
||||
for (unsigned i = 0; i < Errors.size(); i++)
|
||||
Message += Errors[i] + "\n";
|
||||
|
||||
throw ParseException(Opts, Message);
|
||||
throw ParseException(Filename, Message);
|
||||
}
|
||||
}
|
||||
return Result;
|
||||
@ -50,14 +50,14 @@ Module *ParseAssemblyFile(const ToolCommandLine &Opts) throw (ParseException) {
|
||||
//===------------------------------------------------------------------------===
|
||||
|
||||
|
||||
ParseException::ParseException(const ToolCommandLine &opts,
|
||||
const string &message, int lineNo, int colNo)
|
||||
: Opts(opts), Message(message) {
|
||||
ParseException::ParseException(const string &filename, const string &message,
|
||||
int lineNo, int colNo)
|
||||
: Filename(filename), Message(message) {
|
||||
LineNo = lineNo; ColumnNo = colNo;
|
||||
}
|
||||
|
||||
ParseException::ParseException(const ParseException &E)
|
||||
: Opts(E.Opts), Message(E.Message) {
|
||||
: Filename(E.Filename), Message(E.Message) {
|
||||
LineNo = E.LineNo;
|
||||
ColumnNo = E.ColumnNo;
|
||||
}
|
||||
@ -66,10 +66,10 @@ const string ParseException::getMessage() const { // Includes info from options
|
||||
string Result;
|
||||
char Buffer[10];
|
||||
|
||||
if (Opts.getInputFilename() == "-")
|
||||
if (Filename == "-")
|
||||
Result += "<stdin>";
|
||||
else
|
||||
Result += Opts.getInputFilename();
|
||||
Result += Filename;
|
||||
|
||||
if (LineNo != -1) {
|
||||
sprintf(Buffer, "%d", LineNo);
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "llvm/Method.h"
|
||||
#include "llvm/Type.h"
|
||||
#include "llvm/Assembly/Parser.h"
|
||||
#include "llvm/Tools/CommandLine.h"
|
||||
#include "llvm/Tools/StringExtras.h"
|
||||
|
||||
class Module;
|
||||
@ -28,8 +27,8 @@ extern FILE *llvmAsmin;
|
||||
extern int llvmAsmlineno;
|
||||
|
||||
// Globals exported by the parser...
|
||||
extern const ToolCommandLine *CurOptions;
|
||||
Module *RunVMAsmParser(const ToolCommandLine &Opts, FILE *F);
|
||||
extern string CurFilename;
|
||||
Module *RunVMAsmParser(const string &Filename, FILE *F);
|
||||
|
||||
|
||||
// ThrowException - Wrapper around the ParseException class that automatically
|
||||
@ -40,7 +39,7 @@ Module *RunVMAsmParser(const ToolCommandLine &Opts, FILE *F);
|
||||
//
|
||||
static inline void ThrowException(const string &message) {
|
||||
// TODO: column number in exception
|
||||
throw ParseException(*CurOptions, message, llvmAsmlineno);
|
||||
throw ParseException(CurFilename, message, llvmAsmlineno);
|
||||
}
|
||||
|
||||
// ValID - Represents a reference of a definition of some sort. This may either
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,7 @@ int yylex(); // declaration" of xxx warnings.
|
||||
int yyparse();
|
||||
|
||||
static Module *ParserResult;
|
||||
const ToolCommandLine *CurOptions = 0;
|
||||
string CurFilename;
|
||||
|
||||
// This contains info used when building the body of a method. It is destroyed
|
||||
// when the method is completed.
|
||||
@ -367,15 +367,14 @@ static const Type *checkNewType(const Type *Ty) {
|
||||
// RunVMAsmParser - Define an interface to this parser
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
Module *RunVMAsmParser(const ToolCommandLine &Opts, FILE *F) {
|
||||
Module *RunVMAsmParser(const string &Filename, FILE *F) {
|
||||
llvmAsmin = F;
|
||||
CurOptions = &Opts;
|
||||
CurFilename = Filename;
|
||||
llvmAsmlineno = 1; // Reset the current line number...
|
||||
|
||||
CurModule.CurrentModule = new Module(); // Allocate a new module to read
|
||||
yyparse(); // Parse the file.
|
||||
Module *Result = ParserResult;
|
||||
CurOptions = 0;
|
||||
llvmAsmin = stdin; // F is about to go away, don't use it anymore...
|
||||
ParserResult = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user