Skip to content

Commit

Permalink
linting pass
Browse files Browse the repository at this point in the history
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
  • Loading branch information
salaheldinsoliman committed Jun 22, 2024
1 parent 84d5f7d commit 1a8cb27
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 19 deletions.
6 changes: 2 additions & 4 deletions integration/soroban/test_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as StellarSdk from '@stellar/stellar-sdk';



async function call_contract_function(method, server, keypair, contract) {
export async function call_contract_function(method, server, keypair, contract) {

let res;
let builtTransaction = new StellarSdk.TransactionBuilder(await server.getAccount(keypair.publicKey()), {
Expand Down Expand Up @@ -50,6 +50,4 @@ async function call_contract_function(method, server, keypair, contract) {
console.log(err);
}
return res;
}

export { call_contract_function };
}
4 changes: 0 additions & 4 deletions src/codegen/dispatch/soroban.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ pub fn function_dispatch(
let mut wrapper_cfgs = Vec::new();

for cfg in all_cfg.iter_mut() {
if cfg.function_no == ASTFunction::None {
continue;
}

let function = match &cfg.function_no {
ASTFunction::SolidityFunction(no) => &ns.functions[*no],
_ => continue,
Expand Down
1 change: 0 additions & 1 deletion src/emit/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,6 @@ impl<'a> Binary<'a> {
None => return self.context.void_type().fn_type(&args, false),
}
}

// add return values
for ty in returns {
args.push(if ty.is_reference_type(ns) && !ty.is_contract_storage() {
Expand Down
5 changes: 2 additions & 3 deletions src/emit/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ pub(super) fn process_instruction<'a, T: TargetRuntime<'a> + ?Sized>(
Instr::Return { value } => match value.iter().next() {
Some(val) => {
let retval = expression(target, bin, val, &w.vars, function, ns);

bin.builder.build_return(Some(&retval)).unwrap();
}
None => {
Expand Down Expand Up @@ -462,7 +461,7 @@ pub(super) fn process_instruction<'a, T: TargetRuntime<'a> + ?Sized>(
.map(|p| expression(target, bin, p, &w.vars, function, ns).into())
.collect::<Vec<BasicMetadataValueEnum>>();

// Soroban doesnt write return values to imported memory
// Soroban doesn't write return values to imported memory
if !res.is_empty() && ns.target != Target::Soroban {
for v in f.returns.iter() {
parms.push(if ns.target == Target::Solana {
Expand All @@ -488,7 +487,7 @@ pub(super) fn process_instruction<'a, T: TargetRuntime<'a> + ?Sized>(
.try_as_basic_value()
.left();

// Soroban doesnt have return codes, and only returns a single i64 value
// Soroban doesn't have return codes, and only returns a single i64 value
if ns.target != Target::Soroban {
let success = bin
.builder
Expand Down
9 changes: 3 additions & 6 deletions src/emit/soroban/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl SorobanTarget {
} else {
&cfg.name
};
Self::emit_function_spec_entry(context, cfg.clone(), name.to_string(), binary);
Self::emit_function_spec_entry(context, cfg, name.to_string(), binary);
export_list.push(name);
Linkage::External
} else {
Expand Down Expand Up @@ -124,7 +124,6 @@ impl SorobanTarget {

for (func_decl, cfg) in defines {
emit_cfg(&mut SorobanTarget, binary, contract, cfg, func_decl, ns);
//Self::emit_function_dispatcher(binary, cfg, func_decl, &dispatcher_name, ns, &contract);
}
}

Expand All @@ -140,14 +139,12 @@ impl SorobanTarget {

fn emit_function_spec_entry<'a>(
context: &'a Context,
cfg: ControlFlowGraph,
cfg: &ControlFlowGraph,
name: String,
binary: &mut Binary<'a>,
) {
if cfg.public && !cfg.is_placeholder() {
// TODO: Emit custom type spec entries
//let outputs = ScSpecTypeDef::Vec(());

let mut spec = DepthLimitedWrite::new(Vec::new(), 10);
ScSpecEntry::FunctionV0(ScSpecFunctionV0 {
name: name
Expand Down Expand Up @@ -249,7 +246,7 @@ impl SorobanTarget {
let void_param = ast::Parameter::new_default(ast::Type::Void);
cfg.returns = sync::Arc::new(vec![void_param]);

Self::emit_function_spec_entry(binary.context, cfg, "init".to_string(), binary);
Self::emit_function_spec_entry(binary.context, &cfg, "init".to_string(), binary);

let function_name = CString::new(STORAGE_INITIALIZER).unwrap();
let mut storage_initializers = binary
Expand Down
3 changes: 2 additions & 1 deletion src/emit/soroban/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
.const_cast(binary.context.i64_type(), false)
.into(),
dest.into(),
i64_const!(2).into(),
binary.context.i64_type().const_int(2, false).into(),
],
PUT_CONTRACT_DATA,
)
Expand Down Expand Up @@ -235,6 +235,7 @@ impl<'a> TargetRuntime<'a> for SorobanTarget {
}

/// Prints a string
/// TODO: Implement this function, with a call to the `log` function in the Soroban runtime.
fn print(&self, bin: &Binary, string: PointerValue, length: IntValue) {}

Check warning on line 239 in src/emit/soroban/target.rs

View check run for this annotation

Codecov / codecov/patch

src/emit/soroban/target.rs#L239

Added line #L239 was not covered by tests

/// Return success without any result
Expand Down

0 comments on commit 1a8cb27

Please sign in to comment.