40 void PrintF(
const char* format, ...) {
42 va_start(arguments, format);
48 void PrintF(FILE* out,
const char* format, ...) {
50 va_start(arguments, format);
65 bool keep_going =
true;
66 fprintf(stdout,
"%s", prompt);
69 if (fgets(line_buf,
sizeof(line_buf), stdin) ==
NULL) {
78 line_buf[len - 2] ==
'\\' &&
79 line_buf[len - 1] ==
'\n') {
82 line_buf[len - 2] =
'\n';
83 line_buf[len - 1] = 0;
85 }
else if ((len > 0) && (line_buf[len - 1] ==
'\n')) {
92 result = NewArray<char>(len + 1);
95 int new_len = offset + len + 1;
96 char* new_result = NewArray<char>(new_len);
99 memcpy(new_result, result, offset *
kCharSize);
104 memcpy(result + offset, line_buf, len *
kCharSize);
108 result[offset] =
'\0';
117 const char* filename) {
118 if (file ==
NULL || fseek(file, 0, SEEK_END) != 0) {
129 char* result = NewArray<char>(*size + extra_space);
130 for (
int i = 0; i < *size && feof(file) == 0;) {
131 int read =
static_cast<int>(fread(&result[i], 1, *size - i, file));
132 if (read != (*size - i) && ferror(file) != 0) {
149 if (file !=
NULL) fclose(file);
156 return reinterpret_cast<byte*
>(chars);
160 static Vector<const char> SetVectorContents(
char* chars,
169 return Vector<const char>(chars, size);
178 return SetVectorContents(result, size, exists);
187 return SetVectorContents(result, size, exists);
193 while (total < size) {
194 int write =
static_cast<int>(fwrite(str, 1, size - total, f));
243 const char* str =
reinterpret_cast<const char*
>(bytes);
244 return WriteChars(filename, str, size, verbose);
251 va_start(arguments, format);
272 remove_file_on_cleanup_(
false) {
279 bool remove_file_on_cleanup)
283 remove_file_on_cleanup_(remove_file_on_cleanup) {
292 if (remove_file_on_cleanup_) {
295 DeleteArray<char>(filename_);
300 void MemoryMappedExternalResource::Init(
const char* filename) {
303 filename_ =
StrDup(filename);
304 data_ =
reinterpret_cast<char*
>(file_->
memory());
305 length_ = file_->
size();
311 bool is_ascii =
true;
314 const char* start_of_line = data_;
315 const char* end = data_ + length_;
316 for (
const char* p = data_; p < end; p++) {
318 if ((c & 0x80) != 0) {
323 if (abort_if_failed) {
324 int char_no =
static_cast<int>(p - start_of_line) - 1;
328 "Abort: Non-Ascii character 0x%.2x in file %s line %d char %d",
329 c, filename_, line_no, char_no);
334 const int kNumberOfLeadingContextChars = 10;
335 const char* err_context = p - kNumberOfLeadingContextChars;
336 if (err_context < data_) {
340 int err_context_length =
static_cast<int>(p - err_context);
341 if (err_context_length != 0) {
342 PrintF(
" after \"%.*s\"", err_context_length, err_context);
void PrintF(const char *format,...)
static int VSNPrintF(Vector< char > str, const char *format, va_list args)
char * ReadCharsFromFile(FILE *file, int *size, int extra_space, bool verbose, const char *filename)
#define ASSERT(condition)
static void VFPrint(FILE *out, const char *format, va_list args)
byte * ReadBytes(const char *filename, int *size, bool verbose)
char * ReadLine(const char *prompt)
static MemoryMappedFile * open(const char *name)
virtual void * memory()=0
bool is_finalized() const
Vector< const char > ReadFile(const char *filename, bool *exists, bool verbose)
static FILE * FOpen(const char *path, const char *mode)
static void VPrint(const char *format, va_list args)
void AddFormatted(const char *format,...)
int WriteCharsToFile(const char *str, int size, FILE *f)
int StrLength(const char *string)
bool EnsureIsAscii() const
void AddFormattedList(const char *format, va_list list)
int WriteChars(const char *filename, const char *str, int size, bool verbose)
int AppendChars(const char *filename, const char *str, int size, bool verbose)
static void PrintError(const char *format,...)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
static Vector< T > empty()
virtual ~MemoryMappedExternalResource()
char * StrDup(const char *str)
static bool Remove(const char *path)
int WriteBytes(const char *filename, const byte *bytes, int size, bool verbose)
void DeleteArray(T *array)
MemoryMappedExternalResource(const char *filename)