1 //===-- evm/function.h - Class to represent a single basic block --*- C++ -*-===//
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
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"
19 template <typename T
, unsigned N
>
20 struct DynSlice
: public Slice
<T
> {
24 : Slice
<T
>(n
<= N
? _short_data
: new T
[n
], n
)
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
];
34 bool isLocalData() const { return this->_ptr
== _short_data
; }
37 } // end of namespace jitcs
40 // _JITCS_INT_ADT_DYNSLICE_H_