Rename props->value in continuation object

This commit is contained in:
Konstantin Nazarov 2024-09-24 19:18:01 +01:00
parent 9298e5a65b
commit 810707b349
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22
4 changed files with 22 additions and 19 deletions

View file

@ -284,7 +284,7 @@ Result<PodObject*> Arena::gc_continuation(PodContinuation* obj) {
auto nobj = TRY(alloc<PodContinuation>());
nobj->header.tag = Tag::Error;
nobj->props = TRY(gc_pod(obj->props.get()));
nobj->value = TRY(gc_pod(obj->value.get()));
nobj->frame = TRY(gc_pod(obj->frame.get()));
return nobj;

View file

@ -500,6 +500,17 @@ Result<short> Error::cmp(const Error& rhs) const {
return res;
}
Result<Continuation> Continuation::create(const Value& value,
const StackFrame& frame) {
auto pod = TRY(arena_alloc<PodContinuation>());
pod->header.tag = Tag::Continuation;
pod->value = value.pod();
pod->frame = frame.pod();
return Continuation(TRY(MkGcRoot(pod)));
}
Result<Value> Continuation::copy_value() const {
return Value(Continuation(TRY(_value.copy())));
}
@ -507,17 +518,17 @@ Result<Continuation> Continuation::copy() const {
return Continuation(TRY(_value.copy()));
}
Result<Value> Continuation::props() const {
return Value::create(_value->props.get());
Result<Value> Continuation::value() const {
return Value::create(_value->value.get());
}
Result<Value> Continuation::frame() const {
return Value::create(_value->frame.get());
}
Result<short> Continuation::cmp(const Continuation& rhs) const {
auto lhs_props = TRY(props());
auto rhs_props = TRY(rhs.props());
short res = TRY(lhs_props.cmp(rhs_props));
auto lhs_value = TRY(value());
auto rhs_value = TRY(rhs.value());
short res = TRY(lhs_value.cmp(rhs_value));
if (res != 0) return res;
auto lhs_frame = TRY(frame());

View file

@ -1235,18 +1235,10 @@ class Continuation : public Object {
return Continuation(TRY(MkGcRoot(obj)));
}
static Result<Continuation> create(const Dict& props,
const StackFrame& frame) {
auto pod = TRY(arena_alloc<PodContinuation>());
pod->header.tag = Tag::Continuation;
static Result<Continuation> create(const Value& value,
const StackFrame& frame);
pod->props = props.pod();
pod->frame = frame.pod();
return Continuation(TRY(MkGcRoot(pod)));
}
Result<Value> props() const;
Result<Value> value() const;
Result<Value> frame() const;
virtual Result<Value> copy_value() const final;

View file

@ -213,10 +213,10 @@ class PodError final : public PodObject {
};
class PodContinuation final : public PodObject {
public:
public:
PodContinuation() : PodObject(Tag::Continuation) {};
OffPtr<PodObject> props;
OffPtr<PodObject> value;
OffPtr<PodObject> frame;
};