From 28e99bbd7d5b482a68c86984731158f55a323dce Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 4 Feb 2015 16:37:54 +0100 Subject: [PATCH 1/9] Adding ether subdenominations after constan literals --- libsolidity/AST.cpp | 11 +++++++++++ libsolidity/AST.h | 16 +++++++++++++--- libsolidity/Parser.cpp | 6 ++++-- libsolidity/Token.h | 5 +++++ libsolidity/Types.cpp | 27 ++++++++++++++++++++++++--- 5 files changed, 57 insertions(+), 8 deletions(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index 6028c07cf..f0c60e05d 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -594,6 +594,17 @@ void ElementaryTypeNameExpression::checkTypeRequirements() m_type = make_shared(Type::fromElementaryTypeName(m_typeToken)); } +Literal::Literal(Location const& _location, Token::Value _token, + ASTPointer const& _value, + Token::Value _sub): + PrimaryExpression(_location), m_token(_token), m_value(_value) +{ + solAssert(_sub == Token::ILLEGAL || _sub == Token::ETH_SUB_WEI || + _sub == Token::ETH_SUB_SZABO || _sub == Token::ETH_SUB_FINNEY || + _sub == Token::ETH_SUB_ETHER, "Illegal Token::Value given to Literal ctor"); + m_subDenomination =static_cast(_sub); +} + void Literal::checkTypeRequirements() { m_type = Type::forLiteral(*this); diff --git a/libsolidity/AST.h b/libsolidity/AST.h index 525907bf4..ecf91c059 100755 --- a/libsolidity/AST.h +++ b/libsolidity/AST.h @@ -1112,13 +1112,20 @@ private: }; /** - * A literal string or number. @see Type::literalToBigEndian is used to actually parse its value. + * A literal string or number. @see ExpressionCompiler::endVisit() is used to actually parse its value. */ class Literal: public PrimaryExpression { public: - Literal(Location const& _location, Token::Value _token, ASTPointer const& _value): - PrimaryExpression(_location), m_token(_token), m_value(_value) {} + enum class ethSubDenomination { + NONE = Token::ILLEGAL, + WEI = Token::ETH_SUB_WEI, + SZABO = Token::ETH_SUB_SZABO, + FINNEY = Token::ETH_SUB_FINNEY, + ETHER = Token::ETH_SUB_ETHER}; + Literal(Location const& _location, Token::Value _token, + ASTPointer const& _value, + Token::Value _sub = Token::ILLEGAL); virtual void accept(ASTVisitor& _visitor) override; virtual void accept(ASTConstVisitor& _visitor) const override; virtual void checkTypeRequirements() override; @@ -1127,9 +1134,12 @@ public: /// @returns the non-parsed value of the literal ASTString const& getValue() const { return *m_value; } + ethSubDenomination getSubDenomination() const { return m_subDenomination; } + private: Token::Value m_token; ASTPointer m_value; + ethSubDenomination m_subDenomination; }; /// @} diff --git a/libsolidity/Parser.cpp b/libsolidity/Parser.cpp index 0ad7bd7ca..739bbdd61 100644 --- a/libsolidity/Parser.cpp +++ b/libsolidity/Parser.cpp @@ -180,7 +180,7 @@ ASTPointer Parser::parseInheritanceSpecifier() Declaration::Visibility Parser::parseVisibilitySpecifier(Token::Value _token) { - Declaration::Visibility visibility; + Declaration::Visibility visibility = Declaration::Visibility::DEFAULT; if (_token == Token::PUBLIC) visibility = Declaration::Visibility::PUBLIC; else if (_token == Token::PROTECTED) @@ -684,6 +684,7 @@ ASTPointer Parser::parsePrimaryExpression() ASTNodeFactory nodeFactory(*this); Token::Value token = m_scanner->getCurrentToken(); ASTPointer expression; + Token::Value nextToken = Token::ILLEGAL; switch (token) { case Token::TRUE_LITERAL: @@ -691,9 +692,10 @@ ASTPointer Parser::parsePrimaryExpression() expression = nodeFactory.createNode(token, getLiteralAndAdvance()); break; case Token::NUMBER: + nextToken = m_scanner->peekNextToken(); case Token::STRING_LITERAL: nodeFactory.markEndPosition(); - expression = nodeFactory.createNode(token, getLiteralAndAdvance()); + expression = nodeFactory.createNode(token, getLiteralAndAdvance(), nextToken); break; case Token::IDENTIFIER: nodeFactory.markEndPosition(); diff --git a/libsolidity/Token.h b/libsolidity/Token.h index 76e504499..7b9608254 100644 --- a/libsolidity/Token.h +++ b/libsolidity/Token.h @@ -174,6 +174,11 @@ namespace solidity K(WHILE, "while", 0) \ \ \ + /* Ether subdenominations */ \ + K(ETH_SUB_WEI, "wei", 0) \ + K(ETH_SUB_SZABO, "szabo", 0) \ + K(ETH_SUB_FINNEY, "finney", 0) \ + K(ETH_SUB_ETHER, "ether", 0) \ /* type keywords, keep them in this order, keep int as first keyword * the implementation in Types.cpp has to be synced to this here * TODO more to be added */ \ diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index 54e701c10..98c648025 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -326,15 +326,36 @@ string IntegerConstantType::toString() const return "int_const " + m_value.str(); } -u256 IntegerConstantType::literalValue(Literal const*) const +u256 IntegerConstantType::literalValue(Literal const* _literal) const { + Literal::ethSubDenomination sub =_literal->getSubDenomination(); + u256 value; // we ignore the literal and hope that the type was correctly determined solAssert(m_value <= u256(-1), "Integer constant too large."); solAssert(m_value >= -(bigint(1) << 255), "Integer constant too small."); + + if (m_value >= 0) - return u256(m_value); + value = u256(m_value); else - return s2u(s256(m_value)); + value = s2u(s256(m_value)); + + switch(sub) { + case Literal::ethSubDenomination::WEI: + case Literal::ethSubDenomination::NONE: + break; + case Literal::ethSubDenomination::SZABO: + value *= u256(1000000000000); + break; + case Literal::ethSubDenomination::FINNEY: + value *= u256(1000000000000000); + break; + case Literal::ethSubDenomination::ETHER: + value *= u256(1000000000000000000); + break; + } + + return value; } shared_ptr IntegerConstantType::getIntegerType() const From 13d9cbf5abe8edb79e0de51205a3db3665863b07 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 4 Feb 2015 22:02:35 +0100 Subject: [PATCH 2/9] Tests for ether subdenominations. Work in progress --- libsolidity/AST.cpp | 8 +++---- libsolidity/Parser.cpp | 2 ++ libsolidity/Token.h | 1 + test/SolidityExpressionCompiler.cpp | 33 ++++++++++++++++++++++++++++- test/SolidityParser.cpp | 19 +++++++++++++++++ test/SolidityScanner.cpp | 9 ++++++++ 6 files changed, 67 insertions(+), 5 deletions(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index f0c60e05d..307168ed1 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -599,10 +599,10 @@ Literal::Literal(Location const& _location, Token::Value _token, Token::Value _sub): PrimaryExpression(_location), m_token(_token), m_value(_value) { - solAssert(_sub == Token::ILLEGAL || _sub == Token::ETH_SUB_WEI || - _sub == Token::ETH_SUB_SZABO || _sub == Token::ETH_SUB_FINNEY || - _sub == Token::ETH_SUB_ETHER, "Illegal Token::Value given to Literal ctor"); - m_subDenomination =static_cast(_sub); + if(Token::isEtherSubdenomination(_sub)) + m_subDenomination = static_cast(_sub); + else + m_subDenomination = Literal::ethSubDenomination::NONE; } void Literal::checkTypeRequirements() diff --git a/libsolidity/Parser.cpp b/libsolidity/Parser.cpp index 739bbdd61..6449ba93d 100644 --- a/libsolidity/Parser.cpp +++ b/libsolidity/Parser.cpp @@ -694,6 +694,8 @@ ASTPointer Parser::parsePrimaryExpression() case Token::NUMBER: nextToken = m_scanner->peekNextToken(); case Token::STRING_LITERAL: + if (Token::isEtherSubdenomination(nextToken)) + m_scanner->next(); nodeFactory.markEndPosition(); expression = nodeFactory.createNode(token, getLiteralAndAdvance(), nextToken); break; diff --git a/libsolidity/Token.h b/libsolidity/Token.h index 7b9608254..f2beefd9a 100644 --- a/libsolidity/Token.h +++ b/libsolidity/Token.h @@ -383,6 +383,7 @@ public: static bool isCountOp(Value op) { return op == INC || op == DEC; } static bool isShiftOp(Value op) { return (SHL <= op) && (op <= SHR); } static bool isVisibilitySpecifier(Value op) { return op == PUBLIC || op == PRIVATE || op == PROTECTED; } + static bool isEtherSubdenomination(Value op) { return op == ETH_SUB_WEI || op == ETH_SUB_SZABO || op == ETH_SUB_FINNEY || op == Token::ETH_SUB_ETHER; } // Returns a string corresponding to the JS token string // (.e., "<" for the token LT) or NULL if the token doesn't diff --git a/test/SolidityExpressionCompiler.cpp b/test/SolidityExpressionCompiler.cpp index a0cca3a3a..71f40bd25 100644 --- a/test/SolidityExpressionCompiler.cpp +++ b/test/SolidityExpressionCompiler.cpp @@ -91,7 +91,16 @@ bytes compileFirstExpression(const string& _sourceCode, vector> _ { Parser parser; ASTPointer sourceUnit; - BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared(CharStream(_sourceCode)))); + try + { + sourceUnit = parser.parse(make_shared(CharStream(_sourceCode))); + } + catch(boost::exception const& _e) + { + auto msg = std::string("Parsing source code failed with: \n") + boost::diagnostic_information(_e); + BOOST_FAIL(msg); + } + // BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared(CharStream(_sourceCode)))); vector declarations; declarations.reserve(_globalDeclarations.size() + 1); @@ -177,6 +186,28 @@ BOOST_AUTO_TEST_CASE(int_literal) BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } +BOOST_AUTO_TEST_CASE(int_literals_with_ether_subdenominations) +{ + char const* sourceCode = R"( + contract c { + function c () + { + a = 1 wei; + // b = 2 szabo; + // c = 3 finney; +// b = 4 ether; + } + uint256 a; + uint256 b; + uint256 c; + uint256 d; + })"; + bytes code = compileFirstExpression(sourceCode); + + bytes expectation({byte(eth::Instruction::PUSH5), 0x38, 0xd4, 0xa5, 0x10, 0x00}); + BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); +} + BOOST_AUTO_TEST_CASE(comparison) { char const* sourceCode = "contract test {\n" diff --git a/test/SolidityParser.cpp b/test/SolidityParser.cpp index 9ba38a4a1..b6837866c 100644 --- a/test/SolidityParser.cpp +++ b/test/SolidityParser.cpp @@ -660,6 +660,25 @@ BOOST_AUTO_TEST_CASE(multiple_visibility_specifiers) BOOST_CHECK_THROW(parseText(text), ParserError); } +BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations) +{ + char const* text = R"( + contract c { + function c () + { + a = 1 wei; + b = 2 szabo; + c = 3 finney; + b = 4 ether; + } + uint256 a; + uint256 b; + uint256 c; + uint256 d; + })"; + BOOST_CHECK_NO_THROW(parseTextExplainError(text)); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/test/SolidityScanner.cpp b/test/SolidityScanner.cpp index 7dc9ef482..5bd897ab4 100644 --- a/test/SolidityScanner.cpp +++ b/test/SolidityScanner.cpp @@ -255,6 +255,15 @@ BOOST_AUTO_TEST_CASE(comments_mixed_in_sequence) BOOST_CHECK_EQUAL(scanner.getCurrentCommentLiteral(), "documentation comment "); } +BOOST_AUTO_TEST_CASE(ether_subdenominations) +{ + Scanner scanner(CharStream("wei szabo finney ether")); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::ETH_SUB_WEI); + BOOST_CHECK_EQUAL(scanner.next(), Token::ETH_SUB_SZABO); + BOOST_CHECK_EQUAL(scanner.next(), Token::ETH_SUB_FINNEY); + BOOST_CHECK_EQUAL(scanner.next(), Token::ETH_SUB_ETHER); +} + BOOST_AUTO_TEST_SUITE_END() } From c11c26c09453af1e4bf0692f3beaf9ec332abbfe Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Thu, 5 Feb 2015 13:48:02 +0100 Subject: [PATCH 3/9] Tests and fixes for ether subdenominations --- libsolidity/Parser.cpp | 4 +- libsolidity/Types.cpp | 31 +++++++------- test/SolidityExpressionCompiler.cpp | 63 +++++++++++++++++++++++------ 3 files changed, 68 insertions(+), 30 deletions(-) diff --git a/libsolidity/Parser.cpp b/libsolidity/Parser.cpp index 6449ba93d..741b9aba7 100644 --- a/libsolidity/Parser.cpp +++ b/libsolidity/Parser.cpp @@ -694,10 +694,10 @@ ASTPointer Parser::parsePrimaryExpression() case Token::NUMBER: nextToken = m_scanner->peekNextToken(); case Token::STRING_LITERAL: - if (Token::isEtherSubdenomination(nextToken)) - m_scanner->next(); nodeFactory.markEndPosition(); expression = nodeFactory.createNode(token, getLiteralAndAdvance(), nextToken); + if (Token::isEtherSubdenomination(nextToken)) + m_scanner->next(); break; case Token::IDENTIFIER: nodeFactory.markEndPosition(); diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index 98c648025..c554f3551 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -328,31 +328,32 @@ string IntegerConstantType::toString() const u256 IntegerConstantType::literalValue(Literal const* _literal) const { - Literal::ethSubDenomination sub =_literal->getSubDenomination(); u256 value; // we ignore the literal and hope that the type was correctly determined solAssert(m_value <= u256(-1), "Integer constant too large."); solAssert(m_value >= -(bigint(1) << 255), "Integer constant too small."); - if (m_value >= 0) value = u256(m_value); else value = s2u(s256(m_value)); - switch(sub) { - case Literal::ethSubDenomination::WEI: - case Literal::ethSubDenomination::NONE: - break; - case Literal::ethSubDenomination::SZABO: - value *= u256(1000000000000); - break; - case Literal::ethSubDenomination::FINNEY: - value *= u256(1000000000000000); - break; - case Literal::ethSubDenomination::ETHER: - value *= u256(1000000000000000000); - break; + if (_literal) { + Literal::ethSubDenomination sub =_literal->getSubDenomination(); + switch(sub) { + case Literal::ethSubDenomination::WEI: + case Literal::ethSubDenomination::NONE: + break; + case Literal::ethSubDenomination::SZABO: + value *= u256(1000000000000); + break; + case Literal::ethSubDenomination::FINNEY: + value *= u256(1000000000000000); + break; + case Literal::ethSubDenomination::ETHER: + value *= u256(1000000000000000000); + break; + } } return value; diff --git a/test/SolidityExpressionCompiler.cpp b/test/SolidityExpressionCompiler.cpp index 71f40bd25..3c3ea1baa 100644 --- a/test/SolidityExpressionCompiler.cpp +++ b/test/SolidityExpressionCompiler.cpp @@ -100,7 +100,6 @@ bytes compileFirstExpression(const string& _sourceCode, vector> _ auto msg = std::string("Parsing source code failed with: \n") + boost::diagnostic_information(_e); BOOST_FAIL(msg); } - // BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared(CharStream(_sourceCode)))); vector declarations; declarations.reserve(_globalDeclarations.size() + 1); @@ -186,25 +185,63 @@ BOOST_AUTO_TEST_CASE(int_literal) BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } -BOOST_AUTO_TEST_CASE(int_literals_with_ether_subdenominations) +BOOST_AUTO_TEST_CASE(int_with_wei_ether_subdenomination) { char const* sourceCode = R"( - contract c { - function c () + contract test { + function test () { - a = 1 wei; - // b = 2 szabo; - // c = 3 finney; -// b = 4 ether; + var x = 1 wei; } - uint256 a; - uint256 b; - uint256 c; - uint256 d; })"; bytes code = compileFirstExpression(sourceCode); - bytes expectation({byte(eth::Instruction::PUSH5), 0x38, 0xd4, 0xa5, 0x10, 0x00}); + bytes expectation({byte(eth::Instruction::PUSH1), 0x1}); + BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); +} + +BOOST_AUTO_TEST_CASE(int_with_szabo_ether_subdenomination) +{ + char const* sourceCode = R"( + contract test { + function test () + { + var x = 1 szabo; + } + })"; + bytes code = compileFirstExpression(sourceCode); + + bytes expectation({byte(eth::Instruction::PUSH5), 0xe8, 0xd4, 0xa5, 0x10, 0x00}); + BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); +} + +BOOST_AUTO_TEST_CASE(int_with_finney_ether_subdenomination) +{ + char const* sourceCode = R"( + contract test { + function test () + { + var x = 1 finney; + } + })"; + bytes code = compileFirstExpression(sourceCode); + + bytes expectation({byte(eth::Instruction::PUSH7), 0x3, 0x8d, 0x7e, 0xa4, 0xc6, 0x80, 0x00}); + BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); +} + +BOOST_AUTO_TEST_CASE(int_with_ether_ether_subdenomination) +{ + char const* sourceCode = R"( + contract test { + function test () + { + var x = 1 ether; + } + })"; + bytes code = compileFirstExpression(sourceCode); + + bytes expectation({byte(eth::Instruction::PUSH8), 0xd, 0xe0, 0xb6, 0xb3, 0xa7, 0x64, 0x00, 0x00}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } From c0151476adf493c2a9fbd747cf00eda07941e121 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Thu, 5 Feb 2015 22:38:07 +0100 Subject: [PATCH 4/9] Minor Style fixes --- libsolidity/AST.cpp | 6 +++--- libsolidity/AST.h | 16 +++++++++------- libsolidity/Token.h | 12 ++++++------ libsolidity/Types.cpp | 18 ++++++++++-------- test/SolidityScanner.cpp | 8 ++++---- 5 files changed, 32 insertions(+), 28 deletions(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index 307168ed1..455dc44aa 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -599,10 +599,10 @@ Literal::Literal(Location const& _location, Token::Value _token, Token::Value _sub): PrimaryExpression(_location), m_token(_token), m_value(_value) { - if(Token::isEtherSubdenomination(_sub)) - m_subDenomination = static_cast(_sub); + if (Token::isEtherSubdenomination(_sub)) + m_subDenomination = static_cast(_sub); else - m_subDenomination = Literal::ethSubDenomination::NONE; + m_subDenomination = Literal::SubDenomination::NONE; } void Literal::checkTypeRequirements() diff --git a/libsolidity/AST.h b/libsolidity/AST.h index ecf91c059..193e7310a 100755 --- a/libsolidity/AST.h +++ b/libsolidity/AST.h @@ -1117,12 +1117,14 @@ private: class Literal: public PrimaryExpression { public: - enum class ethSubDenomination { + enum class SubDenomination + { NONE = Token::ILLEGAL, - WEI = Token::ETH_SUB_WEI, - SZABO = Token::ETH_SUB_SZABO, - FINNEY = Token::ETH_SUB_FINNEY, - ETHER = Token::ETH_SUB_ETHER}; + WEI = Token::SubWei, + SZABO = Token::SubSzabo, + FINNEY = Token::SubFinney, + ETHER = Token::SubEther + }; Literal(Location const& _location, Token::Value _token, ASTPointer const& _value, Token::Value _sub = Token::ILLEGAL); @@ -1134,12 +1136,12 @@ public: /// @returns the non-parsed value of the literal ASTString const& getValue() const { return *m_value; } - ethSubDenomination getSubDenomination() const { return m_subDenomination; } + SubDenomination getSubDenomination() const { return m_subDenomination; } private: Token::Value m_token; ASTPointer m_value; - ethSubDenomination m_subDenomination; + SubDenomination m_subDenomination; }; /// @} diff --git a/libsolidity/Token.h b/libsolidity/Token.h index f2beefd9a..b07fc46c6 100644 --- a/libsolidity/Token.h +++ b/libsolidity/Token.h @@ -174,11 +174,11 @@ namespace solidity K(WHILE, "while", 0) \ \ \ - /* Ether subdenominations */ \ - K(ETH_SUB_WEI, "wei", 0) \ - K(ETH_SUB_SZABO, "szabo", 0) \ - K(ETH_SUB_FINNEY, "finney", 0) \ - K(ETH_SUB_ETHER, "ether", 0) \ + /* Ether subdenominations */ \ + K(SubWei, "wei", 0) \ + K(SubSzabo, "szabo", 0) \ + K(SubFinney, "finney", 0) \ + K(SubEther, "ether", 0) \ /* type keywords, keep them in this order, keep int as first keyword * the implementation in Types.cpp has to be synced to this here * TODO more to be added */ \ @@ -383,7 +383,7 @@ public: static bool isCountOp(Value op) { return op == INC || op == DEC; } static bool isShiftOp(Value op) { return (SHL <= op) && (op <= SHR); } static bool isVisibilitySpecifier(Value op) { return op == PUBLIC || op == PRIVATE || op == PROTECTED; } - static bool isEtherSubdenomination(Value op) { return op == ETH_SUB_WEI || op == ETH_SUB_SZABO || op == ETH_SUB_FINNEY || op == Token::ETH_SUB_ETHER; } + static bool isEtherSubdenomination(Value op) { return op == SubWei || op == SubSzabo || op == SubFinney || op == Token::SubEther; } // Returns a string corresponding to the JS token string // (.e., "<" for the token LT) or NULL if the token doesn't diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index c554f3551..a8b3add48 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -338,19 +338,21 @@ u256 IntegerConstantType::literalValue(Literal const* _literal) const else value = s2u(s256(m_value)); - if (_literal) { - Literal::ethSubDenomination sub =_literal->getSubDenomination(); - switch(sub) { - case Literal::ethSubDenomination::WEI: - case Literal::ethSubDenomination::NONE: + if (_literal) + { + Literal::SubDenomination sub =_literal->getSubDenomination(); + switch(sub) + { + case Literal::SubDenomination::WEI: + case Literal::SubDenomination::NONE: break; - case Literal::ethSubDenomination::SZABO: + case Literal::SubDenomination::SZABO: value *= u256(1000000000000); break; - case Literal::ethSubDenomination::FINNEY: + case Literal::SubDenomination::FINNEY: value *= u256(1000000000000000); break; - case Literal::ethSubDenomination::ETHER: + case Literal::SubDenomination::ETHER: value *= u256(1000000000000000000); break; } diff --git a/test/SolidityScanner.cpp b/test/SolidityScanner.cpp index 5bd897ab4..8088b4d4b 100644 --- a/test/SolidityScanner.cpp +++ b/test/SolidityScanner.cpp @@ -258,10 +258,10 @@ BOOST_AUTO_TEST_CASE(comments_mixed_in_sequence) BOOST_AUTO_TEST_CASE(ether_subdenominations) { Scanner scanner(CharStream("wei szabo finney ether")); - BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::ETH_SUB_WEI); - BOOST_CHECK_EQUAL(scanner.next(), Token::ETH_SUB_SZABO); - BOOST_CHECK_EQUAL(scanner.next(), Token::ETH_SUB_FINNEY); - BOOST_CHECK_EQUAL(scanner.next(), Token::ETH_SUB_ETHER); + BOOST_CHECK_EQUAL(scanner.getCurrentToken(), Token::SubWei); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubSzabo); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubFinney); + BOOST_CHECK_EQUAL(scanner.next(), Token::SubEther); } BOOST_AUTO_TEST_SUITE_END() From e296d86cc6df7bc637b0175a43cdae9ad60e89c5 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Thu, 5 Feb 2015 23:03:24 +0100 Subject: [PATCH 5/9] More style changes in enums --- libsolidity/AST.cpp | 2 +- libsolidity/AST.h | 10 +++++----- libsolidity/Types.cpp | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libsolidity/AST.cpp b/libsolidity/AST.cpp index 455dc44aa..50a67a8db 100644 --- a/libsolidity/AST.cpp +++ b/libsolidity/AST.cpp @@ -602,7 +602,7 @@ Literal::Literal(Location const& _location, Token::Value _token, if (Token::isEtherSubdenomination(_sub)) m_subDenomination = static_cast(_sub); else - m_subDenomination = Literal::SubDenomination::NONE; + m_subDenomination = Literal::SubDenomination::None; } void Literal::checkTypeRequirements() diff --git a/libsolidity/AST.h b/libsolidity/AST.h index 193e7310a..bced99f9a 100755 --- a/libsolidity/AST.h +++ b/libsolidity/AST.h @@ -1119,11 +1119,11 @@ class Literal: public PrimaryExpression public: enum class SubDenomination { - NONE = Token::ILLEGAL, - WEI = Token::SubWei, - SZABO = Token::SubSzabo, - FINNEY = Token::SubFinney, - ETHER = Token::SubEther + None = Token::ILLEGAL, + Wei = Token::SubWei, + Szabo = Token::SubSzabo, + Finney = Token::SubFinney, + Ether = Token::SubEther }; Literal(Location const& _location, Token::Value _token, ASTPointer const& _value, diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index a8b3add48..648cf9cb2 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -343,16 +343,16 @@ u256 IntegerConstantType::literalValue(Literal const* _literal) const Literal::SubDenomination sub =_literal->getSubDenomination(); switch(sub) { - case Literal::SubDenomination::WEI: - case Literal::SubDenomination::NONE: + case Literal::SubDenomination::Wei: + case Literal::SubDenomination::None: break; - case Literal::SubDenomination::SZABO: + case Literal::SubDenomination::Szabo: value *= u256(1000000000000); break; - case Literal::SubDenomination::FINNEY: + case Literal::SubDenomination::Finney: value *= u256(1000000000000000); break; - case Literal::SubDenomination::ETHER: + case Literal::SubDenomination::Ether: value *= u256(1000000000000000000); break; } From c0358e1f5fd32a62b9f28b277fb6de98f023f838 Mon Sep 17 00:00:00 2001 From: Lu Guanqun Date: Fri, 6 Feb 2015 00:29:03 +0800 Subject: [PATCH 6/9] fix Mac build error for evmjit We need to include , otherwise it complains: cpp-ethereum/evmjit/libevmjit/ExecutionEngine.cpp:147:2: error: implicit instantiation of undefined template 'std::__1::basic_ostream >' clog(JIT) << " + " << std::chrono::duration_cast(executionEndTime - executionStartTime).cou... ^ cpp-ethereum/evmjit/libevmjit/Utils.h:15:23: note: expanded from macro 'clog' #define clog(CHANNEL) std::ostream(nullptr) ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:111:33: note: template is declared here class _LIBCPP_TYPE_VIS_ONLY basic_ostream; ^ --- evmjit/libevmjit/Utils.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/evmjit/libevmjit/Utils.h b/evmjit/libevmjit/Utils.h index 1e6705667..7e6133ced 100644 --- a/evmjit/libevmjit/Utils.h +++ b/evmjit/libevmjit/Utils.h @@ -1,5 +1,7 @@ #pragma once +#include + #include "Common.h" namespace dev From 23fabcd8a6c5fd5aee05e804fd42d01ddf4145cb Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 5 Feb 2015 16:25:25 +0100 Subject: [PATCH 7/9] got rid of flickable in debugger pane --- mix/qml/Debugger.qml | 94 ++++++++++++++++++++++++------------------ mix/qml/js/Debugger.js | 5 ++- 2 files changed, 57 insertions(+), 42 deletions(-) diff --git a/mix/qml/Debugger.qml b/mix/qml/Debugger.qml index 502f3242e..acce5355c 100644 --- a/mix/qml/Debugger.qml +++ b/mix/qml/Debugger.qml @@ -104,18 +104,17 @@ Rectangle { } } - Flickable { + ScrollView { property int firstColumnWidth: 180 property int secondColumnWidth: 250 id: debugScrollArea - flickableDirection: Flickable.VerticalFlick + //flickableDirection: Flickable.VerticalFlick anchors.fill: parent - contentHeight: 4000 - contentWidth: parent.width - Rectangle - { - color: "transparent" - anchors.fill: parent + //contentHeight: 4000 + //width: parent.width + //contentWidth: parent.width + //color: "transparent" + ColumnLayout { property int sideMargin: 10 @@ -124,13 +123,17 @@ Rectangle { anchors.topMargin: 15 anchors.left: parent.left; anchors.leftMargin: machineStates.sideMargin - anchors.right: parent.right; - anchors.rightMargin: machineStates.sideMargin - anchors.fill: parent - Layout.fillWidth: true - Layout.fillHeight: true + width: debugScrollArea.width - machineStates.sideMargin * 2 - 20; + + function updateHeight() { + machineStates.height = transactionLog.childrenRect.height + buttonRow.childrenRect.height + assemblyCodeRow.childrenRect.height + + callStackRect.childrenRect.height + storageRect.childrenRect.height + memoryRect.childrenRect.height + callDataRect.childrenRect.height + 120; + } + + Component.onCompleted: updateHeight(); TransactionLog { + id: transactionLog Layout.fillWidth: true height: 250 } @@ -272,61 +275,74 @@ Rectangle { border.color: "#deddd9" color: "white" anchors.top: parent.top - ListView { + TableView { + id: statesList anchors.fill: parent anchors.leftMargin: 3 anchors.rightMargin: 3 anchors.topMargin: 3 anchors.bottomMargin: 3 clip: true - id: statesList - delegate: renderDelegate - highlight: highlightBar - //highlightFollowsCurrentItem: false + headerDelegate: null + itemDelegate: renderDelegate model: ListModel {} + TableViewColumn { + role: "line" + width: debugScrollArea.firstColumnWidth - 10 + } + } Component { id: highlightBar Rectangle { radius: 4 - height: statesList.currentItem.height - width: statesList.currentItem.width; + anchors.fill: parent y: statesList.currentItem.y color: "#4A90E2" - //Behavior on y { - // PropertyAnimation { properties: "y"; easing.type: Easing.InOutQuad; duration: 50} - //} } } Component { id: renderDelegate + Item { + + Rectangle { + radius: 4 + anchors.fill: parent + color: "#4A90E2" + visible: styleData.selected; + } + RowLayout { id: wrapperItem height: 20 - width: parent.width + //width: parent.width + anchors.fill: parent spacing: 5 + + Text { anchors.left: parent.left anchors.leftMargin: 10 width: 15 color: "#b2b3ae" - text: line.split(' ')[0] + text: styleData.value.split(' ')[0] font.family: "monospace" font.pointSize: 9 - id: id wrapMode: Text.NoWrap + id: id } Text { + anchors.left: id.right; wrapMode: Text.NoWrap - color: parent.ListView.isCurrentItem ? "white" : "black" + color: styleData.selected ? "white" : "black" font.family: "monospace" - text: line.replace(line.split(' ')[0], '') - anchors.left: id.right + text: styleData.value.replace(styleData.value.split(' ')[0], '') font.pointSize: 9 } } + } } } @@ -443,8 +459,6 @@ Rectangle { } orientation: Qt.Vertical - width: debugPanel.width - 2 * machineStates.sideMargin - Rectangle { @@ -454,6 +468,7 @@ Rectangle { width: parent.width Layout.minimumHeight: 120 Layout.maximumHeight: 400 + onHeightChanged: machineStates.updateHeight(); CallStack { anchors.fill: parent id: callStack @@ -461,15 +476,14 @@ Rectangle { } } - Rectangle { id: storageRect color: "transparent" width: parent.width Layout.minimumHeight: 25 - Layout.maximumHeight: 223 - height: 25 + Layout.maximumHeight: 800 + onHeightChanged: machineStates.updateHeight(); DebugInfoList { id: storage @@ -545,10 +559,10 @@ Rectangle { { id: memoryRect; color: "transparent" - height: 25 width: parent.width Layout.minimumHeight: 25 - Layout.maximumHeight: 223 + Layout.maximumHeight: 800 + onHeightChanged: machineStates.updateHeight(); DebugInfoList { id: memoryDump anchors.fill: parent @@ -567,10 +581,10 @@ Rectangle { { id: callDataRect color: "transparent" - height: 25 width: parent.width Layout.minimumHeight: 25 - Layout.maximumHeight: 223 + Layout.maximumHeight: 800 + onHeightChanged: machineStates.updateHeight(); DebugInfoList { id: callDataDump anchors.fill: parent @@ -586,12 +600,12 @@ Rectangle { } Rectangle { + id: bottomRect; width: parent.width - Layout.minimumHeight: 25 + Layout.minimumHeight: 20 color: "transparent" } } } - } } } diff --git a/mix/qml/js/Debugger.js b/mix/qml/js/Debugger.js index de1f87256..96e7a54a2 100644 --- a/mix/qml/js/Debugger.js +++ b/mix/qml/js/Debugger.js @@ -118,8 +118,9 @@ function codeStr(stateIndex) function highlightSelection(index) { - statesList.currentIndex = index; - statesList.positionViewAtIndex(index, ListView.Center); + statesList.positionViewAtRow(index, ListView.Center); + statesList.selection.clear(); + statesList.selection.select(index); } function completeCtxInformation(state) From 1bf479aa67c2180833e1e501fdb130509d8ae5f9 Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 5 Feb 2015 22:25:53 +0100 Subject: [PATCH 8/9] ui tweaks --- mix/qml/Debugger.qml | 104 ++++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 46 deletions(-) diff --git a/mix/qml/Debugger.qml b/mix/qml/Debugger.qml index acce5355c..facf759a8 100644 --- a/mix/qml/Debugger.qml +++ b/mix/qml/Debugger.qml @@ -55,6 +55,15 @@ Rectangle { onCompilationComplete: update(null, false); } + Settings { + id: splitSettings + property alias transactionLogHeight: transactionLog.height + property alias callStackHeight: callStack.height + property alias storageHeightSettings: storageRect.height + property alias memoryDumpHeightSettings: memoryRect.height + property alias callDataHeightSettings: callDataRect.height + } + Rectangle { visible: false; @@ -105,38 +114,45 @@ Rectangle { } ScrollView { - property int firstColumnWidth: 180 - property int secondColumnWidth: 250 id: debugScrollArea - //flickableDirection: Flickable.VerticalFlick anchors.fill: parent - //contentHeight: 4000 - //width: parent.width - //contentWidth: parent.width - //color: "transparent" - ColumnLayout - { - property int sideMargin: 10 - id: machineStates - anchors.top: parent.top - anchors.topMargin: 15 - anchors.left: parent.left; - anchors.leftMargin: machineStates.sideMargin - width: debugScrollArea.width - machineStates.sideMargin * 2 - 20; - - function updateHeight() { - machineStates.height = transactionLog.childrenRect.height + buttonRow.childrenRect.height + assemblyCodeRow.childrenRect.height + - callStackRect.childrenRect.height + storageRect.childrenRect.height + memoryRect.childrenRect.height + callDataRect.childrenRect.height + 120; - } + SplitView + { + property int sideMargin: 10 + id: machineStates + anchors.top: parent.top + anchors.topMargin: 15 + anchors.left: parent.left; + anchors.leftMargin: machineStates.sideMargin + width: debugScrollArea.width - machineStates.sideMargin * 2 - 20; + orientation: Qt.Vertical + handleDelegate: Rectangle { + height: machineStates.sideMargin + color: "transparent" + } - Component.onCompleted: updateHeight(); + function updateHeight() { + machineStates.height = transactionLog.childrenRect.height + buttonRow.childrenRect.height + assemblyCodeRow.childrenRect.height + + callStackRect.childrenRect.height + storageRect.childrenRect.height + memoryRect.childrenRect.height + callDataRect.childrenRect.height + 120; + } - TransactionLog { - id: transactionLog - Layout.fillWidth: true - height: 250 - } + Component.onCompleted: updateHeight(); + + + TransactionLog { + id: transactionLog + Layout.fillWidth: true + Layout.minimumHeight: 60 + height: 250 + } + + ColumnLayout { + + Layout.fillWidth: true + Layout.fillHeight: true + id: statesLayout + spacing: machineStates.sideMargin RowLayout { // step button + slider @@ -145,11 +161,11 @@ Rectangle { height: 27 Layout.fillWidth: true - Rectangle - { + Rectangle { height: parent.height color: "transparent" - width: debugScrollArea.firstColumnWidth + Layout.minimumWidth: stateListContainer.width + Layout.maximumWidth: stateListContainer.width RowLayout { anchors.horizontalCenter: parent.horizontalCenter id: jumpButtons @@ -258,23 +274,25 @@ Rectangle { } } - RowLayout { + Rectangle { // Assembly code id: assemblyCodeRow Layout.fillWidth: true height: 405 implicitHeight: 405 - spacing: machineStates.sideMargin + color: "transparent" Rectangle { id: stateListContainer - width: debugScrollArea.firstColumnWidth + anchors.top : parent.top + anchors.bottom: parent.bottom + anchors.left: parent.left + width: parent.width * 0.4 height: parent.height border.width: 3 border.color: "#deddd9" color: "white" - anchors.top: parent.top TableView { id: statesList anchors.fill: parent @@ -288,7 +306,7 @@ Rectangle { model: ListModel {} TableViewColumn { role: "line" - width: debugScrollArea.firstColumnWidth - 10 + width: parent.width - 10 } } @@ -347,7 +365,10 @@ Rectangle { } Rectangle { - Layout.fillWidth: true + width: parent.width * 0.6 - machineStates.sideMargin + anchors.top : parent.top + anchors.bottom: parent.bottom + anchors.right: parent.right height: parent.height //- 2 * stateListContainer.border.width color: "transparent" ColumnLayout @@ -450,14 +471,6 @@ Rectangle { id: splitInfoList Layout.fillHeight: true Layout.fillWidth: true - - Settings { - id: splitSettings - property alias storageHeightSettings: storageRect.height - property alias memoryDumpHeightSettings: memoryRect.height - property alias callDataHeightSettings: callDataRect.height - } - orientation: Qt.Vertical Rectangle @@ -507,7 +520,6 @@ Rectangle { Layout.preferredWidth: parent.width / 2 Layout.maximumWidth: parent.width / 2 Layout.minimumHeight: parent.height - Layout.maximumHeight: parent.height Text { anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left @@ -528,7 +540,6 @@ Rectangle { Layout.preferredWidth: parent.width / 2 Layout.maximumWidth: parent.width / 2 Layout.minimumHeight: parent.height - Layout.maximumHeight: parent.height Text { anchors.leftMargin: 5 width: parent.width - 5 @@ -607,5 +618,6 @@ Rectangle { } } } + } } } From 3f4370162ff64d277c60e85ecc56b20eb4603f3c Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 6 Feb 2015 00:31:10 +0100 Subject: [PATCH 9/9] ui improvements, bugfixes --- mix/ClientModel.cpp | 13 ++- mix/ClientModel.h | 9 ++ mix/MixClient.cpp | 3 +- mix/qml/DebugInfoList.qml | 26 +++++- mix/qml/Debugger.qml | 184 ++++++++++++++++++++++++------------- mix/qml/WebPreview.qml | 3 +- mix/qml/js/Debugger.js | 2 +- mix/qml/js/ProjectModel.js | 1 + mix/qml/main.qml | 2 +- 9 files changed, 166 insertions(+), 77 deletions(-) diff --git a/mix/ClientModel.cpp b/mix/ClientModel.cpp index 3a2b50999..e18b23ab3 100644 --- a/mix/ClientModel.cpp +++ b/mix/ClientModel.cpp @@ -113,24 +113,27 @@ QString ClientModel::apiCall(QString const& _message) void ClientModel::mine() { - if (m_running) + if (m_running || m_mining) BOOST_THROW_EXCEPTION(ExecutionStateException()); - m_running = true; - emit runStarted(); - emit runStateChanged(); + m_mining = true; + emit miningStarted(); + emit miningStateChanged(); QtConcurrent::run([=]() { try { m_client->mine(); newBlock(); + m_mining = false; + emit miningComplete(); } catch (...) { + m_mining = false; std::cerr << boost::current_exception_diagnostic_information(); emit runFailed(QString::fromStdString(boost::current_exception_diagnostic_information())); } - m_running = false; + emit miningStateChanged(); }); } diff --git a/mix/ClientModel.h b/mix/ClientModel.h index 493290780..be264e108 100644 --- a/mix/ClientModel.h +++ b/mix/ClientModel.h @@ -114,6 +114,8 @@ public: ~ClientModel(); /// @returns true if currently executing contract code Q_PROPERTY(bool running MEMBER m_running NOTIFY runStateChanged) + /// @returns true if currently mining + Q_PROPERTY(bool mining MEMBER m_mining NOTIFY miningStateChanged) /// @returns address of the last executed contract Q_PROPERTY(QString contractAddress READ contractAddress NOTIFY contractAddressChanged) /// ethereum.js RPC request entry point @@ -144,6 +146,12 @@ signals: void runStarted(); /// Transaction execution completed successfully void runComplete(); + /// Mining has started + void miningStarted(); + /// Mined a new block + void miningComplete(); + /// Mining stopped or started + void miningStateChanged(); /// Transaction execution completed with error /// @param _message Error message void runFailed(QString const& _message); @@ -174,6 +182,7 @@ private: AppContext* m_context; std::atomic m_running; + std::atomic m_mining; std::unique_ptr m_client; std::unique_ptr m_rpcConnector; std::unique_ptr m_web3Server; diff --git a/mix/MixClient.cpp b/mix/MixClient.cpp index 17e369a4e..512847a78 100644 --- a/mix/MixClient.cpp +++ b/mix/MixClient.cpp @@ -91,6 +91,7 @@ void MixClient::resetState(u256 _balance) m_state.sync(bc()); m_startState = m_state; m_pendingExecutions.clear(); + m_executions.clear(); } void MixClient::executeTransaction(Transaction const& _t, State& _state) @@ -215,7 +216,7 @@ ExecutionResult const& MixClient::execution(unsigned _block, unsigned _transacti { if (_block == bc().number() + 1) return m_pendingExecutions.at(_transaction); - return m_executions.at(_block).at(_transaction); + return m_executions.at(_block - 1).at(_transaction); } ExecutionResult const& MixClient::lastExecution() const diff --git a/mix/qml/DebugInfoList.qml b/mix/qml/DebugInfoList.qml index cad2a4c9e..1e16038e7 100644 --- a/mix/qml/DebugInfoList.qml +++ b/mix/qml/DebugInfoList.qml @@ -4,14 +4,19 @@ import QtQuick.Layouts 1.0 import QtQuick.Controls.Styles 1.1 ColumnLayout { + id: root property string title property variant listModel; property bool collapsible; + property bool enableSelection; + property real storedHeight; property Component itemDelegate + signal rowActivated(int index) spacing: 0 function collapse() { + storedHeight = childrenRect.height; storageContainer.state = "collapsed"; } @@ -32,7 +37,9 @@ ColumnLayout { Image { source: "qrc:/qml/img/opentriangleindicator.png" width: 15 + height: 15 sourceSize.width: 15 + sourceSize.height: 15 id: storageImgArrow } @@ -53,16 +60,20 @@ ColumnLayout { if (storageContainer.state == "collapsed") { storageContainer.state = ""; - storageContainer.parent.parent.height = storageContainer.parent.parent.Layout.maximumHeight; + storageContainer.parent.parent.height = storedHeight; } else + { + storedHeight = root.childrenRect.height; storageContainer.state = "collapsed"; + } } } } } Rectangle { + id: storageContainer border.width: 3 border.color: "#deddd9" Layout.fillWidth: true @@ -80,18 +91,23 @@ ColumnLayout { } } ] - id: storageContainer - ListView { + TableView { clip: true; + alternatingRowColors: false anchors.top: parent.top anchors.left: parent.left anchors.topMargin: 3 anchors.leftMargin: 3 width: parent.width - 3 height: parent.height - 6 - id: storageList model: listModel - delegate: itemDelegate + selectionMode: enableSelection ? SelectionMode.SingleSelection : SelectionMode.NoSelection + headerDelegate: null + itemDelegate: root.itemDelegate + TableViewColumn { + role: "modelData" + width: parent.width + } } } } diff --git a/mix/qml/Debugger.qml b/mix/qml/Debugger.qml index facf759a8..d7023f4b2 100644 --- a/mix/qml/Debugger.qml +++ b/mix/qml/Debugger.qml @@ -58,7 +58,7 @@ Rectangle { Settings { id: splitSettings property alias transactionLogHeight: transactionLog.height - property alias callStackHeight: callStack.height + property alias callStackHeight: callStackRect.height property alias storageHeightSettings: storageRect.height property alias memoryDumpHeightSettings: memoryRect.height property alias callDataHeightSettings: callDataRect.height @@ -154,18 +154,19 @@ Rectangle { id: statesLayout spacing: machineStates.sideMargin - RowLayout { + Rectangle { // step button + slider id: buttonRow - spacing: machineStates.sideMargin height: 27 Layout.fillWidth: true + color: "transparent" Rectangle { - height: parent.height + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.left: parent.left color: "transparent" - Layout.minimumWidth: stateListContainer.width - Layout.maximumWidth: stateListContainer.width + width: stateListContainer.width RowLayout { anchors.horizontalCenter: parent.horizontalCenter id: jumpButtons @@ -245,9 +246,11 @@ Rectangle { } Rectangle { + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: parent.right + width: debugInfoContainer.width color: "transparent" - Layout.fillWidth: true - height: parent.height Slider { id: statesSlider anchors.fill: parent @@ -324,47 +327,45 @@ Rectangle { Component { id: renderDelegate Item { - - Rectangle { - radius: 4 - anchors.fill: parent - color: "#4A90E2" - visible: styleData.selected; - } - - RowLayout { - id: wrapperItem - height: 20 - //width: parent.width - anchors.fill: parent - spacing: 5 - - - Text { - anchors.left: parent.left - anchors.leftMargin: 10 - width: 15 - color: "#b2b3ae" - text: styleData.value.split(' ')[0] - font.family: "monospace" - font.pointSize: 9 - wrapMode: Text.NoWrap - id: id + Rectangle { + radius: 4 + anchors.fill: parent + color: "#4A90E2" + visible: styleData.selected; } - Text { - anchors.left: id.right; - wrapMode: Text.NoWrap - color: styleData.selected ? "white" : "black" - font.family: "monospace" - text: styleData.value.replace(styleData.value.split(' ')[0], '') - font.pointSize: 9 + + RowLayout { + id: wrapperItem + anchors.fill: parent + spacing: 5 + + + Text { + anchors.left: parent.left + anchors.leftMargin: 10 + width: 15 + color: "#b2b3ae" + text: styleData.value.split(' ')[0] + font.family: "monospace" + font.pointSize: 9 + wrapMode: Text.NoWrap + id: id + } + Text { + anchors.left: id.right; + wrapMode: Text.NoWrap + color: styleData.selected ? "white" : "black" + font.family: "monospace" + text: styleData.value.replace(styleData.value.split(' ')[0], '') + font.pointSize: 9 + } } } - } } } Rectangle { + id: debugInfoContainer width: parent.width * 0.6 - machineStates.sideMargin anchors.top : parent.top anchors.bottom: parent.bottom @@ -409,7 +410,7 @@ Rectangle { title : qsTr("Stack") itemDelegate: Item { id: renderedItem - height: 25 + //height: 25 width: parent.width RowLayout { @@ -428,7 +429,7 @@ Rectangle { anchors.leftMargin: 5 font.family: "monospace" color: "#4a4a4a" - text: model.index; + text: styleData.row; font.pointSize: 9 } } @@ -439,7 +440,6 @@ Rectangle { Layout.fillWidth: true Layout.minimumWidth: 15 Layout.preferredWidth: 15 - Layout.maximumWidth: 60 Layout.minimumHeight: parent.height Text { anchors.left: parent.left @@ -447,7 +447,7 @@ Rectangle { font.family: "monospace" anchors.verticalCenter: parent.verticalCenter color: "#4a4a4a" - text: modelData + text: styleData.value font.pointSize: 9 } } @@ -477,16 +477,80 @@ Rectangle { { id: callStackRect; color: "transparent" - height: 120 - width: parent.width - Layout.minimumHeight: 120 - Layout.maximumHeight: 400 + Layout.minimumHeight: 25 + Layout.maximumHeight: 800 onHeightChanged: machineStates.updateHeight(); - CallStack { - anchors.fill: parent + DebugInfoList + { id: callStack - onFrameActivated: Debugger.displayFrame(index); + collapsible: true + anchors.fill: parent + title : qsTr("Call Stack") + enableSelection: true + onRowActivated: Debugger.displayFrame(index); + itemDelegate: + Item { + anchors.fill: parent + + Rectangle { + anchors.fill: parent + color: "#4A90E2" + visible: styleData.selected; + } + + RowLayout + { + id: row + anchors.fill: parent + Rectangle + { + color: "#f7f7f7" + Layout.fillWidth: true + Layout.minimumWidth: 30 + Layout.maximumWidth: 30 + Text { + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + font.family: "monospace" + anchors.leftMargin: 5 + color: "#4a4a4a" + text: styleData.row; + font.pointSize: 9 + width: parent.width - 5 + elide: Text.ElideRight + } + } + Rectangle + { + color: "transparent" + Layout.fillWidth: true + Layout.minimumWidth: parent.width - 30 + Layout.maximumWidth: parent.width - 30 + Text { + anchors.leftMargin: 5 + width: parent.width - 5 + wrapMode: Text.Wrap + anchors.left: parent.left + font.family: "monospace" + anchors.verticalCenter: parent.verticalCenter + color: "#4a4a4a" + text: styleData.value; + elide: Text.ElideRight + font.pointSize: 9 + } + } + } + + Rectangle { + anchors.top: row.bottom + width: parent.width; + height: 1; + color: "#cccccc" + anchors.bottom: parent.bottom + } + } } + } Rectangle @@ -505,28 +569,24 @@ Rectangle { title : qsTr("Storage") itemDelegate: Item { - height: 27 - width: parent.width; + anchors.fill: parent RowLayout { id: row - width: parent.width - height: 26 + anchors.fill: parent Rectangle { color: "#f7f7f7" Layout.fillWidth: true Layout.minimumWidth: parent.width / 2 - Layout.preferredWidth: parent.width / 2 Layout.maximumWidth: parent.width / 2 - Layout.minimumHeight: parent.height Text { anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left font.family: "monospace" anchors.leftMargin: 5 color: "#4a4a4a" - text: modelData.split('\t')[0]; + text: styleData.value.split('\t')[0]; font.pointSize: 9 width: parent.width - 5 elide: Text.ElideRight @@ -537,9 +597,7 @@ Rectangle { color: "transparent" Layout.fillWidth: true Layout.minimumWidth: parent.width / 2 - Layout.preferredWidth: parent.width / 2 Layout.maximumWidth: parent.width / 2 - Layout.minimumHeight: parent.height Text { anchors.leftMargin: 5 width: parent.width - 5 @@ -548,7 +606,7 @@ Rectangle { font.family: "monospace" anchors.verticalCenter: parent.verticalCenter color: "#4a4a4a" - text: modelData.split('\t')[1]; + text: styleData.value.split('\t')[1]; elide: Text.ElideRight font.pointSize: 9 } diff --git a/mix/qml/WebPreview.qml b/mix/qml/WebPreview.qml index e95a85fde..f4ddca84e 100644 --- a/mix/qml/WebPreview.qml +++ b/mix/qml/WebPreview.qml @@ -114,7 +114,8 @@ Item { onClientConnected: { //filter polling spam //TODO: do it properly - var log = _request.content.indexOf("eth_changed") < 0; + //var log = _request.content.indexOf("eth_changed") < 0; + var log = true; if (log) console.log(_request.content); var response = clientModel.apiCall(_request.content); diff --git a/mix/qml/js/Debugger.js b/mix/qml/js/Debugger.js index 96e7a54a2..872d0aa36 100644 --- a/mix/qml/js/Debugger.js +++ b/mix/qml/js/Debugger.js @@ -107,7 +107,7 @@ function select(stateIndex) callStackData.push(address); } callStackData.push(debugData.states[0].address); - callStack.model = callStackData; + callStack.listModel = callStackData; } function codeStr(stateIndex) diff --git a/mix/qml/js/ProjectModel.js b/mix/qml/js/ProjectModel.js index 4d501ffca..718dd4fa4 100644 --- a/mix/qml/js/ProjectModel.js +++ b/mix/qml/js/ProjectModel.js @@ -153,6 +153,7 @@ function doCloseProject() { console.log("closing project"); projectListModel.clear(); projectPath = ""; + currentDocumentId = ""; projectClosed(); } diff --git a/mix/qml/main.qml b/mix/qml/main.qml index 49d00311f..41b7c50a4 100644 --- a/mix/qml/main.qml +++ b/mix/qml/main.qml @@ -88,7 +88,7 @@ ApplicationWindow { text: qsTr("Mine") shortcut: "Ctrl+M" onTriggered: clientModel.mine(); - enabled: codeModel.hasContract && !clientModel.running + enabled: codeModel.hasContract && !clientModel.running &&!clientModel.mining } Connections {