Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/compiler/LLL/test_compile_lll.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

from vyper.codegen.lll_node import LLLnode
from vyper.lll import compile_lll
from vyper.lll.s_expressions import parse_s_exp
from vyper.old_codegen.parser import LLLnode

fail_list = [
[-(2 ** 255) - 3],
Expand Down
2 changes: 1 addition & 1 deletion tests/compiler/LLL/test_optimize_lll.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from vyper.codegen.lll_node import LLLnode
from vyper.lll import optimizer
from vyper.old_codegen.parser import LLLnode

optimize_list = [
(["eq", 1, 0], ["iszero", 1]),
Expand Down
2 changes: 1 addition & 1 deletion tests/compiler/test_sha3_32.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from vyper.codegen.lll_node import LLLnode
from vyper.lll import compile_lll, optimizer
from vyper.old_codegen.parser_utils import LLLnode


def test_sha3_32():
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from web3.providers.eth_tester import EthereumTesterProvider

from vyper import compiler
from vyper.codegen.lll_node import LLLnode
from vyper.lll import compile_lll, optimizer
from vyper.old_codegen.parser_utils import LLLnode

from .base_conftest import VyperContract, _get_contract, zero_gas_price_strategy

Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/memorymock.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from vyper.old_codegen.context import Context
from vyper.old_codegen.types import BaseType
from vyper.codegen.context import Context
from vyper.codegen.types import BaseType


class ContextMock(Context):
Expand Down Expand Up @@ -45,5 +45,5 @@ def pytest_collection_modifyitems(items, config):
@pytest.fixture
def memory_mocker(monkeypatch, request):
if request.param:
monkeypatch.setattr("vyper.old_codegen.context.Context", ContextMock)
monkeypatch.setattr("vyper.codegen.context.Context", ContextMock)
ContextMock.set_mock_var_size(request.param)
2 changes: 1 addition & 1 deletion tests/fuzzing/test_exponents.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from hypothesis import example, given, settings
from hypothesis import strategies as st

from vyper.old_codegen.expr import calculate_largest_base, calculate_largest_power
from vyper.codegen.expr import calculate_largest_base, calculate_largest_power


@pytest.mark.fuzzing
Expand Down
2 changes: 1 addition & 1 deletion tests/parser/types/test_identifier_naming.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

from vyper.builtin_functions import BUILTIN_FUNCTIONS
from vyper.codegen.expr import BUILTIN_CONSTANTS, ENVIRONMENT_VARIABLES
from vyper.exceptions import NamespaceCollision, StructureException, SyntaxException
from vyper.old_codegen.expr import BUILTIN_CONSTANTS, ENVIRONMENT_VARIABLES
from vyper.semantics.namespace import RESERVED_KEYWORDS
from vyper.utils import FUNCTION_WHITELIST

Expand Down
2 changes: 1 addition & 1 deletion tests/parser/types/test_node_types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pytest import raises

from vyper.old_codegen.types import (
from vyper.codegen.types import (
BaseType,
ByteArrayType,
MappingType,
Expand Down
4 changes: 2 additions & 2 deletions vyper/ast/signatures/function_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from typing import Optional

from vyper import ast as vy_ast
from vyper.codegen.lll_node import Encoding
from vyper.codegen.types import NodeType, canonicalize_type, parse_type
from vyper.exceptions import StructureException
from vyper.old_codegen.lll_node import Encoding
from vyper.old_codegen.types import NodeType, canonicalize_type, parse_type
from vyper.utils import cached_property, mkalphanum


Expand Down
2 changes: 1 addition & 1 deletion vyper/ast/signatures/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import vyper.builtin_interfaces
from vyper import ast as vy_ast
from vyper.ast.signatures.function_signature import FunctionSignature
from vyper.codegen.global_context import GlobalContext
from vyper.exceptions import StructureException
from vyper.old_codegen.global_context import GlobalContext


# Populate built-in interfaces.
Expand Down
8 changes: 4 additions & 4 deletions vyper/builtin_functions/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

from vyper import ast as vy_ast
from vyper.builtin_functions.signatures import signature
from vyper.evm.opcodes import version_check
from vyper.exceptions import InvalidLiteral, StructureException, TypeMismatch
from vyper.old_codegen.parser_utils import (
from vyper.codegen.core import (
LLLnode,
add_ofst,
clamp_basetype,
Expand All @@ -16,7 +14,9 @@
load_op,
shr,
)
from vyper.old_codegen.types import BaseType, ByteArrayType, StringType, get_type
from vyper.codegen.types import BaseType, ByteArrayType, StringType, get_type
from vyper.evm.opcodes import version_check
from vyper.exceptions import InvalidLiteral, StructureException, TypeMismatch
from vyper.utils import DECIMAL_DIVISOR, MemoryPositions, SizeLimits


Expand Down
52 changes: 29 additions & 23 deletions vyper/builtin_functions/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,8 @@
from vyper.ast.signatures.function_signature import VariableRecord
from vyper.ast.validation import validate_call_args
from vyper.builtin_functions.convert import convert
from vyper.evm.opcodes import version_check
from vyper.exceptions import (
ArgumentException,
CompilerPanic,
InvalidLiteral,
InvalidType,
OverflowException,
StateAccessViolation,
StructureException,
TypeMismatch,
UnfoldableNode,
VyperException,
ZeroDivisionException,
)
from vyper.old_codegen.abi import ABI_Tuple, abi_encode, abi_type_of, abi_type_of2
from vyper.old_codegen.expr import Expr
from vyper.old_codegen.keccak256_helper import keccak256_helper
from vyper.old_codegen.parser_utils import (
from vyper.codegen.abi import ABI_Tuple, abi_encode, abi_type_of, abi_type_of2
from vyper.codegen.core import (
LLLnode,
add_ofst,
check_external_call,
Expand All @@ -39,9 +23,31 @@
load_op,
unwrap_location,
)
from vyper.old_codegen.types import BaseType, ByteArrayLike, ByteArrayType, SArrayType
from vyper.old_codegen.types import StringType as OldStringType
from vyper.old_codegen.types import TupleType, is_base_type
from vyper.codegen.expr import Expr
from vyper.codegen.keccak256_helper import keccak256_helper
from vyper.codegen.types import (
BaseType,
ByteArrayLike,
ByteArrayType,
SArrayType,
StringType,
TupleType,
is_base_type,
)
from vyper.evm.opcodes import version_check
from vyper.exceptions import (
ArgumentException,
CompilerPanic,
InvalidLiteral,
InvalidType,
OverflowException,
StateAccessViolation,
StructureException,
TypeMismatch,
UnfoldableNode,
VyperException,
ZeroDivisionException,
)
from vyper.semantics.types import BoolDefinition, DynamicArrayPrimitive, TupleDefinition
from vyper.semantics.types.abstract import (
ArrayValueAbstractType,
Expand Down Expand Up @@ -266,7 +272,7 @@ def build_LLL(self, expr, args, kwargs, context):
if isinstance(args[0].typ, ByteArrayType) or is_base_type(sub.typ, "bytes32"):
ReturnType = ByteArrayType
else:
ReturnType = OldStringType
ReturnType = StringType

# Node representing the position of the output in memory
# CMC 20210917 shouldn't this be a variable with newmaxlen?
Expand Down Expand Up @@ -453,7 +459,7 @@ def build_LLL(self, expr, context):
prev_type = current_type

if current_type == "String":
ReturnType = OldStringType
ReturnType = StringType
else:
ReturnType = ByteArrayType

Expand Down
4 changes: 2 additions & 2 deletions vyper/builtin_functions/signatures.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import functools

from vyper import ast as vy_ast
from vyper.codegen.expr import Expr
from vyper.codegen.types import BaseType, ByteArrayType, StringType, is_base_type
from vyper.exceptions import InvalidLiteral, StructureException, TypeMismatch
from vyper.old_codegen.expr import Expr
from vyper.old_codegen.types import BaseType, ByteArrayType, StringType, is_base_type
from vyper.utils import SizeLimits


Expand Down
6 changes: 3 additions & 3 deletions vyper/builtin_functions/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from vyper.ast import parse_to_ast
from vyper.old_codegen.context import Context
from vyper.old_codegen.global_context import GlobalContext
from vyper.old_codegen.stmt import parse_body
from vyper.codegen.context import Context
from vyper.codegen.global_context import GlobalContext
from vyper.codegen.stmt import parse_body


def generate_inline_function(code, variables, memory_allocator):
Expand Down
4 changes: 2 additions & 2 deletions vyper/cli/vyper_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import vyper
from vyper.cli import vyper_json
from vyper.cli.utils import extract_file_interface_imports, get_interface_file_path
from vyper.codegen.lll_node import LLLnode
from vyper.compiler.settings import VYPER_TRACEBACK_LIMIT
from vyper.evm.opcodes import DEFAULT_EVM_VERSION, EVM_VERSIONS
from vyper.old_codegen import parser_utils
from vyper.typing import ContractCodes, ContractPath, OutputFormats

T = TypeVar("T")
Expand Down Expand Up @@ -231,7 +231,7 @@ def compile_files(
) -> OrderedDict:

if show_gas_estimates:
parser_utils.LLLnode.repr_show_gas = True
LLLnode.repr_show_gas = True

root_path = Path(root_folder).resolve()
if not root_path.exists():
Expand Down
2 changes: 1 addition & 1 deletion vyper/cli/vyper_lll.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import sys

import vyper
from vyper.codegen.lll_node import LLLnode
from vyper.lll import compile_lll, optimizer
from vyper.lll.s_expressions import parse_s_exp
from vyper.old_codegen.parser_utils import LLLnode


def _parse_cli_args():
Expand Down
2 changes: 1 addition & 1 deletion vyper/cli/vyper_serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from socketserver import ThreadingMixIn

import vyper
from vyper.codegen import lll_node
from vyper.evm.opcodes import DEFAULT_EVM_VERSION
from vyper.exceptions import VyperException
from vyper.old_codegen import lll_node


def _parse_cli_args():
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions vyper/old_codegen/abi.py → vyper/codegen/abi.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import vyper.semantics.types as vy
from vyper.exceptions import CompilerPanic
from vyper.old_codegen.lll_node import LLLnode
from vyper.old_codegen.parser_utils import (
from vyper.codegen.core import (
add_ofst,
get_dyn_array_count,
get_element_ptr,
Expand All @@ -10,7 +8,8 @@
unwrap_location,
zero_pad,
)
from vyper.old_codegen.types import (
from vyper.codegen.lll_node import LLLnode
from vyper.codegen.types import (
BaseType,
ByteArrayLike,
ByteArrayType,
Expand All @@ -19,6 +18,7 @@
StringType,
TupleLike,
)
from vyper.exceptions import CompilerPanic
from vyper.utils import ceil32


Expand Down
2 changes: 1 addition & 1 deletion vyper/old_codegen/context.py → vyper/codegen/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from vyper.ast import VyperNode
from vyper.ast.signatures.function_signature import VariableRecord
from vyper.codegen.types import NodeType
from vyper.exceptions import CompilerPanic, FunctionDeclarationException
from vyper.old_codegen.types import NodeType


class Constancy(enum.Enum):
Expand Down
30 changes: 15 additions & 15 deletions vyper/old_codegen/parser_utils.py → vyper/codegen/core.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
from decimal import Context, Decimal, setcontext

from vyper import ast as vy_ast
from vyper.evm.opcodes import version_check
from vyper.exceptions import (
CompilerPanic,
DecimalOverrideException,
InvalidLiteral,
StructureException,
TypeCheckFailure,
TypeMismatch,
)
from vyper.old_codegen.lll_node import Encoding, LLLnode
from vyper.old_codegen.types import (
from vyper.codegen.lll_node import Encoding, LLLnode
from vyper.codegen.types import (
DYNAMIC_ARRAY_OVERHEAD,
ArrayLike,
BaseType,
Expand All @@ -26,6 +17,15 @@
is_base_type,
is_signed_num,
)
from vyper.evm.opcodes import version_check
from vyper.exceptions import (
CompilerPanic,
DecimalOverrideException,
InvalidLiteral,
StructureException,
TypeCheckFailure,
TypeMismatch,
)
from vyper.utils import (
GAS_CALLDATACOPY_WORD,
GAS_CODECOPY_WORD,
Expand Down Expand Up @@ -137,7 +137,7 @@ def _word_size(location):
# try to refactor.
def make_dyn_array_copier(dst, src, context, pos=None):
# TODO circular import!
from vyper.old_codegen.abi import abi_type_of
from vyper.codegen.abi import abi_type_of

assert isinstance(src.typ, DArrayType)
assert isinstance(dst.typ, DArrayType)
Expand Down Expand Up @@ -309,7 +309,7 @@ def add_ofst(loc, ofst):
# Resolve pointer locations for ABI-encoded data
def _getelemptr_abi_helper(parent, member_t, ofst, pos=None, clamp=True):
# TODO circular import!
from vyper.old_codegen.abi import abi_type_of
from vyper.codegen.abi import abi_type_of

member_abi_t = abi_type_of(member_t)

Expand Down Expand Up @@ -340,7 +340,7 @@ def _getelemptr_abi_helper(parent, member_t, ofst, pos=None, clamp=True):
# TODO simplify this code, especially the ABI decoding
def _get_element_ptr_tuplelike(parent, key, pos):
# TODO circular import!
from vyper.old_codegen.abi import abi_type_of
from vyper.codegen.abi import abi_type_of

typ = parent.typ
assert isinstance(typ, TupleLike)
Expand Down Expand Up @@ -406,7 +406,7 @@ def has_length_word(typ):
# TODO simplify this code, especially the ABI decoding
def _get_element_ptr_array(parent, key, pos, array_bounds_check):
# TODO circular import!
from vyper.old_codegen.abi import abi_type_of
from vyper.codegen.abi import abi_type_of

assert isinstance(parent.typ, ArrayLike)

Expand Down
12 changes: 6 additions & 6 deletions vyper/old_codegen/events.py → vyper/codegen/events.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Tuple

from vyper.codegen.abi import ABI_Tuple, abi_encode, abi_type_of, abi_type_of2
from vyper.codegen.context import Context
from vyper.codegen.core import getpos, lll_tuple_from_args, unwrap_location
from vyper.codegen.keccak256_helper import keccak256_helper
from vyper.codegen.lll_node import LLLnode
from vyper.codegen.types.types import BaseType, ByteArrayLike, get_type_for_exact_size
from vyper.exceptions import TypeMismatch
from vyper.old_codegen.abi import ABI_Tuple, abi_encode, abi_type_of, abi_type_of2
from vyper.old_codegen.context import Context
from vyper.old_codegen.keccak256_helper import keccak256_helper
from vyper.old_codegen.lll_node import LLLnode
from vyper.old_codegen.parser_utils import getpos, lll_tuple_from_args, unwrap_location
from vyper.old_codegen.types.types import BaseType, ByteArrayLike, get_type_for_exact_size
from vyper.semantics.types import Event


Expand Down
Loading