/// Return the type for this expression. This assumes the expression has a single value,
/// panics will occur otherwise
Return the type for this expression. This assumes the expression has a single value,
panics will occur otherwise
Return the type for this expression . This assumes the expression has a single value panics will occur otherwise
pub fn ty(&self) -> Type {
        match self {
            Expression::BoolLiteral(_, _)
            | Expression::More(_, _, _)
            | Expression::Less(_, _, _)
            | Expression::MoreEqual(_, _, _)
            | Expression::LessEqual(_, _, _)
            | Expression::Equal(_, _, _)
            | Expression::Or(_, _, _)
            | Expression::And(_, _, _)
            | Expression::NotEqual(_, _, _)
            | Expression::Not(_, _)
            | Expression::StringCompare(_, _, _) => Type::Bool,
            Expression::CodeLiteral(_, _, _) => Type::DynamicBytes,
            Expression::StringConcat(_, ty, _, _)
            | Expression::FunctionArg(_, ty, _)
            | Expression::BytesLiteral(_, ty, _)
            | Expression::NumberLiteral(_, ty, _)
            | Expression::StructLiteral(_, ty, _)
            | Expression::ArrayLiteral(_, ty, _, _)
            | Expression::ConstArrayLiteral(_, ty, _, _)
            | Expression::Add(_, ty, _, _)
            | Expression::Subtract(_, ty, _, _)
            | Expression::Multiply(_, ty, _, _)
            | Expression::Divide(_, ty, _, _)
            | Expression::Modulo(_, ty, _, _)
            | Expression::Power(_, ty, _, _)
            | Expression::BitwiseOr(_, ty, _, _)
            | Expression::BitwiseAnd(_, ty, _, _)
            | Expression::BitwiseXor(_, ty, _, _)
            | Expression::ShiftLeft(_, ty, _, _)
            | Expression::ShiftRight(_, ty, _, _, _)
            | Expression::Variable(_, ty, _)
            | Expression::ConstantVariable(_, ty, _, _)
            | Expression::StorageVariable(_, ty, _, _)
            | Expression::Load(_, ty, _)
            | Expression::StorageLoad(_, ty, _)
            | Expression::ZeroExt(_, ty, _)
            | Expression::SignExt(_, ty, _)
            | Expression::Trunc(_, ty, _)
            | Expression::Cast(_, ty, _)
            | Expression::BytesCast(_, _, ty, _)
            | Expression::Complement(_, ty, _)
            | Expression::UnaryMinus(_, ty, _)
            | Expression::Ternary(_, ty, _, _, _)
            | Expression::ArraySubscript(_, ty, _, _)
            | Expression::StructMember(_, ty, _, _)
            | Expression::AllocDynamicArray(_, ty, _, _)
            | Expression::DynamicArraySubscript(_, ty, _, _)
            | Expression::PreIncrement(_, ty, _)
            | Expression::PreDecrement(_, ty, _)
            | Expression::PostIncrement(_, ty, _)
            | Expression::PostDecrement(_, ty, _)
            | Expression::Keccak256(_, ty, _)
            | Expression::Assign(_, ty, _, _) => ty.clone(),
            Expression::DynamicArrayPush(_, _, ty, _) | Expression::DynamicArrayPop(_, _, ty) => {
                match ty {
                    Type::Array(..) => ty.array_elem(),
                    Type::DynamicBytes => Type::Uint(8),
                    _ => unreachable!(),
                }
            }
            Expression::DynamicArrayLength(_, _) => Type::Uint(32),
            Expression::StorageBytesLength(_, _) => Type::Uint(32),
            Expression::StorageBytesSubscript(_, _, _) => {
                Type::StorageRef(Box::new(Type::Bytes(1)))
            }
            Expression::ExternalFunctionCallRaw { .. } => {
                panic!("two return values");
            }
            Expression::Builtin(_, returns, _, _)
            | Expression::InternalFunctionCall { returns, .. }
            | Expression::ExternalFunctionCall { returns, .. } => {
                assert_eq!(returns.len(), 1);
                returns[0].clone()
            }
            Expression::List(_, list) => {
                assert_eq!(list.len(), 1);
                list[0].ty()
            }
            Expression::Constructor { contract_no, .. } => Type::Contract(*contract_no),
            Expression::Poison => unreachable!(),
            Expression::FormatString(_, _) => Type::String,
            // codegen Expressions
            Expression::ReturnData(_) => Type::DynamicBytes,
            Expression::InternalFunction { ty, .. } => ty.clone(),
            Expression::ExternalFunction { ty, .. } => ty.clone(),
            Expression::InternalFunctionCfg(_) => unreachable!(),
        }
    }
pub fn ty ( & self ) -> Type { match self { Expression :: BoolLiteral ( _ , _ ) | Expression :: More ( _ , _ , _ ) | Expression :: Less ( _ , _ , _ ) | Expression :: MoreEqual ( _ , _ , _ ) | Expression :: LessEqual ( _ , _ , _ ) | Expression :: Equal ( _ , _ , _ ) | Expression :: Or ( _ , _ , _ ) | Expression :: And ( _ , _ , _ ) | Expression :: NotEqual ( _ , _ , _ ) | Expression :: Not ( _ , _ ) | Expression :: StringCompare ( _ , _ , _ ) => Type :: Bool , Expression :: CodeLiteral ( _ , _ , _ ) => Type :: DynamicBytes , Expression :: StringConcat ( _ , ty , _ , _ ) | Expression :: FunctionArg ( _ , ty , _ ) | Expression :: BytesLiteral ( _ , ty , _ ) | Expression :: NumberLiteral ( _ , ty , _ ) | Expression :: StructLiteral ( _ , ty , _ ) | Expression :: ArrayLiteral ( _ , ty , _ , _ ) | Expression :: ConstArrayLiteral ( _ , ty , _ , _ ) | Expression :: Add ( _ , ty , _ , _ ) | Expression :: Subtract ( _ , ty , _ , _ ) | Expression :: Multiply ( _ , ty , _ , _ ) | Expression :: Divide ( _ , ty , _ , _ ) | Expression :: Modulo ( _ , ty , _ , _ ) | Expression :: Power ( _ , ty , _ , _ ) | Expression :: BitwiseOr ( _ , ty , _ , _ ) | Expression :: BitwiseAnd ( _ , ty , _ , _ ) | Expression :: BitwiseXor ( _ , ty , _ , _ ) | Expression :: ShiftLeft ( _ , ty , _ , _ ) | Expression :: ShiftRight ( _ , ty , _ , _ , _ ) | Expression :: Variable ( _ , ty , _ ) | Expression :: ConstantVariable ( _ , ty , _ , _ ) | Expression :: StorageVariable ( _ , ty , _ , _ ) | Expression :: Load ( _ , ty , _ ) | Expression :: StorageLoad ( _ , ty , _ ) | Expression :: ZeroExt ( _ , ty , _ ) | Expression :: SignExt ( _ , ty , _ ) | Expression :: Trunc ( _ , ty , _ ) | Expression :: Cast ( _ , ty , _ ) | Expression :: BytesCast ( _ , _ , ty , _ ) | Expression :: Complement ( _ , ty , _ ) | Expression :: UnaryMinus ( _ , ty , _ ) | Expression :: Ternary ( _ , ty , _ , _ , _ ) | Expression :: ArraySubscript ( _ , ty , _ , _ ) | Expression :: StructMember ( _ , ty , _ , _ ) | Expression :: AllocDynamicArray ( _ , ty , _ , _ ) | Expression :: DynamicArraySubscript ( _ , ty , _ , _ ) | Expression :: PreIncrement ( _ , ty , _ ) | Expression :: PreDecrement ( _ , ty , _ ) | Expression :: PostIncrement ( _ , ty , _ ) | Expression :: PostDecrement ( _ , ty , _ ) | Expression :: Keccak256 ( _ , ty , _ ) | Expression :: Assign ( _ , ty , _ , _ ) => ty . clone ( ) , Expression :: DynamicArrayPush ( _ , _ , ty , _ ) | Expression :: DynamicArrayPop ( _ , _ , ty ) => { match ty { Type :: Array ( .. ) => ty . array_elem ( ) , Type :: DynamicBytes => Type :: Uint ( 8 ) , _ => unreachable ! ( ) , } } Expression :: DynamicArrayLength ( _ , _ ) => Type :: Uint ( 32 ) , Expression :: StorageBytesLength ( _ , _ ) => Type :: Uint ( 32 ) , Expression :: StorageBytesSubscript ( _ , _ , _ ) => { Type :: StorageRef ( Box :: new ( Type :: Bytes ( 1 ) ) ) } Expression :: ExternalFunctionCallRaw { .. } => { panic ! ( " " ) ; } Expression :: Builtin ( _ , returns , _ , _ ) | Expression :: InternalFunctionCall { returns , .. } | Expression :: ExternalFunctionCall { returns , .. } => { assert_eq ! ( returns len ( ) 1 ) ; returns [ 0 ] . clone ( ) } Expression :: List ( _ , list ) => { assert_eq ! ( list len ( ) 1 ) ; list [ 0 ] . ty ( ) } Expression :: Constructor { contract_no , .. } => Type :: Contract ( * contract_no ) , Expression :: Poison => unreachable ! ( ) , Expression :: FormatString ( _ , _ ) => Type :: String , // codegen Expressions Expression :: ReturnData ( _ ) => Type :: DynamicBytes , Expression :: InternalFunction { ty , .. } => ty . clone ( ) , Expression :: ExternalFunction { ty , .. } => ty . clone ( ) , Expression :: InternalFunctionCfg ( _ ) => unreachable ! ( ) , } }
Return the type for this expression.
Return the type for this expression .
&self