Changed current relation from BasicBlock to BasicBlockImpl, and Function
[jitcs.git] / src / jitcs_int_adt_dynslice.h
blobdf02e9c85e8d302499d25906d8054f1fec0d00b5
1 //===-- evm/function.h - Class to represent a single basic block --*- C++ -*-===//
2 //
3 // A basicblock contains nodes, and must end in a terminal instruction node.
4 // Nodes can be instructions, constants. Each node may produce more than one
5 // result.
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef _JITCS_INT_ADT_DYNSLICE_H_
10 #define _JITCS_INT_ADT_DYNSLICE_H_
12 #include "jitcs_base.h"
13 #include "jitcs_typefuncs.h"
14 #include "jitcs_adt_slice.h"
16 namespace jitcs {
17 class TempAllocator;
19 template <typename T, unsigned N>
20 struct DynSlice : public Slice<T> {
21 T _short_data[N];
23 DynSlice(size_t n)
24 : Slice<T>(n <= N ? _short_data : new T[n], n)
26 ~DynSlice() {
27 if (!isLocalData()) delete[] this->_ptr;
29 void reinit(size_t n) {
30 if (!isLocalData()) delete[] this->_ptr;
31 this->_ptr = n <= N ? _short_data : new T[n];
32 this->_size = n;
34 bool isLocalData() const { return this->_ptr == _short_data; }
37 } // end of namespace jitcs
39 #endif
40 // _JITCS_INT_ADT_DYNSLICE_H_