Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement fromReference method for HintReference #291

Open
tcoratger opened this issue Dec 23, 2023 · 1 comment
Open

feat: implement fromReference method for HintReference #291

tcoratger opened this issue Dec 23, 2023 · 1 comment
Assignees

Comments

@tcoratger
Copy link
Collaborator

In order to transform a Reference instance into a HintReference instance:

  • Reference structure

    pub const Reference = struct {
    /// Tracking data for the register associated with the reference.
    ap_tracking_data: ApTracking,
    /// Program counter (pc) tied to the reference (optional, defaults to null).
    pc: ?usize,
    /// Value of the reference.
    value: []const u8,
    };

  • HintReference structure

    pub const HintReference = struct {
    const Self = @This();
    /// First offset value within the hint reference.
    offset1: OffsetValue,
    /// Second offset value within the hint reference.
    offset2: ?OffsetValue,
    /// Flag indicating dereference within the hint reference.
    dereference: bool,
    /// Ap tracking data associated with the hint reference (optional, defaults to null).
    ap_tracking_data: ?ApTracking,
    /// Cairo type information related to the hint reference (optional, defaults to null).
    cairo_type: ?[]const u8,
    /// Initializes a hint reference with specified offsets and dereference flags.
    ///
    /// Params:
    /// - `offset1`: First offset value.
    /// - `offset2`: Second offset value.
    /// - `inner_dereference`: Flag for inner dereference within the first offset value.
    /// - `dereference`: Flag for dereference within the hint reference.
    pub fn init(
    offset1: i32,
    offset2: i32,
    inner_dereference: bool,
    dereference: bool,
    ) Self {
    return .{
    .offset1 = .{ .reference = .{ .FP, offset1, inner_dereference } },
    .offset2 = .{ .value = offset2 },
    .dereference = dereference,
    .ap_tracking_data = null,
    .cairo_type = null,
    };
    }
    /// Initializes a simple hint reference with the specified offset.
    ///
    /// Params:
    /// - `offset1`: First offset value for the hint reference.
    pub fn initSimple(offset1: i32) Self {
    return .{
    .offset1 = .{ .reference = .{ .FP, offset1, false } },
    .offset2 = .{ .value = 0 },
    .dereference = true,
    .ap_tracking_data = null,
    .cairo_type = null,
    };
    }
    };

we need a fromReference method similar to:

https://github.com/lambdaclass/cairo-vm/blob/8a2ef24c1ca258f1d1d230cbbd1478cd1d4cf9db/vm/src/hint_processor/hint_processor_definition.rs#L133-L153

@tcoratger tcoratger self-assigned this Dec 23, 2023
Copy link

There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a 👍
Because this issue is marked as stale, it will be closed and locked in 7 days if no further activity occurs.
Thank you for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant