40 void PrintF(
const char* format, ...) {
42 va_start(arguments, format);
48 void PrintF(FILE* out,
const char* format, ...) {
50 va_start(arguments, format);
59 va_start(arguments, format);
74 bool keep_going =
true;
75 fprintf(stdout,
"%s", prompt);
78 if (fgets(line_buf,
sizeof(line_buf), stdin) ==
NULL) {
87 line_buf[len - 2] ==
'\\' &&
88 line_buf[len - 1] ==
'\n') {
91 line_buf[len - 2] =
'\n';
92 line_buf[len - 1] = 0;
94 }
else if ((len > 0) && (line_buf[len - 1] ==
'\n')) {
101 result = NewArray<char>(len + 1);
104 int new_len = offset + len + 1;
105 char* new_result = NewArray<char>(new_len);
108 memcpy(new_result, result, offset *
kCharSize);
113 memcpy(result + offset, line_buf, len *
kCharSize);
117 result[offset] =
'\0';
126 const char* filename) {
127 if (file ==
NULL || fseek(file, 0, SEEK_END) != 0) {
138 char* result = NewArray<char>(*size + extra_space);
139 for (
int i = 0; i < *size && feof(file) == 0;) {
140 int read =
static_cast<int>(fread(&result[i], 1, *size - i, file));
141 if (read != (*size - i) && ferror(file) != 0) {
158 if (file !=
NULL) fclose(file);
165 return reinterpret_cast<byte*
>(chars);
169 static Vector<const char> SetVectorContents(
char* chars,
178 return Vector<const char>(chars, size);
187 return SetVectorContents(result, size, exists);
196 return SetVectorContents(result, size, exists);
202 while (total < size) {
203 int write =
static_cast<int>(fwrite(str, 1, size - total, f));
252 const char* str =
reinterpret_cast<const char*
>(bytes);
253 return WriteChars(filename, str, size, verbose);
260 va_start(arguments, format);
281 remove_file_on_cleanup_(
false) {
288 bool remove_file_on_cleanup)
292 remove_file_on_cleanup_(remove_file_on_cleanup) {
301 if (remove_file_on_cleanup_) {
304 DeleteArray<char>(filename_);
309 void MemoryMappedExternalResource::Init(
const char* filename) {
312 filename_ =
StrDup(filename);
313 data_ =
reinterpret_cast<char*
>(file_->
memory());
314 length_ = file_->
size();
320 bool is_ascii =
true;
323 const char* start_of_line = data_;
324 const char* end = data_ + length_;
325 for (
const char* p = data_; p < end; p++) {
327 if ((c & 0x80) != 0) {
332 if (abort_if_failed) {
333 int char_no =
static_cast<int>(p - start_of_line) - 1;
337 "Abort: Non-Ascii character 0x%.2x in file %s line %d char %d",
338 c, filename_, line_no, char_no);
343 const int kNumberOfLeadingContextChars = 10;
344 const char* err_context = p - kNumberOfLeadingContextChars;
345 if (err_context < data_) {
349 int err_context_length =
static_cast<int>(p - err_context);
350 if (err_context_length != 0) {
351 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,...)
static int GetCurrentProcessId()
int WriteCharsToFile(const char *str, int size, FILE *f)
activate correct semantics for inheriting readonliness false
int StrLength(const char *string)
static void Print(const char *format,...)
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,...)
void PrintPID(const char *format,...)
static Vector< T > empty()
virtual ~MemoryMappedExternalResource()
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 use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit extra verbose compilation tracing generate extra 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 and VFP2 enable use of VFP2 instructions if available enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of MIPS FPU instructions if NULL
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)