|
@ -45,8 +45,8 @@ shared_ptr<Type const> Type::fromElementaryTypeName(Token::Value _typeToken) |
|
|
bytes = 32; |
|
|
bytes = 32; |
|
|
int modifier = offset / 33; |
|
|
int modifier = offset / 33; |
|
|
return make_shared<IntegerType>(bytes * 8, |
|
|
return make_shared<IntegerType>(bytes * 8, |
|
|
modifier == 0 ? IntegerType::Modifier::SIGNED : |
|
|
modifier == 0 ? IntegerType::Modifier::Signed : |
|
|
modifier == 1 ? IntegerType::Modifier::UNSIGNED : |
|
|
modifier == 1 ? IntegerType::Modifier::Unsigned : |
|
|
IntegerType::Modifier::Hash); |
|
|
IntegerType::Modifier::Hash); |
|
|
} |
|
|
} |
|
|
else if (_typeToken == Token::Address) |
|
|
else if (_typeToken == Token::Address) |
|
@ -211,10 +211,10 @@ TypePointer IntegerType::binaryOperatorResult(Token::Value _operator, TypePointe |
|
|
const MemberList IntegerType::AddressMemberList = |
|
|
const MemberList IntegerType::AddressMemberList = |
|
|
MemberList({{"balance", make_shared<IntegerType >(256)}, |
|
|
MemberList({{"balance", make_shared<IntegerType >(256)}, |
|
|
{"callstring32", make_shared<FunctionType>(strings{"string32"}, strings{}, |
|
|
{"callstring32", make_shared<FunctionType>(strings{"string32"}, strings{}, |
|
|
FunctionType::Location::BARE)}, |
|
|
FunctionType::Location::Bare)}, |
|
|
{"callstring32string32", make_shared<FunctionType>(strings{"string32", "string32"}, |
|
|
{"callstring32string32", make_shared<FunctionType>(strings{"string32", "string32"}, |
|
|
strings{}, FunctionType::Location::BARE)}, |
|
|
strings{}, FunctionType::Location::Bare)}, |
|
|
{"send", make_shared<FunctionType>(strings{"uint"}, strings{}, FunctionType::Location::SEND)}}); |
|
|
{"send", make_shared<FunctionType>(strings{"uint"}, strings{}, FunctionType::Location::Send)}}); |
|
|
|
|
|
|
|
|
IntegerConstantType::IntegerConstantType(Literal const& _literal) |
|
|
IntegerConstantType::IntegerConstantType(Literal const& _literal) |
|
|
{ |
|
|
{ |
|
@ -374,8 +374,8 @@ shared_ptr<IntegerType const> IntegerConstantType::getIntegerType() const |
|
|
return shared_ptr<IntegerType const>(); |
|
|
return shared_ptr<IntegerType const>(); |
|
|
else |
|
|
else |
|
|
return make_shared<IntegerType>(max(bytesRequired(value), 1u) * 8, |
|
|
return make_shared<IntegerType>(max(bytesRequired(value), 1u) * 8, |
|
|
negative ? IntegerType::Modifier::SIGNED |
|
|
negative ? IntegerType::Modifier::Signed |
|
|
: IntegerType::Modifier::UNSIGNED); |
|
|
: IntegerType::Modifier::Unsigned); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
shared_ptr<StaticStringType> StaticStringType::smallestTypeForLiteral(string const& _literal) |
|
|
shared_ptr<StaticStringType> StaticStringType::smallestTypeForLiteral(string const& _literal) |
|
@ -616,7 +616,7 @@ u256 StructType::getStorageOffsetOfMember(string const& _name) const |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
FunctionType::FunctionType(FunctionDefinition const& _function, bool _isInternal): |
|
|
FunctionType::FunctionType(FunctionDefinition const& _function, bool _isInternal): |
|
|
m_location(_isInternal ? Location::INTERNAL : Location::EXTERNAL), |
|
|
m_location(_isInternal ? Location::Internal : Location::External), |
|
|
m_isConstant(_function.isDeclaredConst()), |
|
|
m_isConstant(_function.isDeclaredConst()), |
|
|
m_declaration(&_function) |
|
|
m_declaration(&_function) |
|
|
{ |
|
|
{ |
|
@ -646,7 +646,7 @@ FunctionType::FunctionType(FunctionDefinition const& _function, bool _isInternal |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
FunctionType::FunctionType(VariableDeclaration const& _varDecl): |
|
|
FunctionType::FunctionType(VariableDeclaration const& _varDecl): |
|
|
m_location(Location::EXTERNAL), m_isConstant(true), m_declaration(&_varDecl) |
|
|
m_location(Location::External), m_isConstant(true), m_declaration(&_varDecl) |
|
|
{ |
|
|
{ |
|
|
TypePointers params; |
|
|
TypePointers params; |
|
|
vector<string> paramNames; |
|
|
vector<string> paramNames; |
|
@ -683,7 +683,7 @@ FunctionType::FunctionType(VariableDeclaration const& _varDecl): |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
FunctionType::FunctionType(const EventDefinition& _event): |
|
|
FunctionType::FunctionType(const EventDefinition& _event): |
|
|
m_location(Location::EVENT), m_declaration(&_event) |
|
|
m_location(Location::Event), m_declaration(&_event) |
|
|
{ |
|
|
{ |
|
|
TypePointers params; |
|
|
TypePointers params; |
|
|
vector<string> paramNames; |
|
|
vector<string> paramNames; |
|
@ -740,9 +740,9 @@ string FunctionType::toString() const |
|
|
unsigned FunctionType::getSizeOnStack() const |
|
|
unsigned FunctionType::getSizeOnStack() const |
|
|
{ |
|
|
{ |
|
|
unsigned size = 0; |
|
|
unsigned size = 0; |
|
|
if (m_location == Location::EXTERNAL) |
|
|
if (m_location == Location::External) |
|
|
size = 2; |
|
|
size = 2; |
|
|
else if (m_location == Location::INTERNAL || m_location == Location::BARE) |
|
|
else if (m_location == Location::Internal || m_location == Location::Bare) |
|
|
size = 1; |
|
|
size = 1; |
|
|
if (m_gasSet) |
|
|
if (m_gasSet) |
|
|
size++; |
|
|
size++; |
|
@ -755,22 +755,22 @@ MemberList const& FunctionType::getMembers() const |
|
|
{ |
|
|
{ |
|
|
switch (m_location) |
|
|
switch (m_location) |
|
|
{ |
|
|
{ |
|
|
case Location::EXTERNAL: |
|
|
case Location::External: |
|
|
case Location::CREATION: |
|
|
case Location::Creation: |
|
|
case Location::ECRECOVER: |
|
|
case Location::ECRecover: |
|
|
case Location::SHA256: |
|
|
case Location::SHA256: |
|
|
case Location::RIPEMD160: |
|
|
case Location::RIPEMD160: |
|
|
case Location::BARE: |
|
|
case Location::Bare: |
|
|
if (!m_members) |
|
|
if (!m_members) |
|
|
{ |
|
|
{ |
|
|
map<string, TypePointer> members{ |
|
|
map<string, TypePointer> members{ |
|
|
{"gas", make_shared<FunctionType>(parseElementaryTypeVector({"uint"}), |
|
|
{"gas", make_shared<FunctionType>(parseElementaryTypeVector({"uint"}), |
|
|
TypePointers{copyAndSetGasOrValue(true, false)}, |
|
|
TypePointers{copyAndSetGasOrValue(true, false)}, |
|
|
Location::SET_GAS, m_gasSet, m_valueSet)}, |
|
|
Location::SetGas, m_gasSet, m_valueSet)}, |
|
|
{"value", make_shared<FunctionType>(parseElementaryTypeVector({"uint"}), |
|
|
{"value", make_shared<FunctionType>(parseElementaryTypeVector({"uint"}), |
|
|
TypePointers{copyAndSetGasOrValue(false, true)}, |
|
|
TypePointers{copyAndSetGasOrValue(false, true)}, |
|
|
Location::SET_VALUE, m_gasSet, m_valueSet)}}; |
|
|
Location::SetValue, m_gasSet, m_valueSet)}}; |
|
|
if (m_location == Location::CREATION) |
|
|
if (m_location == Location::Creation) |
|
|
members.erase("gas"); |
|
|
members.erase("gas"); |
|
|
m_members.reset(new MemberList(members)); |
|
|
m_members.reset(new MemberList(members)); |
|
|
} |
|
|
} |
|
@ -919,20 +919,20 @@ MagicType::MagicType(MagicType::Kind _kind): |
|
|
{ |
|
|
{ |
|
|
switch (m_kind) |
|
|
switch (m_kind) |
|
|
{ |
|
|
{ |
|
|
case Kind::BLOCK: |
|
|
case Kind::Block: |
|
|
m_members = MemberList({{"coinbase", make_shared<IntegerType>(0, IntegerType::Modifier::Address)}, |
|
|
m_members = MemberList({{"coinbase", make_shared<IntegerType>(0, IntegerType::Modifier::Address)}, |
|
|
{"timestamp", make_shared<IntegerType>(256)}, |
|
|
{"timestamp", make_shared<IntegerType>(256)}, |
|
|
{"blockhash", make_shared<FunctionType>(strings{"uint"}, strings{"hash"}, FunctionType::Location::BLOCKHASH)}, |
|
|
{"blockhash", make_shared<FunctionType>(strings{"uint"}, strings{"hash"}, FunctionType::Location::BlockHash)}, |
|
|
{"difficulty", make_shared<IntegerType>(256)}, |
|
|
{"difficulty", make_shared<IntegerType>(256)}, |
|
|
{"number", make_shared<IntegerType>(256)}, |
|
|
{"number", make_shared<IntegerType>(256)}, |
|
|
{"gaslimit", make_shared<IntegerType>(256)}}); |
|
|
{"gaslimit", make_shared<IntegerType>(256)}}); |
|
|
break; |
|
|
break; |
|
|
case Kind::MSG: |
|
|
case Kind::Message: |
|
|
m_members = MemberList({{"sender", make_shared<IntegerType>(0, IntegerType::Modifier::Address)}, |
|
|
m_members = MemberList({{"sender", make_shared<IntegerType>(0, IntegerType::Modifier::Address)}, |
|
|
{"gas", make_shared<IntegerType>(256)}, |
|
|
{"gas", make_shared<IntegerType>(256)}, |
|
|
{"value", make_shared<IntegerType>(256)}}); |
|
|
{"value", make_shared<IntegerType>(256)}}); |
|
|
break; |
|
|
break; |
|
|
case Kind::TX: |
|
|
case Kind::Transaction: |
|
|
m_members = MemberList({{"origin", make_shared<IntegerType>(0, IntegerType::Modifier::Address)}, |
|
|
m_members = MemberList({{"origin", make_shared<IntegerType>(0, IntegerType::Modifier::Address)}, |
|
|
{"gasprice", make_shared<IntegerType>(256)}}); |
|
|
{"gasprice", make_shared<IntegerType>(256)}}); |
|
|
break; |
|
|
break; |
|
@ -953,11 +953,11 @@ string MagicType::toString() const |
|
|
{ |
|
|
{ |
|
|
switch (m_kind) |
|
|
switch (m_kind) |
|
|
{ |
|
|
{ |
|
|
case Kind::BLOCK: |
|
|
case Kind::Block: |
|
|
return "block"; |
|
|
return "block"; |
|
|
case Kind::MSG: |
|
|
case Kind::Message: |
|
|
return "msg"; |
|
|
return "msg"; |
|
|
case Kind::TX: |
|
|
case Kind::Transaction: |
|
|
return "tx"; |
|
|
return "tx"; |
|
|
default: |
|
|
default: |
|
|
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown kind of magic.")); |
|
|
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown kind of magic.")); |
|
|