Skip to content

Commit

Permalink
today()
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed Jun 27, 2024
1 parent b692dd6 commit f87e78e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
11 changes: 6 additions & 5 deletions pya2l/aml/aml_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,28 +94,29 @@ std::any AmlVisitor::visitAmlFile(amlParser::AmlFileContext *ctx) {
std::any AmlVisitor::visitDeclaration(amlParser::DeclarationContext *ctx) {
const auto ctx_t = ctx->t;
const auto ctx_b = ctx->b;
Type *tp = nullptr;
TypeDefinition td;
BlockDefinition block;

if (ctx_t) {
tp = std::any_cast<Type *>(visit(ctx_t));
td = std::any_cast<TypeDefinition>(visit(ctx_t));
}

if (ctx_b) {
block = std::any_cast<BlockDefinition>(visit(ctx_b));
}

return Declaration(tp, block);
return Declaration(td, block);
}

std::any AmlVisitor::visitType_definition(amlParser::Type_definitionContext *ctx) {
const auto td_ctx = ctx->type_name();
Type * tp = nullptr;

if (td_ctx) {
const auto tn = visit(td_ctx);
tp = std::any_cast<Type*>(td_ctx);
}

return visitChildren(ctx);
return TypeDefinition(tp);
}

std::any AmlVisitor::visitType_name(amlParser::Type_nameContext *ctx) {
Expand Down
18 changes: 14 additions & 4 deletions pya2l/aml/klasses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,24 @@ class Type {
TypeType m_disc;
};

class TypeDefinition {
public:

TypeDefinition() = default;
TypeDefinition(Type* tp) : m_tp(tp) {}

private:
Type* m_tp;
};

class Declaration {
public:

explicit Declaration(Type* tp, const BlockDefinition& block) : m_tp(tp), m_block(block) {
explicit Declaration(TypeDefinition td, const BlockDefinition& block) : m_td(td), m_block(block) {
}

Type* get_type() const noexcept {
return m_tp;
const TypeDefinition& get_type() const noexcept {
return m_td;
}

const BlockDefinition& get_block() const noexcept {
Expand All @@ -482,7 +492,7 @@ class Declaration {

private:

Type* m_tp;
TypeDefinition m_td;
BlockDefinition m_block;
};

Expand Down

0 comments on commit f87e78e

Please sign in to comment.