Skip to content

Commit

Permalink
Merge branch 'main' into release-0.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
xermicus committed May 10, 2024
2 parents 3e1c57e + 96a1cc8 commit 2743878
Show file tree
Hide file tree
Showing 13 changed files with 385 additions and 129 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,24 @@ jobs:

linux-arm64:
name: Linux arm64
runs-on: linux-arm64
runs-on: solang-arm
if: ${{ github.repository_owner == 'hyperledger' }}
container: ghcr.io/hyperledger/solang-llvm:ci-7
steps:
- name: Checkout sources
uses: actions/checkout@v3.1.0
with:
submodules: recursive
- name: Basic build tools
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ make
- uses: dtolnay/rust-toolchain@1.74.0
- name: Get LLVM
run: curl -sSL --output llvm16.0-linux-arm64.tar.xz https://github.com/hyperledger/solang-llvm/releases/download/llvm16-0/llvm16.0-linux-arm64.tar.xz
- name: Extract LLVM
run: tar Jxf llvm16.0-linux-arm64.tar.xz
- name: Add LLVM to Path
run: echo "$(pwd)/llvm16.0/bin" >> $GITHUB_PATH
- name: Build
run: cargo build --verbose --release
- name: Run tests
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,24 @@ jobs:

linux-arm:
name: Linux Arm
runs-on: linux-arm64
runs-on: solang-arm
if: ${{ github.repository_owner == 'hyperledger' }}
container: ghcr.io/hyperledger/solang-llvm:ci-7
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
submodules: recursive
- name: Basic build tools
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ make
- uses: dtolnay/rust-toolchain@1.74.0
- name: Get LLVM
run: curl -sSL --output llvm16.0-linux-arm64.tar.xz https://github.com/hyperledger/solang-llvm/releases/download/llvm16-0/llvm16.0-linux-arm64.tar.xz
- name: Extract LLVM
run: tar Jxf llvm16.0-linux-arm64.tar.xz
- name: Add LLVM to Path
run: echo "$(pwd)/llvm16.0/bin" >> $GITHUB_PATH
- name: Build
run: cargo build --verbose
- name: Run tests
Expand Down
400 changes: 319 additions & 81 deletions docs/hl_solang_horizontal-color.svg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/abi/anchor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl TypeManager<'_> {
format!("_{real_name}")
};
let unique_name = self.unique_string(new_other_name);
self.types[idx].name = unique_name.clone();
self.types[idx].name.clone_from(&unique_name);
self.added_names
.insert(unique_name, (idx, other_contract, real_name));
type_name.clone()
Expand Down
12 changes: 6 additions & 6 deletions src/bin/languageserver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1876,7 +1876,7 @@ impl<'a> Builder<'a> {
.hover_overrides
.get(&pt::Loc::File(lookup.0, lookup.1.start, lookup.1.stop))
{
lookup.1.val = msg.clone();
lookup.1.val.clone_from(msg);
}
}

Expand All @@ -1900,7 +1900,7 @@ impl<'a> Builder<'a> {

for val in self.types.values_mut() {
if let Some(path) = defs_to_files.get(&val.def_type) {
val.def_path = path.clone();
val.def_path.clone_from(path);
}
}

Expand Down Expand Up @@ -1948,7 +1948,7 @@ impl<'a> Builder<'a> {
.map(|(_, i)| {
let mut i = i.clone();
if let Some(def_path) = defs_to_files.get(&i.val.def_type) {
i.val.def_path = def_path.clone();
i.val.def_path.clone_from(def_path);
}
i
})
Expand All @@ -1963,7 +1963,7 @@ impl<'a> Builder<'a> {
for val in &mut scope.val {
if let Some(val) = &mut val.1 {
if let Some(def_path) = defs_to_files.get(&val.def_type) {
val.def_path = def_path.clone();
val.def_path.clone_from(def_path);
}
}
}
Expand All @@ -1980,7 +1980,7 @@ impl<'a> Builder<'a> {
{
if def_path.to_str().unwrap() == "" {
if let Some(dp) = defs_to_files.get(def_type) {
*def_path = dp.clone();
def_path.clone_from(dp);
}
}
}
Expand All @@ -1994,7 +1994,7 @@ impl<'a> Builder<'a> {
for def_index in properties.values_mut().flatten() {
if def_index.def_path.to_str().unwrap() == "" {
if let Some(def_path) = defs_to_files.get(&def_index.def_type) {
def_index.def_path = def_path.clone();
def_index.def_path.clone_from(def_path);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/codegen/dispatch/polkadot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
};
use num_bigint::{BigInt, Sign};
use solang_parser::pt::{FunctionTy, Loc::Codegen};
use std::fmt::{Display, Formatter, Result};

/// On Polkadot, contracts export a `call` and a `deploy` function.
/// The `contracts` pallet will invoke `deploy` on contract instatiation,
Expand All @@ -27,13 +28,12 @@ pub enum DispatchType {
Call,
}

impl ToString for DispatchType {
fn to_string(&self) -> String {
impl Display for DispatchType {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
match self {
Self::Deploy => "polkadot_deploy_dispatch",
Self::Call => "polkadot_call_dispatch",
Self::Deploy => f.write_str("polkadot_deploy_dispatch"),
Self::Call => f.write_str("polkadot_call_dispatch"),
}
.into()
}
}

Expand Down
9 changes: 4 additions & 5 deletions src/sema/solana_accounts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0

use std::str::FromStr;
use std::{fmt, str::FromStr};

pub enum BuiltinAccounts {
/// These are the accounts that we can collect from a contract and that Anchor will populate
Expand Down Expand Up @@ -31,10 +31,9 @@ impl BuiltinAccounts {
}
}

impl ToString for BuiltinAccounts {
fn to_string(&self) -> String {
let str = self.as_str();
str.to_string()
impl fmt::Display for BuiltinAccounts {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}

Expand Down
22 changes: 10 additions & 12 deletions src/sema/yul/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::sema::Recurse;
use num_bigint::BigInt;
use solang_parser::pt;
use solang_parser::pt::{CodeLocation, StorageLocation};
use std::sync::Arc;
use std::{fmt, sync::Arc};

#[derive(Debug, Clone)]
pub struct InlineAssembly {
Expand Down Expand Up @@ -97,17 +97,15 @@ pub enum YulSuffix {
Address,
}

impl ToString for YulSuffix {
fn to_string(&self) -> String {
let name = match self {
YulSuffix::Offset => "offset",
YulSuffix::Slot => "slot",
YulSuffix::Length => "length",
YulSuffix::Selector => "selector",
YulSuffix::Address => "address",
};

name.to_string()
impl fmt::Display for YulSuffix {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
YulSuffix::Offset => f.write_str("offset"),
YulSuffix::Slot => f.write_str("slot"),
YulSuffix::Length => f.write_str("length"),
YulSuffix::Selector => f.write_str("selector"),
YulSuffix::Address => f.write_str("address"),
}
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/sema/yul/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use crate::Target;
use phf::{phf_map, phf_set};
use std::fmt;

pub struct YulBuiltinPrototype {
pub name: &'static str,
Expand Down Expand Up @@ -258,10 +259,10 @@ impl YulBuiltInFunction {
}
}

impl ToString for YulBuiltInFunction {
fn to_string(&self) -> String {
impl fmt::Display for YulBuiltInFunction {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let prototype = self.get_prototype_info();
prototype.name.to_owned()
f.write_str(prototype.name)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/sema/yul/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ fn resolve_suffix_access(
resolved_expr.loc(),
format!(
"the given expression does not support '.{}' suffixes",
suffix_type.to_string()
suffix_type
),
));
}
Expand Down Expand Up @@ -635,7 +635,7 @@ fn resolve_suffix_access(
resolved_expr.loc(),
format!(
"the given expression does not support '.{}' suffixes",
suffix_type.to_string()
suffix_type
),
));
return Err(());
Expand Down
1 change: 1 addition & 0 deletions tests/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fn run_test_for_path(path: &str) {
}

#[derive(Debug)]
#[allow(unused)]
enum Test {
Check(usize, String),
CheckAbsent(usize, String),
Expand Down
12 changes: 7 additions & 5 deletions tests/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,18 +272,20 @@ fn set_file_contents(source: &str, path: &Path) -> (FileResolver, Vec<String>) {
if !contents.is_empty() {
cache.set_file_contents(&name, contents);
names.push(name);
name = String::new();
}
name = cap.get(1).unwrap().as_str().to_owned();
cap.get(1).unwrap().as_str().clone_into(&mut name);
if name == "////" {
name = "test.sol".to_owned();
"test.sol".clone_into(&mut name);
}
contents = String::new();
} else if let Some(cap) = external_source_delimiter.captures(line) {
let mut name = cap.get(1).unwrap().as_str().to_owned();
if let Some(cap) = equals.captures(&name) {
let filename = cap.get(1).unwrap().as_str();
let mut name = filename.to_owned();
if let Some(cap) = equals.captures(filename) {
let mut ext = path.parent().unwrap().to_path_buf();
ext.push(cap.get(2).unwrap().as_str());
name = cap.get(1).unwrap().as_str().to_owned();
cap.get(1).unwrap().as_str().clone_into(&mut name);
let source = fs::read_to_string(ext).unwrap();
cache.set_file_contents(&name, source);
}
Expand Down
9 changes: 4 additions & 5 deletions tests/polkadot_tests/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ fn mangle_function_names_in_abi() {
let _ = runtime.contracts()[0].code.messages["foo_"];
let _ = runtime.contracts()[0].code.messages["foo_uint256_addressArray2Array"];
let _ = runtime.contracts()[0].code.messages["foo_uint8Array2__int256_bool_address"];
assert!(runtime.contracts()[0].code.messages.get("foo").is_none());
assert!(!runtime.contracts()[0].code.messages.contains_key("foo"));
}

#[test]
Expand All @@ -265,12 +265,11 @@ fn mangle_overloaded_function_names_in_abi() {
);

let _ = runtime.contracts()[0].code.messages["foo"];
assert!(runtime.contracts()[0]
assert!(!runtime.contracts()[0]
.code
.messages
.get("foo_bool")
.is_none());
.contains_key("foo_bool"));

let _ = runtime.contracts()[1].code.messages["foo_bool"];
assert!(runtime.contracts()[1].code.messages.get("foo").is_none());
assert!(!runtime.contracts()[1].code.messages.contains_key("foo"));
}

0 comments on commit 2743878

Please sign in to comment.