Skip to content

Commit

Permalink
Multiple contracts in eosio::contract, and support for typedefs #5
Browse files Browse the repository at this point in the history
  • Loading branch information
soft-bagel-93 committed Dec 27, 2019
1 parent f8865e2 commit 54aad89
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions include/clang/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2870,6 +2870,8 @@ struct EosioOrder {

using EosioOrders = SmallVector<EosioOrder, 2>;

using EosioContracts = SmallVector<std::string, 2>;

/// Base class for declarations which introduce a typedef-name.
class TypedefNameDecl : public TypeDecl, public Redeclarable<TypedefNameDecl> {
struct LLVM_ALIGNAS(8) ModedTInfo {
Expand Down Expand Up @@ -2975,6 +2977,9 @@ class TypedefNameDecl : public TypeDecl, public Redeclarable<TypedefNameDecl> {
std::string getEosioTable() const;
bool hasEosioScopeType() const;
std::string getEosioScopeType() const;

bool hasEosioContracts() const;
EosioContracts getEosioContracts() const;
private:
bool isTransparentTagSlow() const;
};
Expand Down
2 changes: 1 addition & 1 deletion include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ def EosioRicardian : InheritableAttr {
def EosioContract : InheritableAttr {
let Spellings = [CXX11<"eosio", "contract">, GNU<"eosio_contract">];
let Args = [StringArgument<"name", 1>];
let Subjects = SubjectList<[CXXRecord, CXXMethod]>;
let Subjects = SubjectList<[CXXRecord, CXXMethod, TypedefName]>;
let Documentation = [EosioContractDocs];
}

Expand Down
9 changes: 9 additions & 0 deletions lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4450,6 +4450,15 @@ std::string TypedefNameDecl::getEosioScopeType()const {
return getAttr<EosioScopeTypeAttr>()->getType();
}

bool TypedefNameDecl::hasEosioContracts()const { return hasAttr<EosioContractAttr>(); }
EosioContracts TypedefNameDecl::getEosioContracts()const {
EosioContracts ret;
for (auto* attr: getAttrs()) {
if (auto order = dyn_cast<EosioContractAttr>(attr)) ret.push_back(order->getName());
}
return ret;
}

bool TypedefNameDecl::isTransparentTagSlow() const {
auto determineIsTransparent = [&]() {
if (auto *TT = getUnderlyingType()->getAs<TagType>()) {
Expand Down

0 comments on commit 54aad89

Please sign in to comment.