Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_TOOLS_PROFILE_RESET_JTL_COMPILER_H_ | |
| 6 #define CHROME_TOOLS_PROFILE_RESET_JTL_COMPILER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 | |
| 12 // Compiles text-based JTL source code into JTL bytecode. | |
|
battre
2013/09/27 15:00:01
Please put a description of the source code syntax
engedy
2013/10/01 10:48:10
Done.
| |
| 13 class JtlCompiler { | |
| 14 public: | |
| 15 struct CompileError { | |
| 16 enum ErrorCode { | |
| 17 NO_ERROR, | |
| 18 PARSING_ERROR, | |
| 19 UNKNOWN_OPERATION, | |
| 20 INVALID_ARGUMENT_COUNT, | |
| 21 INVALID_ARGUMENT_TYPE, | |
| 22 }; | |
| 23 | |
| 24 CompileError() : line_number(0), error_code(NO_ERROR) {} | |
| 25 CompileError(size_t line_number, | |
| 26 const std::string& context, | |
| 27 ErrorCode error_code) | |
| 28 : line_number(line_number), context(context), error_code(error_code) {} | |
| 29 | |
| 30 size_t line_number; | |
| 31 std::string context; | |
| 32 ErrorCode error_code; | |
| 33 }; | |
| 34 | |
| 35 // Compiles text-based JTL source code contained in |source_code| into JTL | |
| 36 // byte-code to |output_bytecode|. Variable and node names will be hashed | |
| 37 // using the seed in |hash_seed|. On success, returns true. Otherwise, returns | |
| 38 // false and fills |error| with more information if it is non-NULL. | |
| 39 static bool Compile(const std::string& source_code, | |
| 40 const std::string& hash_seed, | |
| 41 std::string* output_bytecode, | |
| 42 CompileError* error); | |
| 43 | |
| 44 private: | |
| 45 DISALLOW_IMPLICIT_CONSTRUCTORS(JtlCompiler); | |
| 46 }; | |
| 47 | |
| 48 #endif // CHROME_TOOLS_PROFILE_RESET_JTL_COMPILER_H_ | |
| OLD | NEW |