2 // Copyright 2012 Francisco Jerez
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 // OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef CLOVER_CORE_MODULE_HPP
24 #define CLOVER_CORE_MODULE_HPP
26 #include "util/compat.hpp"
30 typedef uint32_t resource_id;
31 typedef uint32_t size_t;
42 section(resource_id id, enum type type, size_t size,
43 const compat::vector<char> &data) :
44 id(id), type(type), size(size), data(data) { }
45 section() : id(0), type(text), size(0), data() { }
50 compat::vector<char> data;
71 argument(enum type type, size_t size,
72 size_t target_size, size_t target_align,
73 enum ext_type ext_type) :
74 type(type), size(size),
75 target_size(target_size), target_align(target_align),
76 ext_type(ext_type) { }
78 argument(enum type type, size_t size) :
79 type(type), size(size),
80 target_size(size), target_align(1),
81 ext_type(zero_ext) { }
83 argument() : type(scalar), size(0),
84 target_size(0), target_align(1),
85 ext_type(zero_ext) { }
95 symbol(const compat::vector<char> &name, resource_id section,
96 size_t offset, const compat::vector<argument> &args) :
97 name(name), section(section), offset(offset), args(args) { }
98 symbol() : name(), section(0), offset(0), args() { }
100 compat::vector<char> name;
103 compat::vector<argument> args;
106 void serialize(compat::ostream &os) const;
107 static module deserialize(compat::istream &is);
110 compat::vector<symbol> syms;
111 compat::vector<section> secs;