nany
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
ny::Atom Struct Referencefinal

Definition of a single class or function. More...

#include <atom.h>

Inheritance diagram for ny::Atom:

Classes

struct  FlagAutoSwitch
 
struct  Instances
 
struct  Parameters
 

Public Types

enum  Type : yuint8 {
  Type::namespacedef, Type::funcdef, Type::classdef, Type::vardef,
  Type::typealias, Type::unit
}
 
enum  Flags : uint32_t {
  Flags::suggestInReport, Flags::captureVariables, Flags::error, Flags::pushCapturedVariables,
  Flags::recursive, Flags::instanciating
}
 
enum  Category : uint32_t {
  Category::special, Category::funcoperator, Category::view, Category::classParent,
  Category::ctor, Category::clone, Category::dtor, Category::defvarInit,
  Category::functor, Category::capturedVar, Category::propget, Category::propset,
  Category::propsetCustom, Category::unittest
}
 

Public Member Functions

 Atom (const AnyString &name, Type type)
 
 Atom (Atom &rootparent, const AnyString &name, Type type)
 
Queries
AnyString name () const
 Atom name.
 
CLID clid () const
 Get the clid for this atom.
 
bool isNamespace () const
 Get if the atom is a namespace.
 
bool isClass () const
 Get if the atom is a class.
 
bool isFunction () const
 Get if the atom is a function.
 
bool isOperator () const
 Get if the atom is an operator.
 
bool isSpecial () const
 Get if the atom is a special atom (operator, view...)
 
bool isView () const
 Get if the atom is a view.
 
bool isMemberVariable () const
 Get if the atom is a member variable.
 
bool isClassMember () const
 Get if the atom is a class member (function or variable)
 
bool isAnonymousClass () const
 Get if the atom is an anonymous class.
 
bool isMemberVarDefaultInit () const
 Is a constructor.
 
bool isTypeAlias () const
 Is a type alias.
 
bool isUnit () const
 Get if the atom is an unit.
 
bool isCtor () const
 Get if the atom is a constructor.
 
bool isDtor () const
 Get if the atom is a destructor.
 
bool isCloneCtor () const
 Get if the atom is a clone constructor.
 
bool isFunctor () const
 Get if the atom is a functor (operator ())
 
bool callable () const
 Get if the atom is callable (can be called like a function)
 
bool isCapturedVariable () const
 Get if the atom is a captured variable.
 
bool isProperty () const
 Get if the atom is a property (get or set)
 
bool isPropertyGet () const
 Get if the atom is a property getter.
 
bool isPropertySet () const
 Get if the atom is a property setter.
 
bool isPropertySetCustom () const
 Get if the atom is a property setter (custom operator)
 
bool isUnittest () const
 Get if the atom is an unittest.
 
bool isPublicOrPublished () const
 Get if the atom is publicly accessible.
 
bool hasReturnType () const
 Get if the atom has a return type.
 
bool hasGenericParameters () const
 Get if the atom has generic type parameters.
 
bool isContextual () const
 Get if the atom is contextual. More...
 
bool canAccessTo (const Atom &) const
 Get if this atom can access (use) another one.
 
bool canCaptureVariabes () const
 Get if the atom can capture out-of-scope variables.
 
AtomparentScope ()
 Get the parent atom (if any)
 
const AtomparentScope () const
 Get the parent scope.
 
bool nameLookupFromParentScope (std::vector< std::reference_wrapper< Atom >> &list, const AnyString &name)
 Perform a name lookup from the local scope to the top root atom. More...
 
bool nameLookupOnChildren (std::vector< std::reference_wrapper< Atom >> &list, const AnyString &name, bool *singleHop=nullptr)
 Perform a name lookup from the local scope only. More...
 
bool propertyLookupOnChildren (std::vector< std::reference_wrapper< Atom >> &list, const AnyString &prefix, const AnyString &name)
 Perform a name lookup on properties from the local scope only. More...
 
bool hasMember (const AnyString &name) const
 Get if this atom has a child member.
 
template<class C >
void eachChild (const C &callback)
 Iterate through all children. More...
 
template<class C >
void eachChild (const C &callback) const
 
template<class C >
void eachChild (const AnyString &needle, const C &callback)
 Iterate through all children with a given name. More...
 
template<class C >
void eachChild (const AnyString &needle, const C &callback) const
 
uint32_t findClassAtom (Atom *&out, const AnyString &name)
 
uint32_t findFuncAtom (Atom *&out, const AnyString &name)
 
uint32_t findVarAtom (Atom *&out, const AnyString &name)
 
AtomfindNamespaceAtom (const AnyString &name)
 
const AtomfindChildByMemberFieldID (uint32_t field) const
 
void renameChild (const AnyString &from, const AnyString &to)
 Rename an atom. More...
 
bool findParent (const Atom &atom) const
 Determine whether an atom is a parent to the current atom.
 
uint32_t childrenCount () const
 Get the number of children.
 
bool hasChildren () const
 Get if this atom owns children (sub-classes, methods...)
 
sizeof
uint64_t runtimeSizeof () const
 Size at runtime (sizeof)
 
Info / Debugging
YString fullname () const
 Get the full name of the atom (without any parameters)
 
void retrieveFullname (YString &out, const ClassdefTableView *table=nullptr, bool parentName=true) const
 Append the full name of the atom (without any parameters)
 
YString caption () const
 Get the full name of the atom along with its parameters.
 
YString caption (const ClassdefTableView &) const
 Get the full name of the atom along with its parameter.
 
void retrieveCaption (YString &out, const ClassdefTableView &table) const
 Append the full name of the atom along with its parameters.
 
void printTree (const ClassdefTableView &) const
 Print the subtree.
 
AnyString keyword () const
 Keyword (class, func, var, namespace...) More...
 

Static Public Member Functions

static void extractNames (AnyString &keyword, AnyString &varname, const AnyString &name)
 Get the atom keyword ('func', 'class', 'operator'...) of a given name.
 

Public Attributes

struct ny::Atom::Instances instances
 
uint32_t atomid = 0u
 Atom unique ID (32-bits only, used for classification)
 
Yuni::Flags< Flagsflags = {Flags::suggestInReport}
 Atom flags.
 
Yuni::Flags< Categorycategory
 Atom Category.
 
struct {
   uint16_t   fieldindex = 0
 Field index within the class (before optimization)
 
   uint16_t   effectiveFieldIndex = 0
 Effective field index for runtime.
 
varinfo
 Various information for vardef only (class member)
 
struct {
   bool   isInstanciated = false
 Flag to determine whether the class has already been instanciated or not.
 
   uint16_t   nextFieldIndex = 0
 Next field index for new variable members.
 
   struct {
      uint32_t   atomid = 0
 
      uint32_t   instanceid = (uint32_t) - 1
 
   }   dtor
 Direct access to the destructor (used for reduce compilation time)
 
   struct {
      uint32_t   atomid = 0
 
      uint32_t   instanceid = (uint32_t) - 1
 
   }   clone
 Direct access to the clone func (used to reduce compilation time)
 
classinfo
 Various information for classdef only.
 
const Type type
 Flag to determine whether this entry is a blueprint or a namespace.
 
nyvisibility_t visibility = nyv_public
 Visibility.
 
Atomparent = nullptr
 Parent node.
 
struct {
   YString   filename
 File source.
 
   uint32_t   line = 0
 Start offset.
 
   uint32_t   offset = 0
 end offset
 
origin
 Origins.
 
Vardef returnType
 The return type.
 
Parameters parameters
 Parameters (for functions)
 
Parameters tmplparams
 Template parameters.
 
Parameters tmplparamsForPrinting
 Template parameters just for printing informations (such as errors)
 
uint32_t localVariablesCount = 0u
 The maximum number of variables / classdefs registered for the atom.
 
AtomscopeForNameResolution = nullptr
 A different scope for name resolution, if not null (for plugs/outlets)
 
struct {
   ir::Sequence *   ircode = nullptr
 The original IR sequence.
 
   uint32_t   offset = 0
 Offset to start within this sequence.
 
   uint32_t   stackSizeExtra = 0
 For capturing variables, it may be required to increase the IR stack size.
 
   bool   owned = false
 Flag to determine whether the sequence is owned by the atom or not.
 
opcodes
 The original IR sequence.
 
AnyString builtinalias
 Builtin alias (empty if none)
 
nytype_t builtinMapping = nyt_void
 Builtin type (!= nyt_void if this atom represents a builtin)
 
std::unique_ptr< std::unordered_set< AnyString > > candidatesForCapture
 List of potential candidates for being captured.
 

Friends

struct AtomMap
 

Detailed Description

Definition of a single class or function.

Member Enumeration Documentation

§ Category

enum ny::Atom::Category : uint32_t
strong
Enumerator
special 

Not a normal func/class.

funcoperator 

Operator.

view 

Is the atom a view.

classParent 

When the atom has a class as parent.

ctor 

When the atom is a constructor.

clone 

When the atom is copy constructor.

dtor 

When the atom is the destructor.

defvarInit 

Default variable initialization.

functor 

Functor object.

capturedVar 

Captured variable.

propget 

Property get.

propset 

Property set.

propsetCustom 

property set, custom operator, for future uses

unittest 

unittest

§ Flags

enum ny::Atom::Flags : uint32_t
strong
Enumerator
suggestInReport 

Allow this atom in error reporting.

captureVariables 

Allow this atom (and the sub-functions) to capture variables.

error 

Suppress error messages related to this atom (and code generation)

pushCapturedVariables 

Append captured variables when calling this function (ctor)

recursive 

This func will call itself (directly or indirectly)

instanciating 

Atom currently being instanciated.

§ Type

enum ny::Atom::Type : yuint8
strong
Enumerator
namespacedef 

define a part of a namespace

funcdef 

function definition

classdef 

class definition

vardef 

Variable definition.

typealias 

Typedef.

unit 

Unit (source file)

Member Function Documentation

§ eachChild() [1/2]

template<class C >
void ny::Atom::eachChild ( const C &  callback)
inline

Iterate through all children.

atom.eachChild([&](Atom& child) -> bool {
std::cout << child.name << std::endl;
return true;
});

§ eachChild() [2/2]

template<class C >
void ny::Atom::eachChild ( const AnyString &  needle,
const C &  callback 
)
inline

Iterate through all children with a given name.

atom.eachChild("childname", [&](Atom& child) -> bool {
std::cout << child.name << std::endl;
return true;
});

§ isContextual()

bool ny::Atom::isContextual ( ) const
inline

Get if the atom is contextual.

Contextual means the internal values may vary from a parent instanciation, like a class inside a function, generic types params...

§ keyword()

AnyString ny::Atom::keyword ( ) const

Keyword (class, func, var, namespace...)

Note
The result may lack in precision, since it can depend on the current classdef attached to it
See also
ny::ClassdefTableView::keyword()

§ nameLookupFromParentScope()

bool ny::Atom::nameLookupFromParentScope ( std::vector< std::reference_wrapper< Atom >> &  list,
const AnyString &  name 
)

Perform a name lookup from the local scope to the top root atom.

Parameters
[in,out]listList where all matches will be added
nameThe identifier name to find
Returns
True if at least one overload has been found

§ nameLookupOnChildren()

bool ny::Atom::nameLookupOnChildren ( std::vector< std::reference_wrapper< Atom >> &  list,
const AnyString &  name,
bool *  singleHop = nullptr 
)

Perform a name lookup from the local scope only.

Parameters
[in,out]listList where all matches will be added
nameThe identifier name to find
Returns
True if at least one overload has been found

§ propertyLookupOnChildren()

bool ny::Atom::propertyLookupOnChildren ( std::vector< std::reference_wrapper< Atom >> &  list,
const AnyString &  prefix,
const AnyString &  name 
)

Perform a name lookup on properties from the local scope only.

Parameters
[in,out]listList where all matches will be added
nameThe identifier name to find
Returns
True if at least one overload has been found

§ renameChild()

void ny::Atom::renameChild ( const AnyString &  from,
const AnyString &  to 
)

Rename an atom.

Warning
This method MUST be used with care since the atom does not own the string representing its name

Member Data Documentation

§ offset

uint32_t ny::Atom::offset = 0

end offset

Offset to start within this sequence.


The documentation for this struct was generated from the following files: