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

Chang2 builtins #1064

Merged
merged 14 commits into from
Dec 7, 2024
Merged
  •  
  •  
  •  
47 changes: 47 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion crates/aiken-lang/src/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ pub fn plutus(id_gen: &IdGenerator) -> TypeInfo {
annotations: HashMap::new(),
};

for builtin in DefaultFunction::iter() {
for builtin in DefaultFunction::iter().take(75) {
let value = from_default_function(builtin, id_gen);

plutus.values.insert(builtin.aiken_name(), value);
Expand Down Expand Up @@ -908,6 +908,19 @@ pub fn from_default_function(builtin: DefaultFunction, id_gen: &IdGenerator) ->

(tipo, 2)
}
DefaultFunction::AndByteString => todo!(),
DefaultFunction::OrByteString => todo!(),
DefaultFunction::XorByteString => todo!(),
DefaultFunction::ComplementByteString => todo!(),
DefaultFunction::ReadBit => todo!(),
DefaultFunction::WriteBits => todo!(),
DefaultFunction::ReplicateByte => todo!(),
DefaultFunction::ShiftByteString => todo!(),
DefaultFunction::RotateByteString => todo!(),
DefaultFunction::CountSetBits => todo!(),
DefaultFunction::FindFirstSetBit => todo!(),
DefaultFunction::Ripemd_160 => todo!(),
DefaultFunction::ExpModInteger => todo!(),
};

ValueConstructor::public(
Expand Down
2 changes: 2 additions & 0 deletions crates/uplc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ strum_macros = "0.24.3"
thiserror = "1.0.39"
blst = "0.3.11"
once_cell = "1.18.0"
hamming = "0.1.3"
bitvec = "1.0.1"

[target.'cfg(not(target_family="wasm"))'.dependencies]
secp256k1 = { version = "0.26.0" }
Expand Down
69 changes: 65 additions & 4 deletions crates/uplc/src/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,28 @@ pub enum DefaultFunction {
Bls12_381_MulMlResult = 69,
Bls12_381_FinalVerify = 70,

// Bitwise
// Conversions
IntegerToByteString = 73,
ByteStringToInteger = 74,
// Logical
AndByteString = 75,
OrByteString = 76,
XorByteString = 77,
ComplementByteString = 78,
ReadBit = 79,
WriteBits = 80,
ReplicateByte = 81,
// Bitwise
ShiftByteString = 82,
RotateByteString = 83,
CountSetBits = 84,
FindFirstSetBit = 85,
// Ripemd_160
Ripemd_160 = 86,
ExpModInteger = 87,
// Match
// CaseList = 88,
// CaseData = 89,
}

impl TryFrom<u8> for DefaultFunction {
Expand Down Expand Up @@ -362,11 +381,23 @@ impl FromStr for DefaultFunction {
"bls12_381_millerLoop" => Ok(Bls12_381_MillerLoop),
"bls12_381_mulMlResult" => Ok(Bls12_381_MulMlResult),
"bls12_381_finalVerify" => Ok(Bls12_381_FinalVerify),

// Bitwise
"integerToByteString" => Ok(IntegerToByteString),
"byteStringToInteger" => Ok(ByteStringToInteger),

"andByteString" => Ok(AndByteString),
"orByteString" => Ok(OrByteString),
"xorByteString" => Ok(XorByteString),
"complementByteString" => Ok(ComplementByteString),
"readBit" => Ok(ReadBit),
"writeBits" => Ok(WriteBits),
"replicateByte" => Ok(ReplicateByte),
"shiftByteString" => Ok(ShiftByteString),
"rotateByteString" => Ok(RotateByteString),
"countSetBits" => Ok(CountSetBits),
"findFirstSetBit" => Ok(FindFirstSetBit),
"ripemd_160" => Ok(Ripemd_160),
"expModInteger" => Ok(ExpModInteger),
// "caseList" => Ok(CaseList),
// "caseData" => Ok(CaseData),
rest => Err(format!("Default Function not found - {rest}")),
}
}
Expand Down Expand Up @@ -452,6 +483,21 @@ impl Display for DefaultFunction {
Bls12_381_FinalVerify => write!(f, "bls12_381_finalVerify"),
IntegerToByteString => write!(f, "integerToByteString"),
ByteStringToInteger => write!(f, "byteStringToInteger"),
AndByteString => write!(f, "andByteString"),
OrByteString => write!(f, "orByteString"),
XorByteString => write!(f, "xorByteString"),
ComplementByteString => write!(f, "complementByteString"),
ReadBit => write!(f, "readBit"),
WriteBits => write!(f, "writeBits"),
ReplicateByte => write!(f, "replicateByte"),
ShiftByteString => write!(f, "shiftByteString"),
RotateByteString => write!(f, "rotateByteString"),
CountSetBits => write!(f, "countSetBits"),
FindFirstSetBit => write!(f, "findFirstSetBit"),
Ripemd_160 => write!(f, "ripemd_160"),
ExpModInteger => write!(f, "expModInteger"),
// CaseList => write!(f, "caseList"),
// CaseData => write!(f, "caseData"),
}
}
}
Expand Down Expand Up @@ -536,6 +582,21 @@ impl DefaultFunction {
Bls12_381_FinalVerify => "bls12_381_final_verify",
IntegerToByteString => "integer_to_bytearray",
ByteStringToInteger => "bytearray_to_integer",
AndByteString => "and_bytearray",
OrByteString => "or_bytearray",
XorByteString => "xor_bytearray",
ComplementByteString => "complement_bytearray",
ReadBit => "read_bit",
WriteBits => "write_bits",
ReplicateByte => "replicate_byte",
ShiftByteString => "shift_bytearray",
RotateByteString => "rotate_bytearray",
CountSetBits => "count_set_bits",
FindFirstSetBit => "find_first_set_bit",
Ripemd_160 => "ripemd_160",
ExpModInteger => "exp_mod_integer",
// CaseList => "case_list",
// CaseData => "case_data",
}
.to_string()
}
Expand Down
Loading
Loading