mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Handle cases where there are multiple source files
This commit is contained in:
parent
025422b220
commit
e5c193d427
@ -179,28 +179,25 @@ function split_combined_json
|
|||||||
{
|
{
|
||||||
local json_file="$1"
|
local json_file="$1"
|
||||||
local output_path="$2"
|
local output_path="$2"
|
||||||
local prefix="${3:-}"
|
local path_to_contract_file="${3:-}"
|
||||||
for path_with_contract in $(jq '.contracts | keys | .[]' "${json_file}" 2> /dev/null)
|
for path_with_contract in $(jq --raw-output '.contracts | keys | .[]' "${json_file}" 2> /dev/null)
|
||||||
do
|
do
|
||||||
local path=${path_with_contract}
|
|
||||||
local contract=""
|
local contract=""
|
||||||
local delimiter
|
if [[ -z "${path_to_contract_file}" ]]
|
||||||
delimiter=$("${EXPR}" index "${path}" ":") || true
|
|
||||||
if [[ -z "${prefix}" ]]
|
|
||||||
then
|
then
|
||||||
path=${path_with_contract:0:((${delimiter} - 1))}
|
local delimiter
|
||||||
contract=${path_with_contract:((${delimiter})):((${#path_with_contract} - ${delimiter} - 1))}
|
delimiter=$("${EXPR}" index "${path_with_contract}" ":") || true
|
||||||
|
contract=${path_with_contract:((${delimiter})):((${#path_with_contract} - ${delimiter}))}
|
||||||
else
|
else
|
||||||
path=${path_with_contract}
|
contract="${path_to_contract_file}"
|
||||||
contract=""
|
|
||||||
fi
|
fi
|
||||||
for type in $(jq --raw-output ".contracts.${path_with_contract} | keys | .[]" "${json_file}" 2> /dev/null)
|
for type in $(jq --raw-output ".contracts.\"${path_with_contract}\" | keys | .[]" "${json_file}" 2> /dev/null)
|
||||||
do
|
do
|
||||||
local output
|
local output
|
||||||
output=$(jq --raw-output ".contracts.${path_with_contract}.\"${type}\"" "${json_file}")
|
output=$(jq --raw-output ".contracts.\"${path_with_contract}\".\"${type}\"" "${json_file}")
|
||||||
if [[ -n "${output}" ]]
|
if [[ -n "${output}" ]]
|
||||||
then
|
then
|
||||||
echo "${output}" > "${output_path}/${prefix}${contract}.${type}"
|
echo "${output}" > "${output_path}/${contract}.${type}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -251,7 +248,7 @@ function test_evmjson_via_ir_and_yul_import_export
|
|||||||
|
|
||||||
mkdir yul
|
mkdir yul
|
||||||
# export found solidity contracts to yul.
|
# export found solidity contracts to yul.
|
||||||
run_solc --optimize --via-ir --ir-optimized "${input_files[@]}" --no-optimize-yul -o yul/
|
run_solc --optimize --via-ir --ir-optimized "${input_files[@]}" --no-optimize-yul -o yul
|
||||||
for filename in yul/*
|
for filename in yul/*
|
||||||
do
|
do
|
||||||
if [[ -s "${filename}" ]]
|
if [[ -s "${filename}" ]]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
==== Source: A ====
|
==== Source: A ====
|
||||||
contract C {
|
contract D {
|
||||||
}
|
}
|
||||||
==== Source: B ====
|
==== Source: B ====
|
||||||
import "A" as M;
|
import "A" as M;
|
||||||
@ -7,7 +7,7 @@ import "A" as M;
|
|||||||
contract C {
|
contract C {
|
||||||
function f() public pure returns (bool) {
|
function f() public pure returns (bool) {
|
||||||
bool flag;
|
bool flag;
|
||||||
((flag = true) ? M : M).C;
|
((flag = true) ? M : M).D;
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user