Meta

final case class Meta(scopeTree: ScopeTree, scopeSymbols: Map[EqWrap[Scope], List[Symbol]], symbolScopes: Map[EqWrap[Symbol], Scope], methodArgs: Map[EqWrap[SMethod], List[SVar]], methodRetTypes: Map[EqWrap[SMethod], Type], methodAsts: Map[EqWrap[SMethod], AST], astScopes: Map[EqWrap[AST], Scope], varTypes: Map[EqWrap[SVar], Type])

Metadata - Scope & Symbol State

NOTE: we're not storing symbols in Block, Method, Struct explicitly, since it is causing huge AST-rewrites on updates.

To avoid rewrites, it is possible to use mutable Block, Method, Struct, but we want to avoid it to enable better traceability of mutations.

Value parameters:
astScopes

Scope, AST refers to; { AST -> Scope } -- parent scope for AST

methodArgs

Arguments that belong to a method; { Method -> List[Var] } NOTE: We use List[Var] and NOT a Set to maintain the order Vars were added.

methodAsts

AST, a Symbol references; { Symbol -> AST }

methodRetTypes

Return Type, associated with a method; { Method -> Type }

scopeSymbols

All symbols that belong to a scope; { Scope -> List[Symbol] } NOTE: We use List[Symbol] and NOT a Set to maintain the order Symbols were added.

scopeTree

Scope tree where a child Scope points to a parent Scope (child -> parent)

symbolScopes

Scope a Symbol belongs to; { Symbol -> Scope }

varTypes

Type, assigned to a variable { Var -> Type }. A Type for the variable might be changed, e.g. auto -> long.

Companion:
object
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Value members

Concrete methods

def defineASTScope(ast: AST, scope: Scope): Meta

Defines a scope for an AST

Defines a scope for an AST

def defineBlock(block: SBlock): Meta

Defines a root Scope, not connected to any parent Scope

Defines a root Scope, not connected to any parent Scope

NOTE: it could be multiple Scopes, not connected to the parent, but the use-case for that is not clear.

def defineBlock(block: SBlock, in: Scope): Meta

Defines a Block in the given Scope

Defines a Block in the given Scope

NOTE: Block is not a symbol

def defineBuiltInType(t: SBuiltInType, in: SBlock): Meta

Defines a BuiltInType

Defines a BuiltInType

NOTE: a BuiltInType might be defined only in Block-scope.

def defineMethod(method: SMethod, in: Scope): Meta

Defines a Method in the given Scope

Defines a Method in the given Scope

NOTE: a Method is a symbol as well.

def defineMethodAST(sm: SMethod, ast: AST): Meta

Defines a method AST

Defines a method AST

def defineMethodArg(ms: SMethod, arg: SVar): Meta

Defines a method argument (used to have an ordered list of arguments)

Defines a method argument (used to have an ordered list of arguments)

def defineMethodRetType(sm: SMethod, retType: Type): Meta

Defines a method type

Defines a method type

def defineStruct(struct: SStruct, in: Scope): Meta

Defines a Struct in the given Scope

Defines a Struct in the given Scope

NOTE: a Struct is a symbol as well.

def defineStructField(ss: SStruct, field: SVar): Meta

Defines a field in the Struct

Defines a field in the Struct

def defineVar(v: SVar, in: SBlock): Meta
def defineVarType(v: SVar, t: Type): Meta

Defines a Variable Symbol with the given Type. If the variable is already exists, redefines it.

Defines a Variable Symbol with the given Type. If the variable is already exists, redefines it.

def id(symbol: Symbol): Either[ScopeStateException, String]

Gets the identifier of the symbol

Gets the identifier of the symbol

def methodArgSVars(m: SMethod): Either[Throwable, List[SVar]]

Get Method Arguments Symbols

Get Method Arguments Symbols

def methodArgTypeMap(m: SMethod): Either[Throwable, Map[SVar, Type]]

Gets a Map { SVar -> Type} for the arguments of a Method

Gets a Map { SVar -> Type} for the arguments of a Method

def methodArgTypes(m: SMethod): Either[Throwable, List[Type]]

Get Method Arguments Types

Get Method Arguments Types

def methodAst(m: SMethod): Either[Throwable, AST]

Gets AST for the given method

Gets AST for the given method

def redefineASTScope(oldAst: AST, newAst: AST): Meta

Redefine AST in { AST -> Scope } bindings

Redefine AST in { AST -> Scope } bindings

def resolve(name: String, in: Scope): Either[ScopeStateException, Symbol]

Resolve a symbol in the scope recursively up to the root

Resolve a symbol in the scope recursively up to the root

def resolveMember(name: String, in: Scope): Either[ScopeStateException, Symbol]

Resolves a member of a scope by Name

Resolves a member of a scope by Name

def retTypeFor(m: SMethod): Either[ScopeStateException, Type]

Get a Type for the given Method Symbol (SMethod)

Get a Type for the given Method Symbol (SMethod)

def scopeFor(ast: AST): Either[ScopeStateException, Scope]

Get a Scope for the given AST

Get a Scope for the given AST

def scopeFor(symbol: Symbol): Either[ScopeStateException, Scope]

Get a Scope for the given Symbol

Get a Scope for the given Symbol

def structTypes(sStruct: SStruct): Either[Throwable, Map[String, Type]]

Returns types for the fields of the given struct.

Returns types for the fields of the given struct.

def symbolsFor(s: Scope): List[Symbol]

Gets all symbols in the given scope

Gets all symbols in the given scope

def typeFor(v: SVar): Either[ScopeStateException, Type]

Get a Type for the given Variable Symbol (SVar)

Get a Type for the given Variable Symbol (SVar)

Inherited methods

def productElementNames: Iterator[String]
Inherited from:
Product
def productIterator: Iterator[Any]
Inherited from:
Product