aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiana Husikyan <liana@ethdev.com>2015-04-23 00:53:58 +0800
committerLiana Husikyan <liana@ethdev.com>2015-04-27 19:08:32 +0800
commit88536f90e8403239380c280176250390bab2cd8d (patch)
tree7ca4aa77cf9e039c02265ebdaa3d6650680931c8
parent648ce852561a1a28bebf3be1a64480aee560bf7a (diff)
downloaddexon-solidity-88536f90e8403239380c280176250390bab2cd8d.tar
dexon-solidity-88536f90e8403239380c280176250390bab2cd8d.tar.gz
dexon-solidity-88536f90e8403239380c280176250390bab2cd8d.tar.bz2
dexon-solidity-88536f90e8403239380c280176250390bab2cd8d.tar.lz
dexon-solidity-88536f90e8403239380c280176250390bab2cd8d.tar.xz
dexon-solidity-88536f90e8403239380c280176250390bab2cd8d.tar.zst
dexon-solidity-88536f90e8403239380c280176250390bab2cd8d.zip
changed the test so constructor will have input parameters
-rw-r--r--AST.cpp7
-rw-r--r--ExpressionCompiler.cpp15
-rw-r--r--Types.cpp48
-rw-r--r--Types.h44
4 files changed, 83 insertions, 31 deletions
diff --git a/AST.cpp b/AST.cpp
index 59a7b61c..83b0adf3 100644
--- a/AST.cpp
+++ b/AST.cpp
@@ -817,8 +817,11 @@ void NewExpression::checkTypeRequirements(TypePointers const*)
BOOST_THROW_EXCEPTION(createTypeError("Trying to create an instance of an abstract contract."));
shared_ptr<ContractType const> contractType = make_shared<ContractType>(*m_contract);
TypePointers const& parameterTypes = contractType->getConstructorType()->getParameterTypes();
- m_type = make_shared<FunctionType>(parameterTypes, TypePointers{contractType},
- FunctionType::Location::Creation);
+ m_type = make_shared<FunctionType>(
+ parameterTypes,
+ TypePointers{contractType},
+ strings(),
+ FunctionType::Location::Creation);
}
void MemberAccess::checkTypeRequirements(TypePointers const* _argumentTypes)
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp
index 8c07fbd1..ae825be1 100644
--- a/ExpressionCompiler.cpp
+++ b/ExpressionCompiler.cpp
@@ -521,8 +521,19 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
arguments.front()->accept(*this);
appendTypeConversion(*arguments.front()->getType(),
*function.getParameterTypes().front(), true);
- appendExternalFunctionCall(FunctionType(TypePointers{}, TypePointers{},
- Location::External, false, true, true), {}, true);
+ appendExternalFunctionCall(
+ FunctionType(
+ TypePointers{},
+ TypePointers{},
+ strings(),
+ Location::External,
+ false,
+ true,
+ true
+ ),
+ {},
+ true
+ );
break;
case Location::Suicide:
arguments.front()->accept(*this);
diff --git a/Types.cpp b/Types.cpp
index 19bc134e..40b0dba6 100644
--- a/Types.cpp
+++ b/Types.cpp
@@ -1143,7 +1143,7 @@ FunctionTypePointer FunctionType::externalFunctionType() const
return FunctionTypePointer();
retParamTypes.push_back(type->externalType());
}
- return make_shared<FunctionType>(paramTypes, retParamTypes, m_location, m_arbitraryParameters);
+ return make_shared<FunctionType>(paramTypes, retParamTypes, m_parameterNames, m_location, m_arbitraryParameters);
}
MemberList const& FunctionType::getMembers() const
@@ -1159,14 +1159,34 @@ MemberList const& FunctionType::getMembers() const
if (!m_members)
{
MemberList::MemberMap members{
- {"value", make_shared<FunctionType>(parseElementaryTypeVector({"uint"}),
- TypePointers{copyAndSetGasOrValue(false, true)},
- Location::SetValue, false, m_gasSet, m_valueSet)}};
+ {
+ "value",
+ make_shared<FunctionType>(
+ parseElementaryTypeVector({"uint"}),
+ TypePointers{copyAndSetGasOrValue(false, true)},
+ strings(),
+ Location::SetValue,
+ false,
+ m_gasSet,
+ m_valueSet
+ )
+ }
+ };
if (m_location != Location::Creation)
- members.push_back(MemberList::Member("gas", make_shared<FunctionType>(
- parseElementaryTypeVector({"uint"}),
- TypePointers{copyAndSetGasOrValue(true, false)},
- Location::SetGas, false, m_gasSet, m_valueSet)));
+ members.push_back(
+ MemberList::Member(
+ "gas",
+ make_shared<FunctionType>(
+ parseElementaryTypeVector({"uint"}),
+ TypePointers{copyAndSetGasOrValue(true, false)},
+ strings(),
+ Location::SetGas,
+ false,
+ m_gasSet,
+ m_valueSet
+ )
+ )
+ );
m_members.reset(new MemberList(members));
}
return *m_members;
@@ -1244,9 +1264,15 @@ TypePointers FunctionType::parseElementaryTypeVector(strings const& _types)
TypePointer FunctionType::copyAndSetGasOrValue(bool _setGas, bool _setValue) const
{
- return make_shared<FunctionType>(m_parameterTypes, m_returnParameterTypes, m_location,
- m_arbitraryParameters,
- m_gasSet || _setGas, m_valueSet || _setValue);
+ return make_shared<FunctionType>(
+ m_parameterTypes,
+ m_returnParameterTypes,
+ strings(),
+ m_location,
+ m_arbitraryParameters,
+ m_gasSet || _setGas,
+ m_valueSet || _setValue
+ );
}
vector<string> const FunctionType::getParameterTypeNames() const
diff --git a/Types.h b/Types.h
index cc9c455f..49dd436d 100644
--- a/Types.h
+++ b/Types.h
@@ -564,24 +564,36 @@ public:
explicit FunctionType(FunctionDefinition const& _function, bool _isInternal = true);
explicit FunctionType(VariableDeclaration const& _varDecl);
explicit FunctionType(EventDefinition const& _event);
- FunctionType(strings const& _parameterTypes, strings const& _returnParameterTypes,
- Location _location = Location::Internal, bool _arbitraryParameters = false):
- FunctionType(parseElementaryTypeVector(_parameterTypes), parseElementaryTypeVector(_returnParameterTypes),
- _location, _arbitraryParameters) {}
FunctionType(
- TypePointers const& _parameterTypes,
- TypePointers const& _returnParameterTypes,
- Location _location = Location::Internal,
- bool _arbitraryParameters = false,
- bool _gasSet = false,
- bool _valueSet = false
+ strings const& _parameterTypes,
+ strings const& _returnParameterTypes,
+ Location _location = Location::Internal,
+ bool _arbitraryParameters = false
+ ): FunctionType(
+ parseElementaryTypeVector(_parameterTypes),
+ parseElementaryTypeVector(_returnParameterTypes),
+ strings(),
+ _location,
+ _arbitraryParameters
+ )
+ {
+ }
+ FunctionType(
+ TypePointers const& _parameterTypes,
+ TypePointers const& _returnParameterTypes,
+ strings _parameterNames = strings(),
+ Location _location = Location::Internal,
+ bool _arbitraryParameters = false,
+ bool _gasSet = false,
+ bool _valueSet = false
):
- m_parameterTypes (_parameterTypes),
- m_returnParameterTypes (_returnParameterTypes),
- m_location (_location),
- m_arbitraryParameters (_arbitraryParameters),
- m_gasSet (_gasSet),
- m_valueSet (_valueSet)
+ m_parameterTypes (_parameterTypes),
+ m_returnParameterTypes (_returnParameterTypes),
+ m_parameterNames (_parameterNames),
+ m_location (_location),
+ m_arbitraryParameters (_arbitraryParameters),
+ m_gasSet (_gasSet),
+ m_valueSet (_valueSet)
{}
TypePointers const& getParameterTypes() const { return m_parameterTypes; }