Index: chrome/tools/profile_reset/jtl_compiler.h |
diff --git a/chrome/tools/profile_reset/jtl_compiler.h b/chrome/tools/profile_reset/jtl_compiler.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c7738424a1900c623d8f378d29667932028689f9 |
--- /dev/null |
+++ b/chrome/tools/profile_reset/jtl_compiler.h |
@@ -0,0 +1,48 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_TOOLS_PROFILE_RESET_JTL_COMPILER_H_ |
+#define CHROME_TOOLS_PROFILE_RESET_JTL_COMPILER_H_ |
+ |
+#include <string> |
+ |
+#include "base/basictypes.h" |
+ |
+// 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.
|
+class JtlCompiler { |
+ public: |
+ struct CompileError { |
+ enum ErrorCode { |
+ NO_ERROR, |
+ PARSING_ERROR, |
+ UNKNOWN_OPERATION, |
+ INVALID_ARGUMENT_COUNT, |
+ INVALID_ARGUMENT_TYPE, |
+ }; |
+ |
+ CompileError() : line_number(0), error_code(NO_ERROR) {} |
+ CompileError(size_t line_number, |
+ const std::string& context, |
+ ErrorCode error_code) |
+ : line_number(line_number), context(context), error_code(error_code) {} |
+ |
+ size_t line_number; |
+ std::string context; |
+ ErrorCode error_code; |
+ }; |
+ |
+ // Compiles text-based JTL source code contained in |source_code| into JTL |
+ // byte-code to |output_bytecode|. Variable and node names will be hashed |
+ // using the seed in |hash_seed|. On success, returns true. Otherwise, returns |
+ // false and fills |error| with more information if it is non-NULL. |
+ static bool Compile(const std::string& source_code, |
+ const std::string& hash_seed, |
+ std::string* output_bytecode, |
+ CompileError* error); |
+ |
+ private: |
+ DISALLOW_IMPLICIT_CONSTRUCTORS(JtlCompiler); |
+}; |
+ |
+#endif // CHROME_TOOLS_PROFILE_RESET_JTL_COMPILER_H_ |