85 #include "hlp_context.h"
92 HLPContext::HLPContext() : _Context(NULL, 0, NULL, UNDEFINED) {
95 HLPContext::HLPContext(Atom *code, uint16 index, HLPOverlay *
const overlay, Data data) : _Context(code, index, overlay, data) {
98 bool HLPContext::operator ==(
const HLPContext &c)
const {
100 HLPContext lhs = dereference();
101 HLPContext rhs = c.dereference();
103 if (lhs[0] != rhs[0])
106 if (lhs[0].isStructural()) {
108 uint16 atom_count = lhs.get_children_count();
109 for (uint16 i = 1; i <= atom_count; ++i)
110 if (lhs.get_child_deref(i) != rhs.get_child_deref(i))
117 bool HLPContext::operator !=(
const HLPContext &c)
const {
119 return !(*
this == c);
122 HLPContext HLPContext::dereference()
const {
124 switch ((*
this)[0].getDescriptor()) {
126 return HLPContext(code_, (*
this)[0].asIndex(), (HLPOverlay *)overlay_, data_).dereference();
128 Atom *value_code = ((HLPOverlay *)overlay_)->get_value_code((*
this)[0].asIndex());
130 return HLPContext(value_code, 0, (HLPOverlay *)overlay_, BINDING_MAP).dereference();
133 }
case Atom::VALUE_PTR:
134 return HLPContext(&overlay_->values_[0], (*
this)[0].asIndex(), (HLPOverlay *)overlay_, VALUE_ARRAY).dereference();
140 bool HLPContext::evaluate_no_dereference()
const {
150 switch (code_[index_].getDescriptor()) {
151 case Atom::ASSIGN_PTR: {
153 HLPContext c(code_, code_[index_].asIndex(), (HLPOverlay *)overlay_);
154 if (c.evaluate_no_dereference()) {
156 ((HLPOverlay *)overlay_)->bindings_->bind_variable(code_, code_[index_].asAssignmentIndex(), code_[index_].asIndex(), &overlay_->values_[0]);
158 }
else if (((HLPOverlay*)overlay_)->bindings_->scan_variable(code_[index_].asAssignmentIndex())) {
163 }
case Atom::OPERATOR: {
165 uint16 atom_count = get_children_count();
166 for (uint16 i = 1; i <= atom_count; ++i) {
172 Operator op = Operator::Get((*
this)[0].asOpcode());
173 HLPContext *c =
new HLPContext(*
this);
178 case Atom::INSTANTIATED_PROGRAM:
179 case Atom::INSTANTIATED_CPP_PROGRAM:
180 case Atom::INSTANTIATED_INPUT_LESS_PROGRAM:
181 case Atom::INSTANTIATED_ANTI_PROGRAM:
182 case Atom::COMPOSITE_STATE:
188 uint16 atom_count = get_children_count();
189 for (uint16 i = 1; i <= atom_count; ++i) {
200 uint16 HLPContext::get_object_code_size()
const {
204 return ((HLPOverlay *)overlay_)->get_unpacked_object()->code_size();
206 return ((HLPOverlay *)overlay_)->get_value_code_size((*
this)[0].asIndex());
208 return overlay_->values_.size();