replicode
class.h
Go to the documentation of this file.
1 // class.h
2 //
3 // Author: Eric Nivel
4 //
5 // BSD license:
6 // Copyright (c) 2010, Eric Nivel
7 // All rights reserved.
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions are met:
10 //
11 // - Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // - Redistributions in binary form must reproduce the above copyright
14 // notice, this list of conditions and the following disclaimer in the
15 // documentation and/or other materials provided with the distribution.
16 // - Neither the name of Eric Nivel nor the
17 // names of their contributors may be used to endorse or promote products
18 // derived from this software without specific prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
21 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 // DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
24 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 #ifndef class_h
32 #define class_h
33 
34 #include "structure_member.h"
35 #include <vector>
36 
37 namespace r_comp {
38 
39 class Compiler;
40 
41 class Class {
42 private:
43  bool has_offset() const;
44 public:
45  static const char *Expression;
46  static const char *Type;
47 
48  Class(ReturnType t = ANY);
49  Class(Atom atom,
50  std::string str_opcode,
51  std::vector<StructureMember> r,
52  ReturnType t = ANY);
53  bool is_pattern(Metadata *metadata) const;
54  bool is_fact(Metadata *metadata) const;
55  bool get_member_index(Metadata *metadata, std::string &name, uint16_t &index, Class *&p) const;
56  std::string get_member_name(uint64_t index); // for decompilation
57  ReturnType get_member_type(const uint16_t index);
58  Class *get_member_class(Metadata *metadata, const std::string &name);
60  std::string str_opcode; // unused for anything but objects, markers and operators.
61  std::vector<StructureMember> things_to_read;
62  ReturnType type; // ANY for non-operators.
64 
65  void write(uintptr_t *storage);
66  void read(uintptr_t *storage);
67  size_t get_size();
68 };
69 }
70 
71 
72 #endif
ReturnType
Definition: structure_member.h:48
Definition: class.h:41
Class(ReturnType t=ANY)
Definition: class.cpp:53
void write(uintptr_t *storage)
Definition: class.cpp:109
bool is_pattern(Metadata *metadata) const
Definition: class.cpp:66
static const char * Type
Definition: class.h:46
Definition: segments.h:59
bool has_offset() const
Definition: class.cpp:40
Class * get_member_class(Metadata *metadata, const std::string &name)
Definition: class.cpp:101
std::vector< StructureMember > things_to_read
Definition: class.h:61
size_t get_size()
Definition: class.cpp:141
dll_export r_comp::Compiler Compiler
Definition: init.cpp:66
Definition: atom.h:45
Definition: structure_member.h:49
ReturnType get_member_type(const uint16_t index)
Definition: class.cpp:96
void read(uintptr_t *storage)
Definition: class.cpp:124
bool get_member_index(Metadata *metadata, std::string &name, uint16_t &index, Class *&p) const
Definition: class.cpp:76
ReturnType type
Definition: class.h:62
static const char * Expression
Definition: class.h:45
std::string get_member_name(uint64_t index)
Definition: class.cpp:91
Iteration
Definition: structure_member.h:66
std::string str_opcode
Definition: class.h:60
Atom atom
Definition: class.h:59
bool is_fact(Metadata *metadata) const
Definition: class.cpp:71
StructureMember::Iteration use_as
Definition: class.h:63
Definition: image.h:41