From 258b1a74e214a69b06e603849c76362aecfae0d5 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 9 Jun 2015 14:26:08 +0200 Subject: Distinction between storage pointer and storage ref and type checking for conversion between storage and memory. --- ExpressionCompiler.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'ExpressionCompiler.cpp') diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index d9b6da14..811ee60e 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -204,7 +204,7 @@ void ExpressionCompiler::appendTypeConversion(Type const& _typeOnStack, Type con } else if (targetTypeCategory == Type::Category::Enum) // just clean - appendTypeConversion(_typeOnStack, *_typeOnStack.getRealType(), true); + appendTypeConversion(_typeOnStack, *_typeOnStack.mobileType(), true); else { solAssert(targetTypeCategory == Type::Category::Integer || targetTypeCategory == Type::Category::Contract, ""); @@ -232,6 +232,25 @@ void ExpressionCompiler::appendTypeConversion(Type const& _typeOnStack, Type con } } break; + case Type::Category::Array: + //@TODO + break; + case Type::Category::Struct: + { + solAssert(targetTypeCategory == stackTypeCategory, ""); + auto& targetType = dynamic_cast(_targetType); + auto& stackType = dynamic_cast(_typeOnStack); + solAssert( + targetType.location() == ReferenceType::Location::Storage && + stackType.location() == ReferenceType::Location::Storage, + "Non-storage structs not yet implemented." + ); + solAssert( + targetType.isPointer(), + "Type conversion to non-pointer struct requested." + ); + break; + } default: // All other types should not be convertible to non-equal types. solAssert(_typeOnStack == _targetType, "Invalid type conversion requested."); @@ -771,7 +790,7 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess) TypeType const& type = dynamic_cast(*_memberAccess.getExpression().getType()); solAssert( !type.getMembers().membersByName(_memberAccess.getMemberName()).empty(), - "Invalid member access to " + type.toString() + "Invalid member access to " + type.toString(false) ); if (dynamic_cast(type.getActualType().get())) @@ -1101,7 +1120,7 @@ void ExpressionCompiler::appendExternalFunctionCall( bool manualFunctionId = (funKind == FunctionKind::Bare || funKind == FunctionKind::BareCallCode) && !_arguments.empty() && - _arguments.front()->getType()->getRealType()->getCalldataEncodedSize(false) == + _arguments.front()->getType()->mobileType()->getCalldataEncodedSize(false) == CompilerUtils::dataStartOffset; if (manualFunctionId) { @@ -1225,7 +1244,7 @@ void ExpressionCompiler::encodeToMemory( TypePointers targetTypes = _targetTypes.empty() ? _givenTypes : _targetTypes; solAssert(targetTypes.size() == _givenTypes.size(), ""); for (TypePointer& t: targetTypes) - t = t->getRealType()->externalType(); + t = t->mobileType()->externalType(); // Stack during operation: // ... ... @@ -1325,7 +1344,7 @@ void ExpressionCompiler::appendExpressionCopyToMemory(Type const& _expectedType, appendTypeMoveToMemory(_expectedType); } else - appendTypeMoveToMemory(*_expression.getType()->getRealType()); + appendTypeMoveToMemory(*_expression.getType()->mobileType()); } void ExpressionCompiler::setLValueFromDeclaration(Declaration const& _declaration, Expression const& _expression) -- cgit