Flutter Engine
The Flutter Engine
regexp_assembler_bytecode_inl.h
Go to the documentation of this file.
1// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5// A light-weight assembler for the Irregexp byte code.
6
8
9#ifndef RUNTIME_VM_REGEXP_ASSEMBLER_BYTECODE_INL_H_
10#define RUNTIME_VM_REGEXP_ASSEMBLER_BYTECODE_INL_H_
11
12namespace dart {
13
14void BytecodeRegExpMacroAssembler::Emit(uint32_t byte,
15 uint32_t twenty_four_bits) {
16 uint32_t word = ((twenty_four_bits << BYTECODE_SHIFT) | byte);
17 ASSERT(pc_ <= buffer_->length());
18 if (pc_ + 3 >= buffer_->length()) {
19 Expand();
20 }
21 *reinterpret_cast<uint32_t*>(buffer_->data() + pc_) = word;
22 pc_ += 4;
23}
24
25void BytecodeRegExpMacroAssembler::Emit16(uint32_t word) {
26 ASSERT(pc_ <= buffer_->length());
27 if (pc_ + 1 >= buffer_->length()) {
28 Expand();
29 }
30 *reinterpret_cast<uint16_t*>(buffer_->data() + pc_) = word;
31 pc_ += 2;
32}
33
34void BytecodeRegExpMacroAssembler::Emit8(uint32_t word) {
35 ASSERT(pc_ <= buffer_->length());
36 if (pc_ == buffer_->length()) {
37 Expand();
38 }
39 *reinterpret_cast<unsigned char*>(buffer_->data() + pc_) = word;
40 pc_ += 1;
41}
42
43void BytecodeRegExpMacroAssembler::Emit32(uint32_t word) {
44 ASSERT(pc_ <= buffer_->length());
45 if (pc_ + 3 >= buffer_->length()) {
46 Expand();
47 }
48 *reinterpret_cast<uint32_t*>(buffer_->data() + pc_) = word;
49 pc_ += 4;
50}
51
52} // namespace dart
53
54#endif // RUNTIME_VM_REGEXP_ASSEMBLER_BYTECODE_INL_H_
intptr_t length() const
#define ASSERT(E)
Definition: dart_vm.cc:33
const int BYTECODE_SHIFT
intptr_t word
Definition: globals.h:500