diff --git a/cairo_native/executor/index.html b/cairo_native/executor/index.html index 7b9a6c43b..e5c351a51 100644 --- a/cairo_native/executor/index.html +++ b/cairo_native/executor/index.html @@ -1,5 +1,5 @@ cairo_native::executor - Rust -

Module cairo_native::executor

source ·
Expand description

§Executors

+

Module cairo_native::executor

source ·
Expand description

§Executors

This module provides methods to execute the programs, either via JIT or compiled ahead of time. It also provides a cache to avoid recompiling previously compiled programs.

Structs§

Enums§

\ No newline at end of file diff --git a/cairo_native/libfuncs/felt252_dict/index.html b/cairo_native/libfuncs/felt252_dict/index.html index c7cf158ff..950955e04 100644 --- a/cairo_native/libfuncs/felt252_dict/index.html +++ b/cairo_native/libfuncs/felt252_dict/index.html @@ -1,2 +1,2 @@ cairo_native::libfuncs::felt252_dict - Rust -
Expand description

§Felt dictionary libfuncs

Functions§

\ No newline at end of file +
Expand description

§Felt dictionary libfuncs

Functions§

\ No newline at end of file diff --git a/cairo_native/types/squashed_felt252_dict/fn.build.html b/cairo_native/types/squashed_felt252_dict/fn.build.html index 302972fd7..11173a08e 100644 --- a/cairo_native/types/squashed_felt252_dict/fn.build.html +++ b/cairo_native/types/squashed_felt252_dict/fn.build.html @@ -1,5 +1,5 @@ build in cairo_native::types::squashed_felt252_dict - Rust -
pub fn build<'ctx>(
+    
pub fn build<'ctx>(
     context: &'ctx Context,
     _module: &Module<'ctx>,
     _registry: &ProgramRegistry<CoreType, CoreLibfunc>,
diff --git a/cairo_native/types/squashed_felt252_dict/index.html b/cairo_native/types/squashed_felt252_dict/index.html
index da2e5887b..fc4ceb0d4 100644
--- a/cairo_native/types/squashed_felt252_dict/index.html
+++ b/cairo_native/types/squashed_felt252_dict/index.html
@@ -1,2 +1,2 @@
 cairo_native::types::squashed_felt252_dict - Rust
-    
Expand description

§Squashed Felt dictionary type

Functions§

  • Build the MLIR type.
\ No newline at end of file +
Expand description

§Squashed Felt dictionary type

Functions§

  • Build the MLIR type.
\ No newline at end of file diff --git a/cairo_native/values/enum.JitValue.html b/cairo_native/values/enum.JitValue.html index e9f305a5b..9ae2a658c 100644 --- a/cairo_native/values/enum.JitValue.html +++ b/cairo_native/values/enum.JitValue.html @@ -47,7 +47,7 @@

A Boxed value or a non-null Nullable value is returned with it’s inner value.

Variants§

§

Felt252(Felt)

§

Bytes31([u8; 31])

§

Array(Vec<Self>)

all elements need to be same type

§

Struct

Fields

§fields: Vec<Self>
§debug_name: Option<String>
§

Enum

Fields

§tag: usize
§value: Box<Self>
§debug_name: Option<String>
§

Felt252Dict

Fields

§value: HashMap<Felt, Self>
§debug_name: Option<String>
§

Uint8(u8)

§

Uint16(u16)

§

Uint32(u32)

§

Uint64(u64)

§

Uint128(u128)

§

Sint8(i8)

§

Sint16(i16)

§

Sint32(i32)

§

Sint64(i64)

§

Sint128(i128)

§

EcPoint(Felt, Felt)

§

EcState(Felt, Felt, Felt, Felt)

§

Secp256K1Point

Fields

§x: (u128, u128)
§y: (u128, u128)
§

Secp256R1Point

Fields

§x: (u128, u128)
§y: (u128, u128)
§

BoundedInt

Fields

§value: Felt
§range: Range
§

Null

Used as return value for Nullables that are null.

-

Implementations§

source§

impl JitValue

source

pub fn felt_str(value: &str) -> Self

String to felt

+

Implementations§

source§

impl JitValue

source

pub fn felt_str(value: &str) -> Self

String to felt

Trait Implementations§

source§

impl Clone for JitValue

source§

fn clone(&self) -> JitValue

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for JitValue

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for JitValue

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T: Into<JitValue> + Clone> From<&[T]> for JitValue

source§

fn from(value: &[T]) -> Self

Converts to this type from the input type.
source§

impl<T: Into<JitValue>, const N: usize> From<[T; N]> for JitValue

source§

fn from(value: [T; N]) -> Self

Converts to this type from the input type.
source§

impl From<Felt> for JitValue

source§

fn from(value: Felt) -> Self

Converts to this type from the input type.
source§

impl<T: Into<JitValue>> From<Vec<T>> for JitValue

source§

fn from(value: Vec<T>) -> Self

Converts to this type from the input type.
source§

impl From<i128> for JitValue

source§

fn from(value: i128) -> Self

Converts to this type from the input type.
source§

impl From<i16> for JitValue

source§

fn from(value: i16) -> Self

Converts to this type from the input type.
source§

impl From<i32> for JitValue

source§

fn from(value: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for JitValue

source§

fn from(value: i64) -> Self

Converts to this type from the input type.
source§

impl From<i8> for JitValue

source§

fn from(value: i8) -> Self

Converts to this type from the input type.
source§

impl From<u128> for JitValue

source§

fn from(value: u128) -> Self

Converts to this type from the input type.
source§

impl From<u16> for JitValue

source§

fn from(value: u16) -> Self

Converts to this type from the input type.
source§

impl From<u32> for JitValue

source§

fn from(value: u32) -> Self

Converts to this type from the input type.
source§

impl From<u64> for JitValue

source§

fn from(value: u64) -> Self

Converts to this type from the input type.
source§

impl From<u8> for JitValue

source§

fn from(value: u8) -> Self

Converts to this type from the input type.
source§

impl PartialEq for JitValue

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always diff --git a/cairo_native/values/index.html b/cairo_native/values/index.html index 35233bfb5..bc796a89f 100644 --- a/cairo_native/values/index.html +++ b/cairo_native/values/index.html @@ -1,4 +1,4 @@ cairo_native::values - Rust -

Module cairo_native::values

source ·
Expand description

§JIT params and return values de/serialization

+

Module cairo_native::values

source ·
Expand description

§JIT params and return values de/serialization

A Rusty interface to provide parameters to JIT calls.

Enums§

  • A JitValue is a value that can be passed to the JIT engine as an argument or received as a result.
\ No newline at end of file diff --git a/help.html b/help.html index 5f214fa54..a47b990ff 100644 --- a/help.html +++ b/help.html @@ -1,2 +1,2 @@ -Help -

Rustdoc help

Back
\ No newline at end of file +Help +

Rustdoc help

Back
\ No newline at end of file diff --git a/settings.html b/settings.html index 9673305a1..1f893e136 100644 --- a/settings.html +++ b/settings.html @@ -1,2 +1,2 @@ -Settings -

Rustdoc settings

Back
\ No newline at end of file +Settings +

Rustdoc settings

Back
\ No newline at end of file diff --git a/src/cairo_native/executor.rs.html b/src/cairo_native/executor.rs.html index cd97a5408..2d00e1a05 100644 --- a/src/cairo_native/executor.rs.html +++ b/src/cairo_native/executor.rs.html @@ -850,23 +850,6 @@

Files

848 849 850 -851 -852 -853 -854 -855 -856 -857 -858 -859 -860 -861 -862 -863 -864 -865 -866 -867
//! # Executors
 //!
 //! This module provides methods to execute the programs, either via JIT or compiled ahead
@@ -896,7 +879,7 @@ 

Files

use std::{ alloc::Layout, arch::global_asm, - ptr::{null_mut, NonNull}, + ptr::{addr_of_mut, null_mut, NonNull}, rc::Rc, }; @@ -1689,29 +1672,12 @@

Files

Ok(JitValue::from_jit(return_ptr.unwrap(), type_id, registry)) } } - CoreTypeConcrete::Felt252Dict(_) => match return_ptr { - Some(return_ptr) => Ok(JitValue::from_jit( - unsafe { *return_ptr.cast::<NonNull<()>>().as_ref() }, - type_id, - registry, - )), - None => Ok(JitValue::from_jit( - NonNull::new(ret_registers[0] as *mut ()).unwrap(), - type_id, - registry, - )), - }, - CoreTypeConcrete::SquashedFelt252Dict(_) => match return_ptr { - Some(return_ptr) => Ok(JitValue::from_jit( - unsafe { *return_ptr.cast::<NonNull<()>>().as_ref() }, - type_id, - registry, - )), - None => Ok(JitValue::from_jit( - NonNull::new(ret_registers[0] as *mut ()).unwrap(), - type_id, - registry, - )), + CoreTypeConcrete::Felt252Dict(_) | CoreTypeConcrete::SquashedFelt252Dict(_) => unsafe { + let ptr = return_ptr.unwrap_or(NonNull::new_unchecked( + addr_of_mut!(ret_registers[0]) as *mut () + )); + let value = JitValue::from_jit(ptr, type_id, registry); + Ok(value) }, // Builtins are handled before the call to parse_result diff --git a/src/cairo_native/libfuncs/felt252_dict.rs.html b/src/cairo_native/libfuncs/felt252_dict.rs.html index 2a0d54abd..313d11c36 100644 --- a/src/cairo_native/libfuncs/felt252_dict.rs.html +++ b/src/cairo_native/libfuncs/felt252_dict.rs.html @@ -211,6 +211,102 @@

Files

209 210 211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307
//! # `Felt` dictionary libfuncs
 
 use super::LibfuncHelper;
@@ -329,7 +425,10 @@ 

Files

#[cfg(test)] mod test { - use crate::utils::test::{jit_dict, jit_struct, load_cairo, run_program_assert_output}; + use crate::{ + utils::test::{jit_dict, jit_enum, jit_struct, load_cairo, run_program_assert_output}, + values::JitValue, + }; #[test] fn run_dict_new() { @@ -421,5 +520,98 @@

Files

), ); } + + #[test] + fn run_dict_deserialize2() { + let program = load_cairo!( + use traits::Default; + use dict::Felt252DictTrait; + + fn run_test(mut dict: Felt252Dict<u32>) -> (felt252, Felt252Dict<u32>) { + (0, dict) + } + ); + + run_program_assert_output( + &program, + "run_test", + &[jit_dict!( + 1 => 2u32, + 2 => 3u32, + 3 => 4u32, + 4 => 5u32, + 5 => 6u32, + )], + jit_struct!( + JitValue::Felt252(0.into()), + jit_dict!( + 1 => 2u32, + 2 => 3u32, + 3 => 4u32, + 4 => 5u32, + 5 => 6u32, + ) + ), + ); + } + + #[test] + fn run_dict_deserialize_struct() { + let program = load_cairo! { + use core::{dict::Felt252DictTrait, nullable::Nullable}; + + fn run_test() -> Felt252Dict<Nullable<(u32, u64, u128)>> { + let mut x: Felt252Dict<Nullable<(u32, u64, u128)>> = Default::default(); + x.insert(0, NullableTrait::new((1_u32, 2_u64, 3_u128))); + x.insert(1, NullableTrait::new((2_u32, 3_u64, 4_u128))); + x.insert(2, NullableTrait::new((3_u32, 4_u64, 5_u128))); + x + } + }; + + run_program_assert_output( + &program, + "run_test", + &[], + jit_dict!( + 0 => jit_struct!(1u32.into(), 2u64.into(), 3u128.into()), + 1 => jit_struct!(2u32.into(), 3u64.into(), 4u128.into()), + 2 => jit_struct!(3u32.into(), 4u64.into(), 5u128.into()), + ), + ); + } + + #[test] + fn run_dict_deserialize_enum() { + let program = load_cairo! { + use core::{dict::Felt252DictTrait, nullable::Nullable}; + + #[derive(Drop)] + enum MyEnum { + A: u32, + B: u64, + C: u128, + } + + fn run_test() -> Felt252Dict<Nullable<MyEnum>> { + let mut x: Felt252Dict<Nullable<MyEnum>> = Default::default(); + x.insert(0, NullableTrait::new(MyEnum::A(1))); + x.insert(1, NullableTrait::new(MyEnum::B(2))); + x.insert(2, NullableTrait::new(MyEnum::C(3))); + x + } + }; + + run_program_assert_output( + &program, + "run_test", + &[], + jit_dict!( + 0 => jit_enum!(0, 1u32.into()), + 1 => jit_enum!(1, 2u64.into()), + 2 => jit_enum!(2, 3u128.into()), + ), + ); + } }
\ No newline at end of file diff --git a/src/cairo_native/types/squashed_felt252_dict.rs.html b/src/cairo_native/types/squashed_felt252_dict.rs.html index d5508ef0e..2e145309b 100644 --- a/src/cairo_native/types/squashed_felt252_dict.rs.html +++ b/src/cairo_native/types/squashed_felt252_dict.rs.html @@ -29,9 +29,6 @@

Files

27 28 29 -30 -31 -32
//! # Squashed `Felt` dictionary type
 
 use super::WithSelf;
@@ -59,9 +56,6 @@ 

Files

_metadata: &mut MetadataStorage, _info: WithSelf<InfoAndTypeConcreteType>, ) -> Result<Type<'ctx>> { - //let inner = registry.get_type(&info.ty)?; - //let layout = inner.layout(registry)?; - - Ok(llvm::r#type::pointer(context, 0)) + Ok(llvm::r#type::pointer(context, 0)) }
\ No newline at end of file diff --git a/src/cairo_native/values.rs.html b/src/cairo_native/values.rs.html index 96cc09892..bd917f8f1 100644 --- a/src/cairo_native/values.rs.html +++ b/src/cairo_native/values.rs.html @@ -1464,6 +1464,8 @@

Files

1462 1463 1464 +1465 +1466
//! # JIT params and return values de/serialization
 
 //! A Rusty interface to provide parameters to JIT calls.
@@ -2171,8 +2173,10 @@ 

Files

} CoreTypeConcrete::Felt252Dict(info) | CoreTypeConcrete::SquashedFelt252Dict(info) => { - let map = Box::from_raw( - ptr.cast::<HashMap<[u8; 32], NonNull<std::ffi::c_void>>>() + let (map, _) = *Box::from_raw( + ptr.cast::<NonNull<()>>() + .as_ref() + .cast::<(HashMap<[u8; 32], NonNull<std::ffi::c_void>>, u64)>() .as_ptr(), );