-
Notifications
You must be signed in to change notification settings - Fork 997
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1784 from Troublor/array-type
Make type information of NewArray more precise
- Loading branch information
Showing
10 changed files
with
57 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,23 @@ | ||
from typing import Union, TYPE_CHECKING | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from slither.core.expressions.expression import Expression | ||
from slither.core.solidity_types.type import Type | ||
|
||
if TYPE_CHECKING: | ||
from slither.core.solidity_types.elementary_type import ElementaryType | ||
from slither.core.solidity_types.type_alias import TypeAliasTopLevel | ||
from slither.core.solidity_types.array_type import ArrayType | ||
|
||
|
||
class NewArray(Expression): | ||
|
||
# note: dont conserve the size of the array if provided | ||
def __init__( | ||
self, depth: int, array_type: Union["TypeAliasTopLevel", "ElementaryType"] | ||
) -> None: | ||
def __init__(self, array_type: "ArrayType") -> None: | ||
super().__init__() | ||
assert isinstance(array_type, Type) | ||
self._depth: int = depth | ||
self._array_type: Type = array_type | ||
# pylint: disable=import-outside-toplevel | ||
from slither.core.solidity_types.array_type import ArrayType | ||
|
||
@property | ||
def array_type(self) -> Type: | ||
return self._array_type | ||
assert isinstance(array_type, ArrayType) | ||
self._array_type = array_type | ||
|
||
@property | ||
def depth(self) -> int: | ||
return self._depth | ||
def array_type(self) -> "ArrayType": | ||
return self._array_type | ||
|
||
def __str__(self): | ||
return "new " + str(self._array_type) + "[]" * self._depth | ||
return "new " + str(self._array_type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters