souffle  2.0.2-371-g6315b36
ComponentChecker.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 /************************************************************************
10  *
11  * @file ComponentChecker.h
12  *
13  * Defines the component semantic checker pass.
14  *
15  ***********************************************************************/
16 
17 #pragma once
18 
19 #include "ast/Component.h"
20 #include "ast/ComponentInit.h"
21 #include "ast/ComponentType.h"
22 #include "ast/Program.h"
23 #include "ast/TranslationUnit.h"
26 #include "parser/SrcLocation.h"
27 #include "reports/ErrorReport.h"
28 #include <string>
29 
30 namespace souffle::ast::transform {
31 
32 class ComponentChecker : public Transformer {
33 public:
34  ~ComponentChecker() override = default;
35 
36  std::string getName() const override {
37  return "ComponentChecker";
38  }
39 
40  ComponentChecker* clone() const override {
41  return new ComponentChecker();
42  }
43 
44 private:
45  bool transform(TranslationUnit& translationUnit) override;
46 
48  const Component* enclosingComponent, const analysis::ComponentLookupAnalysis& componentLookup,
49  const std::string& name, const SrcLocation& loc, const analysis::TypeBinding& binding);
50  static void checkComponentReference(ErrorReport& report, const Component* enclosingComponent,
51  const analysis::ComponentLookupAnalysis& componentLookup, const ast::ComponentType& type,
52  const SrcLocation& loc, const analysis::TypeBinding& binding);
53  static void checkComponentInit(ErrorReport& report, const Component* enclosingComponent,
54  const analysis::ComponentLookupAnalysis& componentLookup, const ComponentInit& init,
55  const analysis::TypeBinding& binding);
56  static void checkComponent(ErrorReport& report, const Component* enclosingComponent,
57  const analysis::ComponentLookupAnalysis& componentLookup, const Component& component,
58  const analysis::TypeBinding& binding);
59  static void checkComponents(ErrorReport& report, const Program& program,
60  const analysis::ComponentLookupAnalysis& componentLookup);
61  static void checkComponentNamespaces(ErrorReport& report, const Program& program);
62 };
63 
64 } // namespace souffle::ast::transform
souffle::ast::transform::ComponentChecker::checkComponents
static void checkComponents(ErrorReport &report, const Program &program, const analysis::ComponentLookupAnalysis &componentLookup)
Definition: ComponentChecker.cpp:194
TranslationUnit.h
souffle::ast::transform::ComponentChecker::checkComponentNameReference
static const Component * checkComponentNameReference(ErrorReport &report, const Component *enclosingComponent, const analysis::ComponentLookupAnalysis &componentLookup, const std::string &name, const SrcLocation &loc, const analysis::TypeBinding &binding)
Definition: ComponentChecker.cpp:56
souffle::ast::transform::ComponentChecker::checkComponent
static void checkComponent(ErrorReport &report, const Component *enclosingComponent, const analysis::ComponentLookupAnalysis &componentLookup, const Component &component, const analysis::TypeBinding &binding)
Definition: ComponentChecker.cpp:108
souffle::ast::transform::ComponentChecker::getName
std::string getName() const override
Definition: ComponentChecker.h:48
SrcLocation.h
Component.h
souffle::ast::transform::ComponentChecker::checkComponentInit
static void checkComponentInit(ErrorReport &report, const Component *enclosingComponent, const analysis::ComponentLookupAnalysis &componentLookup, const ComponentInit &init, const analysis::TypeBinding &binding)
Definition: ComponentChecker.cpp:91
Transformer.h
souffle::ast::ComponentInit
Component initialization class.
Definition: ComponentInit.h:47
ComponentInit.h
souffle::ast::transform::ComponentChecker::clone
ComponentChecker * clone() const override
Definition: ComponentChecker.h:52
souffle::ast::ComponentType
Component type of a component.
Definition: ComponentType.h:45
souffle::ast::transform::ComponentChecker::transform
bool transform(TranslationUnit &translationUnit) override
Definition: ComponentChecker.cpp:47
souffle::ast::Program
The program class consists of relations, clauses and types.
Definition: Program.h:52
souffle::ast::transform::ComponentChecker::checkComponentReference
static void checkComponentReference(ErrorReport &report, const Component *enclosingComponent, const analysis::ComponentLookupAnalysis &componentLookup, const ast::ComponentType &type, const SrcLocation &loc, const analysis::TypeBinding &binding)
Definition: ComponentChecker.cpp:75
souffle::ast::TranslationUnit
Translation unit class for the translation pipeline.
Definition: TranslationUnit.h:51
ComponentLookup.h
souffle::ast::transform
Definition: Program.h:45
ComponentType.h
souffle::ast::analysis::TypeBinding
Class that encapsulates std::map of types binding that comes from .init c = Comp<MyType> Type binding...
Definition: ComponentLookup.h:37
souffle::ast::Component
Component class.
Definition: Component.h:58
Program.h
souffle::ast::transform::ComponentChecker::checkComponentNamespaces
static void checkComponentNamespaces(ErrorReport &report, const Program &program)
Definition: ComponentChecker.cpp:206
souffle::ast::transform::ComponentChecker
Definition: ComponentChecker.h:38
souffle::SrcLocation
A class describing a range in an input file.
Definition: SrcLocation.h:32
souffle::ErrorReport
Definition: ErrorReport.h:152
ErrorReport.h
souffle::ast::transform::ComponentChecker::~ComponentChecker
~ComponentChecker() override=default
std::type
ElementType type
Definition: span.h:640
souffle::ast::analysis::ComponentLookupAnalysis
Definition: ComponentLookup.h:78