aboutsummaryrefslogtreecommitdiffstats
path: root/NameAndTypeResolver.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-06-09 20:26:08 +0800
committerchriseth <c@ethdev.com>2015-06-15 20:40:41 +0800
commit258b1a74e214a69b06e603849c76362aecfae0d5 (patch)
tree9d6794a4e0c2af5175f22bb5b2cdd258f0323031 /NameAndTypeResolver.cpp
parentd60ef3f2d792989ebcbf3326bcf8fced6031b5b9 (diff)
downloaddexon-solidity-258b1a74e214a69b06e603849c76362aecfae0d5.tar.gz
dexon-solidity-258b1a74e214a69b06e603849c76362aecfae0d5.tar.zst
dexon-solidity-258b1a74e214a69b06e603849c76362aecfae0d5.zip
Distinction between storage pointer and storage ref and type checking for conversion between storage and memory.
Diffstat (limited to 'NameAndTypeResolver.cpp')
-rw-r--r--NameAndTypeResolver.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/NameAndTypeResolver.cpp b/NameAndTypeResolver.cpp
index 22232014..e6079796 100644
--- a/NameAndTypeResolver.cpp
+++ b/NameAndTypeResolver.cpp
@@ -431,7 +431,7 @@ void ReferencesResolver::endVisit(VariableDeclaration& _variable)
// They default to memory for function parameters and storage for local variables.
if (auto ref = dynamic_cast<ReferenceType const*>(type.get()))
{
- if (_variable.isExternalFunctionParameter())
+ if (_variable.isExternalCallableParameter())
{
// force location of external function parameters (not return) to calldata
if (loc != Location::Default)
@@ -439,9 +439,9 @@ void ReferencesResolver::endVisit(VariableDeclaration& _variable)
"Location has to be calldata for external functions "
"(remove the \"memory\" or \"storage\" keyword)."
));
- type = ref->copyForLocation(ReferenceType::Location::CallData);
+ type = ref->copyForLocation(ReferenceType::Location::CallData, true);
}
- else if (_variable.isFunctionParameter() && _variable.getScope()->isPublic())
+ else if (_variable.isCallableParameter() && _variable.getScope()->isPublic())
{
// force locations of public or external function (return) parameters to memory
if (loc == VariableDeclaration::Location::Storage)
@@ -449,16 +449,18 @@ void ReferencesResolver::endVisit(VariableDeclaration& _variable)
"Location has to be memory for publicly visible functions "
"(remove the \"storage\" keyword)."
));
- type = ref->copyForLocation(ReferenceType::Location::Memory);
+ type = ref->copyForLocation(ReferenceType::Location::Memory, true);
}
else
{
if (loc == Location::Default)
- loc = _variable.isFunctionParameter() ? Location::Memory : Location::Storage;
+ loc = _variable.isCallableParameter() ? Location::Memory : Location::Storage;
+ bool isPointer = !_variable.isStateVariable();
type = ref->copyForLocation(
loc == Location::Memory ?
ReferenceType::Location::Memory :
- ReferenceType::Location::Storage
+ ReferenceType::Location::Storage,
+ isPointer
);
}
}