Joos1W Compiler Framework
All Classes Functions Typedefs Pages
semantic::internal::ExprNameWrapper Class Reference

Represents a wrapper around a name that is being resolved. This is a list of either ExprNameWrapper or ast::ExprNodeList. More...

#include <ExprResolver.h>

Public Types

using PrevTy = std::variant< ExprNameWrapper *, ast::ExprNodeList >
 

Public Member Functions

 ExprNameWrapper (Type type, ast::exprnode::MemberName *node, ast::exprnode::MemberAccess *op)
 Build an unresolved wrapper of Type given a name node, represents a name particle represented by "node" of type "type". More...
 
void reclassify (Type type, ast::Decl const *resolution, ast::Type const *typeResolution)
 
void reclassify (Type type, NameResolver::Pkg const *resolution)
 
void verifyInvariants (Type expectedTy) const
 
ExprNameWrapperprevAsWrapper () const
 
ExprNameWrapperprevIfWrapper () const
 
ast::Decl const * prevAsDecl (ExprTypeResolver &TR, NameResolver &NR, SourceRange loc) const
 If the previous value is a wrapper, unwrap the declaration. However, if the previous value is a list of expressions, return the the class representation of the type of the expression. More...
 
Type type () const
 
auto resolution () const
 
auto typeResolution () const
 
void setPrev (std::optional< PrevTy > prev)
 
std::optional< PrevTy > prev () const
 
void dump () const
 
void dump (int indent) const
 
std::string_view type_string () const
 

Public Attributes

ast::exprnode::MemberNamenode
 
ast::exprnode::MemberAccessop
 

Detailed Description

Represents a wrapper around a name that is being resolved. This is a list of either ExprNameWrapper or ast::ExprNodeList.

Definition at line 43 of file ExprResolver.h.

Constructor & Destructor Documentation

◆ ExprNameWrapper()

semantic::internal::ExprNameWrapper::ExprNameWrapper ( Type  type,
ast::exprnode::MemberName node,
ast::exprnode::MemberAccess op 
)
inline

Build an unresolved wrapper of Type given a name node, represents a name particle represented by "node" of type "type".

Parameters
typeThe Java name type of the current particle
nodeThe expression node representing the particle
opThe operator joining the particle to the previous particle. If this is a single name, then op is nullptr.

Definition at line 71 of file ExprResolver.h.

73  : node{node},
74  op{op},
75  type_{type},
76  prev_{std::nullopt},
77  resolution_{std::nullopt} {}

References ExprNameWrapper().

Referenced by ExprNameWrapper().

Member Function Documentation

◆ prevAsDecl()

ast::Decl const * semantic::ExprNameWrapper::prevAsDecl ( ExprTypeResolver TR,
NameResolver NR,
SourceRange  loc 
) const

If the previous value is a wrapper, unwrap the declaration. However, if the previous value is a list of expressions, return the the class representation of the type of the expression.

Parameters
TRThe expression type resolver
NRThe name resolver
Returns
ast::Decl const* Either a decl or a type represented as decl

Definition at line 340 of file ExprResolver.cc.

342  {
343  // Simple case, the previous node is wrapped so we know the decl
344  if(auto p = prevIfWrapper()) return std::get<ast::Decl const*>(p->resolution());
345  // Complex case, the previous node is an expression list
346  ast::ExprNodeList prevList = std::get<ast::ExprNodeList>(prev_.value());
347  auto type = TR.EvalList(prevList, loc);
348  return cast<ast::Decl>(GetTypeAsDecl(type, NR));
349 }
A list of ExprNodes* that can be iterated and concatenated.
Definition: ExprNode.h:60

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