aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorGreg Lewis <glewis@FreeBSD.org>2005-11-02 06:01:12 +0800
committerGreg Lewis <glewis@FreeBSD.org>2005-11-02 06:01:12 +0800
commit5c2fd494ba788d2a145c1d250f5bfef73eeda019 (patch)
tree8c959ac7a1b6836228c020a9d9c6e413938927a2 /java
parentb0f40404815ddde06a9ac4e06c988ce7bffdc74d (diff)
downloadfreebsd-ports-5c2fd494ba788d2a145c1d250f5bfef73eeda019.tar.gz
freebsd-ports-5c2fd494ba788d2a145c1d250f5bfef73eeda019.tar.zst
freebsd-ports-5c2fd494ba788d2a145c1d250f5bfef73eeda019.zip
. Update to 1.4.2_10.
Notes
Notes: svn path=/head/; revision=146957
Diffstat (limited to 'java')
-rw-r--r--java/linux-sun-jdk14/Makefile4
-rw-r--r--java/linux-sun-jdk14/distinfo4
-rw-r--r--java/linux-sun-jdk14/pkg-plist2
3 files changed, 6 insertions, 4 deletions
diff --git a/java/linux-sun-jdk14/Makefile b/java/linux-sun-jdk14/Makefile
index 244f2b3ea448..e1480b64b593 100644
--- a/java/linux-sun-jdk14/Makefile
+++ b/java/linux-sun-jdk14/Makefile
@@ -31,7 +31,7 @@ NO_BUILD= yes
USE_LINUX= yes
USE_XLIB= yes
JDK_VERSION= 1.4.2
-JDK_REVISION= 09
+JDK_REVISION= 10
DL_JDK_VERSION= ${JDK_VERSION}_${JDK_REVISION}
INSTALL_JDK_VERSION= ${DL_JDK_VERSION:S/_/./g}
ONLY_FOR_ARCHS= i386 amd64
@@ -53,7 +53,7 @@ pre-everything::
do-extract:
@${MKDIR} ${WRKDIR}
@cd ${WRKDIR} \
- && ${TAIL} -n 138073 ${DISTDIR}/${DISTNAME}${EXTRACT_SUFX} > ${WRKDIR}/install.sfx \
+ && ${TAIL} -n 138580 ${DISTDIR}/${DISTNAME}${EXTRACT_SUFX} > ${WRKDIR}/install.sfx \
&& ${CHMOD} +x ${WRKDIR}/install.sfx \
&& ${WRKDIR}/install.sfx > /dev/null
diff --git a/java/linux-sun-jdk14/distinfo b/java/linux-sun-jdk14/distinfo
index 127a2c22c2d2..599a0c6e14bd 100644
--- a/java/linux-sun-jdk14/distinfo
+++ b/java/linux-sun-jdk14/distinfo
@@ -1,2 +1,2 @@
-MD5 (j2sdk-1_4_2_09-linux-i586.bin) = 96173e3090a9820fd2338af88fbb2d09
-SIZE (j2sdk-1_4_2_09-linux-i586.bin) = 36429599
+MD5 (j2sdk-1_4_2_10-linux-i586.bin) = c565e255b183e2284415238369108c11
+SIZE (j2sdk-1_4_2_10-linux-i586.bin) = 36446523
diff --git a/java/linux-sun-jdk14/pkg-plist b/java/linux-sun-jdk14/pkg-plist
index f572da8383d3..483860e75c19 100644
--- a/java/linux-sun-jdk14/pkg-plist
+++ b/java/linux-sun-jdk14/pkg-plist
@@ -957,6 +957,7 @@
%%T%%/jre/lib/font.properties.SuSE8.0
%%T%%/jre/lib/font.properties.ja
%%T%%/jre/lib/font.properties.ja.Redhat3
+%%T%%/jre/lib/font.properties.ja.Redhat4
%%T%%/jre/lib/font.properties.ja.Redhat6.1
%%T%%/jre/lib/font.properties.ja.Redhat6.2
%%T%%/jre/lib/font.properties.ja.Redhat7.2
@@ -976,6 +977,7 @@
%%T%%/jre/lib/font.properties.zh.Turbo
%%T%%/jre/lib/font.properties.zh_CN.Redhat
%%T%%/jre/lib/font.properties.zh_CN.Redhat2.1
+%%T%%/jre/lib/font.properties.zh_CN.Redhat4
%%T%%/jre/lib/font.properties.zh_CN.Sun
%%T%%/jre/lib/font.properties.zh_CN_UTF8.Sun
%%T%%/jre/lib/font.properties.zh_HK.Sun
389'>389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414
/*
    This file is part of cpp-ethereum.

    cpp-ethereum is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    cpp-ethereum is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with cpp-ethereum.  If not, see <http://www.gnu.org/licenses/>.
*/
/**
 * @author Christian <c@ethdev.com>
 * @date 2014
 * Solidity abstract syntax tree.
 */

#pragma once


#include <string>
#include <vector>
#include <memory>
#include <boost/noncopyable.hpp>
#include <libevmasm/SourceLocation.h>
#include <libsolidity/interface/Utils.h>
#include <libsolidity/ast/ASTForward.h>
#include <libsolidity/parsing/Token.h>
#include <libsolidity/ast/Types.h>
#include <libsolidity/interface/Exceptions.h>
#include <libsolidity/ast/ASTAnnotations.h>

namespace dev
{
namespace solidity
{

class ASTVisitor;
class ASTConstVisitor;


/**
 * The root (abstract) class of the AST inheritance tree.
 * It is possible to traverse all direct and indirect children of an AST node by calling
 * accept, providing an ASTVisitor.
 */
class ASTNode: private boost::noncopyable
{
public:
    explicit ASTNode(SourceLocation const& _location);
    virtual ~ASTNode();

    virtual void accept(ASTVisitor& _visitor) = 0;
    virtual void accept(ASTConstVisitor& _visitor) const = 0;
    template <class T>
    static void listAccept(std::vector<T> const& _list, ASTVisitor& _visitor)
    {
        for (T const& element: _list)
            element->accept(_visitor);
    }
    template <class T>
    static void listAccept(std::vector<T> const& _list, ASTConstVisitor& _visitor)
    {
        for (T const& element: _list)
            element->accept(_visitor);
    }

    /// @returns a copy of the vector containing only the nodes which derive from T.
    template <class _T>
    static std::vector<_T const*> filteredNodes(std::vector<ASTPointer<ASTNode>> const& _nodes);

    /// Returns the source code location of this node.
    SourceLocation const& location() const { return m_location; }

    /// Creates a @ref TypeError exception and decorates it with the location of the node and
    /// the given description
    Error createTypeError(std::string const& _description) const;

    ///@todo make this const-safe by providing a different way to access the annotation
    virtual ASTAnnotation& annotation() const;

    ///@{
    ///@name equality operators
    /// Equality relies on the fact that nodes cannot be copied.
    bool operator==(ASTNode const& _other) const { return this == &_other; }
    bool operator!=(ASTNode const& _other) const { return !operator==(_other); }
    ///@}

protected:
    /// Annotation - is specialised in derived classes, is created upon request (because of polymorphism).
    mutable ASTAnnotation* m_annotation = nullptr;

private:
    SourceLocation m_location;
};

template <class _T>
std::vector<_T const*> ASTNode::filteredNodes(std::vector<ASTPointer<ASTNode>> const& _nodes)
{
    std::vector<_T const*> ret;
    for (auto const& n: _nodes)
        if (auto const* nt = dynamic_cast<_T const*>(n.get()))
            ret.push_back(nt);
    return ret;
}

/**
 * Source unit containing import directives and contract definitions.
 */
class SourceUnit: public ASTNode
{
public:
    SourceUnit(SourceLocation const& _location, std::vector<ASTPointer<ASTNode>> const& _nodes):
        ASTNode(_location), m_nodes(_nodes) {}

    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    std::vector<ASTPointer<ASTNode>> nodes() const { return m_nodes; }

private:
    std::vector<ASTPointer<ASTNode>> m_nodes;
};

/**
 * Import directive for referencing other files / source objects.
 * Example: import "abc.sol"
 * Source objects are identified by a string which can be a file name but does not have to be.
 */
class ImportDirective: public ASTNode
{
public:
    ImportDirective(SourceLocation const& _location, ASTPointer<ASTString> const& _identifier):
        ASTNode(_location), m_identifier(_identifier) {}

    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    ASTString const& identifier() const { return *m_identifier; }

private:
    ASTPointer<ASTString> m_identifier;
};

/**
 * Abstract AST class for a declaration (contract, function, struct, variable).
 */
class Declaration: public ASTNode
{
public:
    /// Visibility ordered from restricted to unrestricted.
    enum class Visibility { Default, Private, Internal, Public, External };

    Declaration(
        SourceLocation const& _location,
        ASTPointer<ASTString> const& _name,
        Visibility _visibility = Visibility::Default
    ):
        ASTNode(_location), m_name(_name), m_visibility(_visibility), m_scope(nullptr) {}

    /// @returns the declared name.
    ASTString const& name() const { return *m_name; }
    Visibility visibility() const { return m_visibility == Visibility::Default ? defaultVisibility() : m_visibility; }
    bool isPublic() const { return visibility() >= Visibility::Public; }
    virtual bool isVisibleInContract() const { return visibility() != Visibility::External; }
    bool isVisibleInDerivedContracts() const { return isVisibleInContract() && visibility() >= Visibility::Internal; }

    /// @returns the scope this declaration resides in. Can be nullptr if it is the global scope.
    /// Available only after name and type resolution step.
    Declaration const* scope() const { return m_scope; }
    void setScope(Declaration const* _scope) { m_scope = _scope; }

    virtual bool isLValue() const { return false; }
    virtual bool isPartOfExternalInterface() const { return false; }

    /// @returns the type of expressions referencing this declaration.
    /// The current contract has to be given since this context can change the type, especially of
    /// contract types.
    /// This can only be called once types of variable declarations have already been resolved.
    virtual TypePointer type() const = 0;

protected:
    virtual Visibility defaultVisibility() const { return Visibility::Public; }

private:
    ASTPointer<ASTString> m_name;
    Visibility m_visibility;
    Declaration const* m_scope;
};

/**
 * Abstract class that is added to each AST node that can store local variables.
 */
class VariableScope
{
public:
    void addLocalVariable(VariableDeclaration const& _localVariable) { m_localVariables.push_back(&_localVariable); }
    std::vector<VariableDeclaration const*> const& localVariables() const { return m_localVariables; }

private:
    std::vector<VariableDeclaration const*> m_localVariables;
};

/**
 * Abstract class that is added to each AST node that can receive documentation.
 */
class Documented
{
public:
    explicit Documented(ASTPointer<ASTString> const& _documentation): m_documentation(_documentation) {}

    /// @return A shared pointer of an ASTString.
    /// Can contain a nullptr in which case indicates absence of documentation
    ASTPointer<ASTString> const& documentation() const { return m_documentation; }

protected:
    ASTPointer<ASTString> m_documentation;
};

/**
 * Abstract class that is added to AST nodes that can be marked as not being fully implemented
 */
class ImplementationOptional
{
public:
    explicit ImplementationOptional(bool _implemented): m_implemented(_implemented) {}

    /// @return whether this node is fully implemented or not
    bool isImplemented() const { return m_implemented; }

protected:
    bool m_implemented;
};

/// @}

/**
 * Definition of a contract or library. This is the only AST nodes where child nodes are not visited in
 * document order. It first visits all struct declarations, then all variable declarations and
 * finally all function declarations.
 */
class ContractDefinition: public Declaration, public Documented
{
public:
    ContractDefinition(
        SourceLocation const& _location,
        ASTPointer<ASTString> const& _name,
        ASTPointer<ASTString> const& _documentation,
        std::vector<ASTPointer<InheritanceSpecifier>> const& _baseContracts,
        std::vector<ASTPointer<ASTNode>> const& _subNodes,
        bool _isLibrary
    ):
        Declaration(_location, _name),
        Documented(_documentation),
        m_baseContracts(_baseContracts),
        m_subNodes(_subNodes),
        m_isLibrary(_isLibrary)
    {}

    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    std::vector<ASTPointer<InheritanceSpecifier>> const& baseContracts() const { return m_baseContracts; }
    std::vector<ASTPointer<ASTNode>> const& subNodes() const { return m_subNodes; }
    std::vector<UsingForDirective const*> usingForDirectives() const { return filteredNodes<UsingForDirective>(m_subNodes); }
    std::vector<StructDefinition const*> definedStructs() const { return filteredNodes<StructDefinition>(m_subNodes); }
    std::vector<EnumDefinition const*> definedEnums() const { return filteredNodes<EnumDefinition>(m_subNodes); }
    std::vector<VariableDeclaration const*> stateVariables() const { return filteredNodes<VariableDeclaration>(m_subNodes); }
    std::vector<ModifierDefinition const*> functionModifiers() const { return filteredNodes<ModifierDefinition>(m_subNodes); }
    std::vector<FunctionDefinition const*> definedFunctions() const { return filteredNodes<FunctionDefinition>(m_subNodes); }
    std::vector<EventDefinition const*> events() const { return filteredNodes<EventDefinition>(m_subNodes); }
    std::vector<EventDefinition const*> const& interfaceEvents() const;
    bool isLibrary() const { return m_isLibrary; }

    /// @returns a map of canonical function signatures to FunctionDefinitions
    /// as intended for use by the ABI.
    std::map<FixedHash<4>, FunctionTypePointer> interfaceFunctions() const;
    std::vector<std::pair<FixedHash<4>, FunctionTypePointer>> const& interfaceFunctionList() const;

    /// @returns a list of the inheritable members of this contract
    std::vector<Declaration const*> const& inheritableMembers() const;

    /// Returns the constructor or nullptr if no constructor was specified.
    FunctionDefinition const* constructor() const;
    /// Returns the fallback function or nullptr if no fallback function was specified.
    FunctionDefinition const* fallbackFunction() const;

    std::string const& userDocumentation() const;
    void setUserDocumentation(std::string const& _userDocumentation);

    std::string const& devDocumentation() const;
    void setDevDocumentation(std::string const& _devDocumentation);

    virtual TypePointer type() const override;

    virtual ContractDefinitionAnnotation& annotation() const override;

private:
    std::vector<ASTPointer<InheritanceSpecifier>> m_baseContracts;
    std::vector<ASTPointer<ASTNode>> m_subNodes;
    bool m_isLibrary;

    // parsed Natspec documentation of the contract.
    std::string m_userDocumentation;
    std::string m_devDocumentation;

    std::vector<ContractDefinition const*> m_linearizedBaseContracts;
    mutable std::unique_ptr<std::vector<std::pair<FixedHash<4>, FunctionTypePointer>>> m_interfaceFunctionList;
    mutable std::unique_ptr<std::vector<EventDefinition const*>> m_interfaceEvents;
    mutable std::unique_ptr<std::vector<Declaration const*>> m_inheritableMembers;
};

class InheritanceSpecifier: public ASTNode
{
public:
    InheritanceSpecifier(
        SourceLocation const& _location,
        ASTPointer<Identifier> const& _baseName,
        std::vector<ASTPointer<Expression>> _arguments
    ):
        ASTNode(_location), m_baseName(_baseName), m_arguments(_arguments) {}

    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    Identifier const& name() const { return *m_baseName; }
    std::vector<ASTPointer<Expression>> const& arguments() const { return m_arguments; }

private:
    ASTPointer<Identifier> m_baseName;
    std::vector<ASTPointer<Expression>> m_arguments;
};

/**
 * `using LibraryName for uint` will attach all functions from the library LibraryName
 * to `uint` if the first parameter matches the type. `using LibraryName for *` attaches
 * the function to any matching type.
 */
class UsingForDirective: public ASTNode
{
public:
    UsingForDirective(
        SourceLocation const& _location,
        ASTPointer<Identifier> const& _libraryName,
        ASTPointer<TypeName> const& _typeName
    ):
        ASTNode(_location), m_libraryName(_libraryName), m_typeName(_typeName) {}

    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    Identifier const& libraryName() const { return *m_libraryName; }
    /// @returns the type name the library is attached to, null for `*`.
    TypeName const* typeName() const { return m_typeName.get(); }

private:
    ASTPointer<Identifier> m_libraryName;
    ASTPointer<TypeName> m_typeName;
};

class StructDefinition: public Declaration
{
public:
    StructDefinition(
        SourceLocation const& _location,
        ASTPointer<ASTString> const& _name,
        std::vector<ASTPointer<VariableDeclaration>> const& _members
    ):
        Declaration(_location, _name), m_members(_members) {}

    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    std::vector<ASTPointer<VariableDeclaration>> const& members() const { return m_members; }

    virtual TypePointer type() const override;

    virtual TypeDeclarationAnnotation& annotation() const override;

private:
    std::vector<ASTPointer<VariableDeclaration>> m_members;
};

class EnumDefinition: public Declaration
{
public:
    EnumDefinition(
        SourceLocation const& _location,
        ASTPointer<ASTString> const& _name,
        std::vector<ASTPointer<EnumValue>> const& _members
    ):
        Declaration(_location, _name), m_members(_members) {}
    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    std::vector<ASTPointer<EnumValue>> const& members() const { return m_members; }

    virtual TypePointer type() const override;

    virtual TypeDeclarationAnnotation& annotation() const override;

private:
    std::vector<ASTPointer<EnumValue>> m_members;
};

/**
 * Declaration of an Enum Value
 */
class EnumValue: public Declaration
{
public:
    EnumValue(SourceLocation const& _location, ASTPointer<ASTString> const& _name):
        Declaration(_location, _name) {}

    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    virtual TypePointer type() const override;
};

/**
 * Parameter list, used as function parameter list and return list.
 * None of the parameters is allowed to contain mappings (not even recursively
 * inside structs).
 */
class ParameterList: public ASTNode
{
public:
    ParameterList(
        SourceLocation const& _location,
        std::vector<ASTPointer<VariableDeclaration>> const& _parameters
    ):
        ASTNode(_location), m_parameters(_parameters) {}
    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    std::vector<ASTPointer<VariableDeclaration>> const& parameters() const { return m_parameters; }

private:
    std::vector<ASTPointer<VariableDeclaration>> m_parameters;
};

/**
 * Base class for all nodes that define function-like objects, i.e. FunctionDefinition,
 * EventDefinition and ModifierDefinition.
 */
class CallableDeclaration: public Declaration, public VariableScope
{
public:
    CallableDeclaration(
        SourceLocation const& _location,
        ASTPointer<ASTString> const& _name,
        Declaration::Visibility _visibility,
        ASTPointer<ParameterList> const& _parameters,
        ASTPointer<ParameterList> const& _returnParameters = ASTPointer<ParameterList>()
    ):
        Declaration(_location, _name, _visibility),
        m_parameters(_parameters),
        m_returnParameters(_returnParameters)
    {
    }

    std::vector<ASTPointer<VariableDeclaration>> const& parameters() const { return m_parameters->parameters(); }
    ParameterList const& parameterList() const { return *m_parameters; }
    ASTPointer<ParameterList> const& returnParameterList() const { return m_returnParameters; }

protected:
    ASTPointer<ParameterList> m_parameters;
    ASTPointer<ParameterList> m_returnParameters;
};

class FunctionDefinition: public CallableDeclaration, public Documented, public ImplementationOptional
{
public:
    FunctionDefinition(
        SourceLocation const& _location,
        ASTPointer<ASTString> const& _name,
        Declaration::Visibility _visibility,
        bool _isConstructor,
        ASTPointer<ASTString> const& _documentation,
        ASTPointer<ParameterList> const& _parameters,
        bool _isDeclaredConst,
        std::vector<ASTPointer<ModifierInvocation>> const& _modifiers,
        ASTPointer<ParameterList> const& _returnParameters,
        ASTPointer<Block> const& _body
    ):
        CallableDeclaration(_location, _name, _visibility, _parameters, _returnParameters),
        Documented(_documentation),
        ImplementationOptional(_body != nullptr),
        m_isConstructor(_isConstructor),
        m_isDeclaredConst(_isDeclaredConst),
        m_functionModifiers(_modifiers),
        m_body(_body)
    {}

    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    bool isConstructor() const { return m_isConstructor; }
    bool isDeclaredConst() const { return m_isDeclaredConst; }
    std::vector<ASTPointer<ModifierInvocation>> const& modifiers() const { return m_functionModifiers; }
    std::vector<ASTPointer<VariableDeclaration>> const& returnParameters() const { return m_returnParameters->parameters(); }
    Block const& body() const { return *m_body; }

    virtual bool isVisibleInContract() const override
    {
        return Declaration::isVisibleInContract() && !isConstructor() && !name().empty();
    }
    virtual bool isPartOfExternalInterface() const override { return isPublic() && !m_isConstructor && !name().empty(); }

    /// @returns the external signature of the function
    /// That consists of the name of the function followed by the types of the
    /// arguments separated by commas all enclosed in parentheses without any spaces.
    std::string externalSignature() const;

    virtual TypePointer type() const override;

    virtual FunctionDefinitionAnnotation& annotation() const override;

private:
    bool m_isConstructor;
    bool m_isDeclaredConst;
    std::vector<ASTPointer<ModifierInvocation>> m_functionModifiers;
    ASTPointer<Block> m_body;
};

/**
 * Declaration of a variable. This can be used in various places, e.g. in function parameter
 * lists, struct definitions and even function bodys.
 */
class VariableDeclaration: public Declaration
{
public:
    enum Location { Default, Storage, Memory };

    VariableDeclaration(
        SourceLocation const& _sourceLocation,
        ASTPointer<TypeName> const& _type,
        ASTPointer<ASTString> const& _name,
        ASTPointer<Expression> _value,
        Visibility _visibility,
        bool _isStateVar = false,
        bool _isIndexed = false,
        bool _isConstant = false,
        Location _referenceLocation = Location::Default
    ):
        Declaration(_sourceLocation, _name, _visibility),
        m_typeName(_type),
        m_value(_value),
        m_isStateVariable(_isStateVar),
        m_isIndexed(_isIndexed),
        m_isConstant(_isConstant),
        m_location(_referenceLocation) {}

    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    TypeName* typeName() const { return m_typeName.get(); }
    ASTPointer<Expression> const& value() const { return m_value; }

    virtual bool isLValue() const override;
    virtual bool isPartOfExternalInterface() const override { return isPublic(); }

    bool isLocalVariable() const { return !!dynamic_cast<FunctionDefinition const*>(scope()); }
    /// @returns true if this variable is a parameter or return parameter of a function.
    bool isCallableParameter() const;
    /// @returns true if this variable is a parameter (not return parameter) of an external function.
    bool isExternalCallableParameter() const;
    /// @returns true if the type of the variable does not need to be specified, i.e. it is declared
    /// in the body of a function or modifier.
    bool canHaveAutoType() const;
    bool isStateVariable() const { return m_isStateVariable; }
    bool isIndexed() const { return m_isIndexed; }
    bool isConstant() const { return m_isConstant; }
    Location referenceLocation() const { return m_location; }

    virtual TypePointer type() const override;

    virtual VariableDeclarationAnnotation& annotation() const override;

protected:
    Visibility defaultVisibility() const override { return Visibility::Internal; }

private:
    ASTPointer<TypeName> m_typeName; ///< can be empty ("var")
    /// Initially assigned value, can be missing. For local variables, this is stored inside
    /// VariableDeclarationStatement and not here.
    ASTPointer<Expression> m_value;
    bool m_isStateVariable; ///< Whether or not this is a contract state variable
    bool m_isIndexed; ///< Whether this is an indexed variable (used by events).
    bool m_isConstant; ///< Whether the variable is a compile-time constant.
    Location m_location; ///< Location of the variable if it is of reference type.
};

/**
 * Definition of a function modifier.
 */
class ModifierDefinition: public CallableDeclaration, public Documented
{
public:
    ModifierDefinition(
        SourceLocation const& _location,
        ASTPointer<ASTString> const& _name,
        ASTPointer<ASTString> const& _documentation,
        ASTPointer<ParameterList> const& _parameters,
        ASTPointer<Block> const& _body
    ):
        CallableDeclaration(_location, _name, Visibility::Default, _parameters),
        Documented(_documentation),
        m_body(_body)
    {
    }

    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    Block const& body() const { return *m_body; }

    virtual TypePointer type() const override;

    virtual ModifierDefinitionAnnotation& annotation() const override;

private:
    ASTPointer<Block> m_body;
};

/**
 * Invocation/usage of a modifier in a function header or a base constructor call.
 */
class ModifierInvocation: public ASTNode
{
public:
    ModifierInvocation(
        SourceLocation const& _location,
        ASTPointer<Identifier> const& _name,
        std::vector<ASTPointer<Expression>> _arguments
    ):
        ASTNode(_location), m_modifierName(_name), m_arguments(_arguments) {}

    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    ASTPointer<Identifier> const& name() const { return m_modifierName; }
    std::vector<ASTPointer<Expression>> const& arguments() const { return m_arguments; }

private:
    ASTPointer<Identifier> m_modifierName;
    std::vector<ASTPointer<Expression>> m_arguments;
};

/**
 * Definition of a (loggable) event.
 */
class EventDefinition: public CallableDeclaration, public Documented
{
public:
    EventDefinition(
        SourceLocation const& _location,
        ASTPointer<ASTString> const& _name,
        ASTPointer<ASTString> const& _documentation,
        ASTPointer<ParameterList> const& _parameters,
        bool _anonymous = false
    ):
        CallableDeclaration(_location, _name, Visibility::Default, _parameters),
        Documented(_documentation),
        m_anonymous(_anonymous)
    {
    }

    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    bool isAnonymous() const { return m_anonymous; }

    virtual TypePointer type() const override;

    virtual EventDefinitionAnnotation& annotation() const override;

private:
    bool m_anonymous = false;
};

/**
 * Pseudo AST node that is used as declaration for "this", "msg", "tx", "block" and the global
 * functions when such an identifier is encountered. Will never have a valid location in the source code.
 */
class MagicVariableDeclaration: public Declaration
{
public:
    MagicVariableDeclaration(ASTString const& _name, std::shared_ptr<Type const> const& _type):
        Declaration(SourceLocation(), std::make_shared<ASTString>(_name)), m_type(_type) {}
    virtual void accept(ASTVisitor&) override
    {
        BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("MagicVariableDeclaration used inside real AST."));
    }
    virtual void accept(ASTConstVisitor&) const override
    {
        BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("MagicVariableDeclaration used inside real AST."));
    }

    virtual TypePointer type() const override { return m_type; }

private:
    std::shared_ptr<Type const> m_type;
};

/// Types
/// @{

/**
 * Abstract base class of a type name, can be any built-in or user-defined type.
 */
class TypeName: public ASTNode
{
public:
    explicit TypeName(SourceLocation const& _location): ASTNode(_location) {}
    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    virtual TypeNameAnnotation& annotation() const override;
};

/**
 * Any pre-defined type name represented by a single keyword, i.e. it excludes mappings,
 * contracts, functions, etc.
 */
class ElementaryTypeName: public TypeName
{
public:
    ElementaryTypeName(SourceLocation const& _location, Token::Value _type):
        TypeName(_location), m_type(_type)
    {
        solAssert(Token::isElementaryTypeName(_type), "");
    }
    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    Token::Value typeName() const { return m_type; }

private:
    Token::Value m_type;
};

/**
 * Name referring to a user-defined type (i.e. a struct, contract, etc.).
 */
class UserDefinedTypeName: public TypeName
{
public:
    UserDefinedTypeName(SourceLocation const& _location, std::vector<ASTString> const& _namePath):
        TypeName(_location), m_namePath(_namePath) {}
    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    std::vector<ASTString> const& namePath() const { return m_namePath; }

    virtual UserDefinedTypeNameAnnotation& annotation() const override;

private:
    std::vector<ASTString> m_namePath;
};

/**
 * A mapping type. Its source form is "mapping('keyType' => 'valueType')"
 */
class Mapping: public TypeName
{
public:
    Mapping(
        SourceLocation const& _location,
        ASTPointer<ElementaryTypeName> const& _keyType,
        ASTPointer<TypeName> const& _valueType
    ):
        TypeName(_location), m_keyType(_keyType), m_valueType(_valueType) {}
    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    ElementaryTypeName const& keyType() const { return *m_keyType; }
    TypeName const& valueType() const { return *m_valueType; }

private:
    ASTPointer<ElementaryTypeName> m_keyType;
    ASTPointer<TypeName> m_valueType;
};

/**
 * An array type, can be "typename[]" or "typename[<expression>]".
 */
class ArrayTypeName: public TypeName
{
public:
    ArrayTypeName(
        SourceLocation const& _location,
        ASTPointer<TypeName> const& _baseType,
        ASTPointer<Expression> const& _length
    ):
        TypeName(_location), m_baseType(_baseType), m_length(_length) {}
    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    TypeName const& baseType() const { return *m_baseType; }
    Expression const* length() const { return m_length.get(); }

private:
    ASTPointer<TypeName> m_baseType;
    ASTPointer<Expression> m_length; ///< Length of the array, might be empty.
};

/// @}

/// Statements
/// @{


/**
 * Abstract base class for statements.
 */
class Statement: public ASTNode, public Documented
{
public:
    explicit Statement(
        SourceLocation const& _location,
        ASTPointer<ASTString> const& _docString
    ): ASTNode(_location), Documented(_docString) {}

    virtual StatementAnnotation& annotation() const override;
};

/**
 * Brace-enclosed block containing zero or more statements.
 */
class Block: public Statement
{
public:
    Block(
        SourceLocation const& _location,
        ASTPointer<ASTString> const& _docString,
        std::vector<ASTPointer<Statement>> const& _statements
    ):
        Statement(_location, _docString), m_statements(_statements) {}
    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    std::vector<ASTPointer<Statement>> const& statements() const { return m_statements; }

private:
    std::vector<ASTPointer<Statement>> m_statements;
};

/**
 * Special placeholder statement denoted by "_" used in function modifiers. This is replaced by
 * the original function when the modifier is applied.
 */
class PlaceholderStatement: public Statement
{
public:
    explicit PlaceholderStatement(
        SourceLocation const& _location,
        ASTPointer<ASTString> const& _docString
    ): Statement(_location, _docString) {}

    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;
};

/**
 * If-statement with an optional "else" part. Note that "else if" is modeled by having a new
 * if-statement as the false (else) body.
 */
class IfStatement: public Statement
{
public:
    IfStatement(
        SourceLocation const& _location,
        ASTPointer<ASTString> const& _docString,
        ASTPointer<Expression> const& _condition,
        ASTPointer<Statement> const& _trueBody,
        ASTPointer<Statement> const& _falseBody
    ):
        Statement(_location, _docString),
        m_condition(_condition),
        m_trueBody(_trueBody),
        m_falseBody(_falseBody)
    {}
    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    Expression const& condition() const { return *m_condition; }
    Statement const& trueStatement() const { return *m_trueBody; }
    /// @returns the "else" part of the if statement or nullptr if there is no "else" part.
    Statement const* falseStatement() const { return m_falseBody.get(); }

private:
    ASTPointer<Expression> m_condition;
    ASTPointer<Statement> m_trueBody;
    ASTPointer<Statement> m_falseBody; ///< "else" part, optional
};

/**
 * Statement in which a break statement is legal (abstract class).
 */
class BreakableStatement: public Statement
{
public:
    explicit BreakableStatement(
        SourceLocation const& _location,
        ASTPointer<ASTString> const& _docString
    ): Statement(_location, _docString) {}
};

class WhileStatement: public BreakableStatement
{
public:
    WhileStatement(
        SourceLocation const& _location,
        ASTPointer<ASTString> const& _docString,
        ASTPointer<Expression> const& _condition,
        ASTPointer<Statement> const& _body
    ):
        BreakableStatement(_location, _docString), m_condition(_condition), m_body(_body) {}
    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    Expression const& condition() const { return *m_condition; }
    Statement const& body() const { return *m_body; }

private:
    ASTPointer<Expression> m_condition;
    ASTPointer<Statement> m_body;
};

/**
 * For loop statement
 */
class ForStatement: public BreakableStatement
{
public:
    ForStatement(
        SourceLocation const& _location,
        ASTPointer<ASTString> const& _docString,
        ASTPointer<Statement> const& _initExpression,
        ASTPointer<Expression> const& _conditionExpression,
        ASTPointer<ExpressionStatement> const& _loopExpression,
        ASTPointer<Statement> const& _body
    ):
        BreakableStatement(_location, _docString),
        m_initExpression(_initExpression),
        m_condExpression(_conditionExpression),
        m_loopExpression(_loopExpression),
        m_body(_body)
    {}
    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;

    Statement const* initializationExpression() const { return m_initExpression.get(); }
    Expression const* condition() const { return m_condExpression.get(); }
    ExpressionStatement const* loopExpression() const { return m_loopExpression.get(); }
    Statement const& body() const { return *m_body; }

private:
    /// For statement's initialization expresion. for(XXX; ; ). Can be empty
    ASTPointer<Statement> m_initExpression;
    /// For statement's condition expresion. for(; XXX ; ). Can be empty
    ASTPointer<Expression> m_condExpression;
    /// For statement's loop expresion. for(;;XXX). Can be empty
    ASTPointer<ExpressionStatement> m_loopExpression;
    /// The body of the loop
    ASTPointer<Statement> m_body;
};

class Continue: public Statement
{
public:
    explicit Continue(SourceLocation const& _location,  ASTPointer<ASTString> const& _docString):
        Statement(_location, _docString) {}
    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;
};

class Break: public Statement
{
public:
    explicit Break(SourceLocation const& _location, ASTPointer<ASTString> const& _docString):
        Statement(_location, _docString) {}
    virtual void accept(ASTVisitor& _visitor) override;
    virtual void accept(ASTConstVisitor& _visitor) const override;
};

class Return: public Statement
{
public:
    Return(
        SourceLocation const& _location,