Debian Codegraph @

js/src/irregexp/imported/regexp-bytecode-generator-inl.h

raw
1 // Copyright 2008-2009 the V8 project 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 V8_REGEXP_REGEXP_BYTECODE_GENERATOR_INL_H_
6 #define V8_REGEXP_REGEXP_BYTECODE_GENERATOR_INL_H_
7
8 #include "irregexp/imported/regexp-bytecode-generator.h"
9
10 #include "irregexp/imported/regexp-bytecodes.h"
11
12 namespace v8 {
13 namespace internal {
14
15 void RegExpBytecodeGenerator::Emit(uint32_t byte, uint32_t twenty_four_bits) {
16 DCHECK(is_uint24(twenty_four_bits));
17 Emit32((twenty_four_bits << BYTECODE_SHIFT) | byte);
18 }
19
20 void RegExpBytecodeGenerator::Emit(uint32_t byte, int32_t twenty_four_bits) {
21 DCHECK(is_int24(twenty_four_bits));
22 Emit32((static_cast<uint32_t>(twenty_four_bits) << BYTECODE_SHIFT) | byte);
23 }
24
25 void RegExpBytecodeGenerator::Emit16(uint32_t word) {
26 DCHECK(pc_ <= static_cast<int>(buffer_.size()));
27 if (pc_ + 1 >= static_cast<int>(buffer_.size())) {
28 ExpandBuffer();
29 }
30 *reinterpret_cast<uint16_t*>(buffer_.data() + pc_) = word;
31 pc_ += 2;
32 }
33
34 void RegExpBytecodeGenerator::Emit8(uint32_t word) {
35 DCHECK(pc_ <= static_cast<int>(buffer_.size()));
36 if (pc_ == static_cast<int>(buffer_.size())) {
37 ExpandBuffer();
38 }
39 *reinterpret_cast<unsigned char*>(buffer_.data() + pc_) = word;
40 pc_ += 1;
41 }
42
43 void RegExpBytecodeGenerator::Emit32(uint32_t word) {
44 DCHECK(pc_ <= static_cast<int>(buffer_.size()));
45 if (pc_ + 3 >= static_cast<int>(buffer_.size())) {
46 ExpandBuffer();
47 }
48 *reinterpret_cast<uint32_t*>(buffer_.data() + pc_) = word;
49 pc_ += 4;
50 }
51
52 } // namespace internal
53 } // namespace v8
54
55 #endif // V8_REGEXP_REGEXP_BYTECODE_GENERATOR_INL_H_