std/jule/sema
Index
fn AnalyzePackage(mut files: []&ast::AST, mut importer: Importer, flags: Flag): (&Package, []build::Log)
fn AnalyzeFile(mut f: &ast::AST, mut importer: Importer, flags: Flag): (&SymTab, []build::Log)
trait Importer
trait Kind
trait Lookup
struct Field
struct Struct
fn FindMethod(mut self, ident: str, statically: bool): &Func
fn FindField(mut self, ident: str): &Field
fn IsImplements(self, t: &Trait): bool
fn HasRefAccessible(self): bool
struct FieldIns
struct StructIns
fn Str(self): str
fn Equal(&self, other: &Type): bool
fn Same(self, s: &StructIns): bool
fn FindMethod(mut self, ident: str, statically: bool): &Func
fn FindField(mut self, ident: str): &FieldIns
struct OperandExpr
struct BinaryExpr
struct UnaryExpr
struct StructArgExpr
struct StructLitExpr
struct AllocStructLitExpr
struct CastingExpr
struct FuncCallExpr
struct SliceExpr
struct IndexingExpr
struct AnonFuncExpr
struct KeyValPairExpr
struct MapExpr
struct SlicingExpr
struct TraitSubIdentExpr
struct StructSubIdentExpr
struct StructStaticIdentExpr
struct ArrayExpr
struct TupleExpr
struct BuiltinPrintCallExpr
struct BuiltinPrintlnCallExpr
struct BuiltinNewCallExpr
struct BuiltinPanicCallExpr
struct ChanRecv
struct ChanSend
struct BuiltinCloseCallExpr
struct BuiltinMakeCallExpr
struct BuiltinAppendCallExpr
struct BuiltinLenCallExpr
struct BuiltinCapCallExpr
struct BuiltinDeleteCallExpr
struct BuiltinCopyCallExpr
struct BuiltinErrorCallExpr
struct SizeofExpr
struct AlignofExpr
struct RuneExpr
struct BackendEmitExpr
struct FreeExpr
struct SymTab
fn SelectPackage(mut self, selector: fn(&ImportInfo): bool): &ImportInfo
fn FindVar(mut self, ident: str, binded: bool): &Var
fn FindTypeAlias(mut self, ident: str, binded: bool): &TypeAlias
fn FindStruct(mut self, ident: str, binded: bool): &Struct
fn FindFunc(mut self, ident: str, binded: bool): &Func
fn FindTrait(mut self, ident: str): &Trait
fn FindEnum(mut self, ident: str): &Enum
fn FindTypeEnum(mut self, ident: str): &TypeEnum
struct Trait
fn Str(self): str
fn Equal(&self, other: &Type): bool
fn FindMethod(mut self, ident: str): &Func
struct EnumItem
fn AutoExpr(self): bool
struct Enum
fn Str(self): str
fn Equal(&self, other: &Type): bool
fn FindItem(mut self, ident: str): &EnumItem
struct TypeEnumItem
struct TypeEnum
fn Str(self): str
fn Equal(&self, other: &Type): bool
fn FindItem(mut self, ident: str): &TypeEnumItem
struct Impl
fn IsTraitImpl(self): bool
fn IsStructImpl(self): bool
struct Scope
struct If
struct Else
struct Conditional
struct InfIter
struct WhileIter
fn IsWhileNext(self): bool
struct RangeIter
struct Continue
struct Break
struct Label
struct Goto
struct Postfix
struct Assign
struct MultiAssign
struct Match
fn IsGenericTypeMatch(self): bool
struct Select
struct Case
struct Fall
struct Ret
struct RetType
struct Param
fn IsSelf(self): bool
fn IsRef(self): bool
struct Func
fn IsVoid(self): bool
fn IsMethod(self): bool
fn IsEntryPoint(self): bool
fn IsInit(self): bool
fn IsAnon(self): bool
fn AnyVar(self): bool
struct ParamIns
fn Str(self): str
struct FuncIns
fn Str(self): str
fn Equal(&self, other: &Type): bool
fn EqualFunc(&self, &f: &FuncIns, responsive: bool): bool
fn Types(mut self): []&Type
fn IsBuiltin(self): bool
fn IsAnon(self): bool
fn Same(self, f: &FuncIns): bool
fn GetKindStr(self, ident: bool): str
struct ReferenceStack
fn Len(self): int
fn At(mut self, i: int): any
fn Push(mut self, mut ref: any)
fn Exist[T](self, t: T): bool
struct Pass
struct ImportInfo
fn SelectPackage(mut self, fn(&ImportInfo): bool): &ImportInfo
fn FindVar(mut self, ident: str, _: bool): &Var
fn FindTypeAlias(mut self, ident: str, _: bool): &TypeAlias
fn FindStruct(mut self, ident: str, _: bool): &Struct
fn FindFunc(mut self, ident: str, _: bool): &Func
fn FindTrait(mut self, ident: str): &Trait
fn FindEnum(mut self, ident: str): &Enum
fn FindTypeEnum(mut self, ident: str): &TypeEnum
struct Package
fn SelectPackage(mut self, fn(&ImportInfo): bool): &ImportInfo
fn FindVar(mut self, ident: str, binded: bool): &Var
fn FindTypeAlias(mut self, ident: str, binded: bool): &TypeAlias
fn FindStruct(mut self, ident: str, binded: bool): &Struct
fn FindFunc(mut self, ident: str, binded: bool): &Func
fn FindTrait(mut self, ident: str): &Trait
fn FindEnum(mut self, ident: str): &Enum
fn FindTypeEnum(mut self, ident: str): &TypeEnum
struct Var
fn IsInitialized(self): bool
fn IsTypeInferred(self): bool
struct FuncPattern
static fn Str(f: &Func): bool
struct Value
fn IsNil(self): bool
fn IsVoid(self): bool
fn IsConst(self): bool
fn GoodOperand(self, mut &other: &Value): bool
struct ValueSym
struct InsGeneric
struct TypeAlias
struct Type
fn Str(self): str
fn Equal(&self, other: &Type): bool
fn Binded(self): bool
fn IsNil(self): bool
fn Void(self): bool
fn ActualKind(mut self): Kind
fn ActualEqual(&self, other: &Type): bool
fn Comparable(self): bool
fn Mutable(self): bool
fn Ordered(self): bool
fn NilCompatible(self): bool
fn GC(self): bool
fn Variadicable(self): bool
fn Prim(mut self): &Prim
fn Chan(mut self): &Chan
fn Sptr(mut self): &Sptr
fn Ptr(mut self): &Ptr
fn Enum(mut self): &Enum
fn TypeEnum(mut self): &TypeEnum
fn Array(mut self): &Array
fn Slice(mut self): &Slice
fn Func(mut self): &FuncIns
fn Struct(mut self): &StructIns
fn Trait(mut self): &Trait
fn Map(mut self): &Map
fn Tuple(mut self): &Tuple
struct TypeSym
struct Prim
fn Str(self): str
fn Equal(&self, other: &Type): bool
fn IsConstraint(self): bool
fn IsI8(self): bool
fn IsI16(self): bool
fn IsI32(self): bool
fn IsI64(self): bool
fn IsU8(self): bool
fn IsU16(self): bool
fn IsU32(self): bool
fn IsU64(self): bool
fn IsF32(self): bool
fn IsF64(self): bool
fn IsInt(self): bool
fn IsUint(self): bool
fn IsUintptr(self): bool
fn IsBool(self): bool
fn IsStr(self): bool
fn IsAny(self): bool
struct Chan
fn Str(self): str
fn Equal(&self, other: &Type): bool
struct Sptr
fn Str(self): str
fn Equal(&self, other: &Type): bool
struct Slice
fn Str(self): str
fn Equal(&self, other: &Type): bool
struct Tuple
fn Str(self): str
fn Equal(&self, other: &Type): bool
struct Map
fn Str(self): str
fn Equal(&self, other: &Type): bool
struct Array
fn Str(self): str
fn Equal(&self, other: &Type): bool
struct Ptr
fn Str(self): str
fn Equal(&self, other: &Type): bool
fn IsUnsafe(self): bool
enum Expr: type
enum Stmt: type
enum CaseOwner: type
enum Flag
AnalyzePackage
fn AnalyzePackage(mut files: []&ast::AST, mut importer: Importer, flags: Flag): (&Package, []build::Log)
Builds symbol table of package's ASTs. Returns nil if files is nil. Returns nil if pwd is empty. Returns nil if pstd is empty. Accepts current working directory is pwd.
Parameters:
files: abstract syntax trees of files
importer: importer that used for use declarations
Dependent Parameters:
working-directory: uses working directory path provided by build
std-path: uses standard library path provided by build
Risks:
You can pass nil to importer, but panics if importer is nil and
semantic analyzer used nil importer.
AnalyzeFile
fn AnalyzeFile(mut f: &ast::AST, mut importer: Importer, flags: Flag): (&SymTab, []build::Log)
Builds symbol table of AST. Returns nil if f is nil. Returns nil if pwd is empty. Returns nil if pstd is empty. Accepts current working directory is pwd.
Parameters:
f: file's abstract syntax tree
importer: importer that used for use declarations
Dependent Parameters:
working-directory: uses working directory path provided by build
std-path: uses standard library path provided by build
Risks:
You can pass nil to importer, but panics if importer is nil and
semantic analyzer used nil importer.
Importer
trait Importer {
// Set current module path.
// Path should be valid directory.
// Set to empty string if module is not exist.
fn SetModPath(mut self, path: str)
// Returns current module path.
// Path should be valid directory.
// Returns empty string if module is not exist.
fn GetModPath(self): str
// Returns module path by identity.
fn ModById(self, id: int): str
// Returns &ImportInfo by path.
// This function accepted as returns already imported and checked package.
// If returns not-nil value, will be used instead of ImportPackage
// if possible and package content is not checked by Sema.
fn GetImport(mut self, path: str): &ImportInfo
// Path is the directory path of package to import.
// Should return abstract syntax tree of package files.
// Logs accepts as error.
// Updated module to package's module if exist when updateMod is true.
fn ImportPackage(mut self, path: str, updateMod: bool): ([]&ast::AST, []build::Log)
// Invoked after the package is imported.
// Sets module identitity of imported package to current module.
fn Imported(mut self, mut &ImportInfo)
}
Importer. Used by semantic analysis to import use declarations. The default importer implementation is highly recommended. 3rd-party importer implementations may cause unpredictable issues.
Kind
trait Kind {
fn Str(self): str
fn Equal(&self, other: &Type): bool
}
Kind of type declaration.
Lookup
trait Lookup {
// Select imported package.
// Returns nil if did not found any match.
fn SelectPackage(mut self, selector: fn(&ImportInfo): bool): &ImportInfo
// Find variable by identifier and binded state.
// Returns nil if did not found any match.
fn FindVar(mut self, ident: str, binded: bool): &Var
// Find type alias by identifier and binded state.
// Returns nil if did not found any match.
fn FindTypeAlias(mut self, ident: str, binded: bool): &TypeAlias
// Find structure by identifier and binded state.
// Returns nil if did not found any match.
fn FindStruct(mut self, ident: str, binded: bool): &Struct
// Find function by identifier and binded state.
// Returns nil if did not found any match.
fn FindFunc(mut self, ident: str, binded: bool): &Func
// Find trait by identifier.
// Returns nil if did not found any match.
fn FindTrait(mut self, ident: str): &Trait
// Find enum by identifier.
// Returns nil if did not found any match.
fn FindEnum(mut self, ident: str): &Enum
// Find type enum by identifier.
// Returns nil if did not found any match.
fn FindTypeEnum(mut self, ident: str): &TypeEnum
}
Generic behavior of lookupable types. Typically it is a scope like global scope, function scope or etc.
Field
struct Field {
Owner: &Struct
Token: &token::Token
Public: bool
Mutable: bool // Interior mutability.
Ident: str
TypeSym: &TypeSym
Default: &ast::Expr // Nil if not given.
}
Field.
Struct
struct Struct {
// This structure depended to these structures, except binded ones.
// Only stores plain identifier references such as A, B, and MyStruct.
// Not includes non-plain identifier references such as *A, &B, and []MyStruct.
//
// As far as tested, safe to store in structure declaration rather than instances.
// This collection applied for all instances.
Depends: []&Struct
Token: &token::Token
Ident: str
Fields: []&Field
Methods: []&Func
Public: bool
Binded: bool
Directives: []&ast::Directive
Generics: []&ast::Generic
Implements: []&Trait
// Structure instances for each unique type combination of structure.
// Nil if structure is never used.
Instances: []&StructIns
// NOTE: contains filtered hidden or unexported fields
}
Structure.
FindMethod
fn FindMethod(mut self, ident: str, statically: bool): &Func
Returns method by identifier. Returns nil if not exist any method in this identifier.
FindField
fn FindField(mut self, ident: str): &Field
Returns field by identifier. Returns nil if not exist any field in this identifier.
IsImplements
fn IsImplements(self, t: &Trait): bool
Reports whether structure implements given trait.
HasRefAccessible
fn HasRefAccessible(self): bool
Reports whether structure has only reference-type-accessible defines.
FieldIns
struct FieldIns {
Owner: &StructIns
Decl: &Field
Type: &Type
Default: &Value // Nil if not given.
}
Field instance.
StructIns
struct StructIns {
Source: &Type // See developer reference (9).
Checked: bool
Decl: &Struct
Generics: []&InsGeneric
Fields: []&FieldIns
Methods: []&Func
Mutable: bool // This structure has mutable defines.
Comparable: bool
Refers: &ReferenceStack
}
Structure instance.
Implemented Traits
Kind
Str
fn Str(self): str
Implement: Kind Returns Struct's type kind as string.
Equal
fn Equal(&self, other: &Type): bool
Reports whether types are same.
Same
fn Same(self, s: &StructIns): bool
Reports whether instances are same. Returns true if declarations and generics are same.
FindMethod
fn FindMethod(mut self, ident: str, statically: bool): &Func
Returns method by identifier. Returns nil if not exist any method in this identifier.
FindField
fn FindField(mut self, ident: str): &FieldIns
Returns field by identifier. Returns nil if not exist any field in this identifier.
OperandExpr
struct OperandExpr {
Type: &Type
Model: Expr
}
Operand expression model.
BinaryExpr
struct BinaryExpr {
Left: &OperandExpr
Right: &OperandExpr
Op: &token::Token
}
Binary operation expression model.
UnaryExpr
struct UnaryExpr {
Expr: &Value
Op: &token::Token
}
Unary operation expression model.
StructArgExpr
struct StructArgExpr {
Token: &token::Token
Field: &FieldIns
Expr: &Value
}
Structure field argument expression model for constructors. For example: &MyStruct{10, false, "-"}
StructLitExpr
struct StructLitExpr {
Strct: &StructIns
Args: []&StructArgExpr
}
Structure literal.
AllocStructLitExpr
struct AllocStructLitExpr {
Lit: &StructLitExpr
}
Heap allocated structure litral expression. For example: &MyStruct{}
CastingExpr
struct CastingExpr {
Token: &token::Token
Expr: &Value
Type: &Type
}
Casting expression model. For example: (int)(my_float)
FuncCallExpr
struct FuncCallExpr {
Token: &token::Token
Func: &FuncIns
IsCo: bool
Expr: Expr
Args: []Expr
Except: &Scope
Assigned: bool
}
Function call expression model.
SliceExpr
struct SliceExpr {
ElemType: &Type
Elems: []&Value
}
Slice expression model. For example: [1, 2, 3, 4, 5, 6, 8, 9, 10]
IndexingExpr
struct IndexingExpr {
Token: &token::Token
Expr: &Value
Index: &Value
}
Indexing expression model. For example: slice[index]
AnonFuncExpr
struct AnonFuncExpr {
Captured: []&Var
Func: &FuncIns
Global: bool
}
Anonymous function expression model.
KeyValPairExpr
struct KeyValPairExpr {
Key: Expr
Val: Expr
}
Key-value expression pair model.
MapExpr
struct MapExpr {
Kind: &Map
Entries: []&KeyValPairExpr
}
Map expression model. For example; {0: false, 1: true}
SlicingExpr
struct SlicingExpr {
Token: &token::Token
// Expression to slicing.
Expr: &Value
// Left index expression.
// Nil integer if expression have not left index.
Left: Expr
// Right index expression.
// Nil if expression have not right index.
Right: Expr
// Cap index expression.
// Nil if expression have not cap index.
Cap: Expr
}
Slicing expression model. For example: mySlice[2:len(mySlice)-5]
TraitSubIdentExpr
struct TraitSubIdentExpr {
Token: &token::Token
Expr: Expr
Method: &Func
Trt: &Trait
}
Trait sub-ident expression model. For example: myTrait.subIdent
StructSubIdentExpr
struct StructSubIdentExpr {
Token: &token::Token
Expr: &Value
Method: &FuncIns
Field: &FieldIns
Owner: &StructIns
}
Structure sub-ident expression model. For example: myStruct.subIdent
StructStaticIdentExpr
struct StructStaticIdentExpr {
Structure: &StructIns
Expr: Expr
Method: &FuncIns
}
Structure static ident expression model. For example: MyStruct.mySubIdent
ArrayExpr
struct ArrayExpr {
Kind: &Array
Elems: []&Value
}
Array expression model. If array filled, elems field holds 2 data. First data is expression, second is nil, kind of mark to that array filled.
TupleExpr
struct TupleExpr {
Values: []&Value
}
Tuple expression model.
BuiltinPrintCallExpr
struct BuiltinPrintCallExpr {
Expr: &Value
}
Expression Model: for built-in print function calls.
BuiltinPrintlnCallExpr
struct BuiltinPrintlnCallExpr {
Expr: &Value
}
Expression Model: for built-in println function calls.
BuiltinNewCallExpr
struct BuiltinNewCallExpr {
Type: &Type // Element type of smart pointer.
Init: Expr // Nil for not initialized.
}
Expression Model: for built-in new function calls.
BuiltinPanicCallExpr
struct BuiltinPanicCallExpr {
Token: &token::Token
Expr: Expr
}
Expression Model: for built-in panic function calls.
ChanRecv
struct ChanRecv {
Token: &token::Token
Expr: &Value
}
Expression model: for channel receive.
ChanSend
struct ChanSend {
Token: &token::Token
Chan: &Value
Data: &Value
}
Expression mode: for channel send.
BuiltinCloseCallExpr
struct BuiltinCloseCallExpr {
Token: &token::Token
Chan: &Value
}
Expression Model: for built-in close function calls.
BuiltinMakeCallExpr
struct BuiltinMakeCallExpr {
Type: &Type
Len: Expr
Cap: Expr
}
Expression Model: for built-in make function calls. If Type is slice, the Len and Cap fields may be meaningful. If Type is channel, the buffer size specified in the Cap field if exist. The Len field is undefined for channel types.
BuiltinAppendCallExpr
struct BuiltinAppendCallExpr {
Dest: &Value // Type is always slice.
Elements: &Value // Type is always slice or string, no chance for variadic.
}
Expression Model: for built-in append function calls.
BuiltinLenCallExpr
struct BuiltinLenCallExpr {
Expr: &Value
}
Expression Model: for built-in len function calls.
BuiltinCapCallExpr
struct BuiltinCapCallExpr {
Expr: &Value
}
Expression Model: for built-in cap function calls.
BuiltinDeleteCallExpr
struct BuiltinDeleteCallExpr {
Dest: &Value
Key: &Value
}
Expression Model: for built-in delete function calls.
BuiltinCopyCallExpr
struct BuiltinCopyCallExpr {
Dest: &Value
Src: &Value
}
Expression Model: for built-in copy function calls.
BuiltinErrorCallExpr
struct BuiltinErrorCallExpr {
Func: &FuncIns
Err: &Value
}
Expression Model: for built-in error function calls.
SizeofExpr
struct SizeofExpr {
Expr: Expr
}
Expression Model: for sizeof expressions. For example, in C++: sizeof(int)
AlignofExpr
struct AlignofExpr {
Expr: Expr
}
Expression Model: for alignof expressions. For example, in C++: alignof(int)
RuneExpr
struct RuneExpr {
Code: rune
}
Rune literal expression model. For example: 'a'
BackendEmitExpr
struct BackendEmitExpr {
Code: str
// Expression Model: for expression or type emit to backend from Jule source code.
Exprs: []Expr
}
Expression Model: for inline code emit to backend.
FreeExpr
struct FreeExpr {
Expr: Expr
}
Expression Model: for free calls. Function provided by: "std/mem"
SymTab
struct SymTab {
File: &token::Fileset // Owner fileset of this symbol table.
Passes: []Pass // All passed flags with jule:pass directive.
Imports: []&ImportInfo // Imported packages.
Vars: []&Var // Variables.
TypeAliases: []&TypeAlias // Type aliases.
Structs: []&Struct // Structures.
Funcs: []&Func // Functions.
Traits: []&Trait // Traits.
Enums: []&Enum // Enums.
TypeEnums: []&TypeEnum // Type enums.
Impls: []&Impl // Implementations.
}
Symbol table. Builds by semantic analyzer.
Implemented Traits
Lookup
SelectPackage
fn SelectPackage(mut self, selector: fn(&ImportInfo): bool): &ImportInfo
Returns imported package by selector. Returns nil if selector returns false for all packages. Returns nil if selector is nil.
FindVar
fn FindVar(mut self, ident: str, binded: bool): &Var
Returns variable by identifier and binded state. Returns nil if refenrece not exist any variable in this identifier.
FindTypeAlias
fn FindTypeAlias(mut self, ident: str, binded: bool): &TypeAlias
Returns type alias by identifier and binded state. Returns nil if not exist any type alias in this identifier.
FindStruct
fn FindStruct(mut self, ident: str, binded: bool): &Struct
Returns struct by identifier and binded state. Returns nil if not exist any struct in this identifier.
FindFunc
fn FindFunc(mut self, ident: str, binded: bool): &Func
Returns function by identifier and binded state. Returns nil if not exist any function in this identifier.
FindTrait
fn FindTrait(mut self, ident: str): &Trait
Returns trait by identifier. Returns nil if not exist any trait in this identifier.
FindEnum
fn FindEnum(mut self, ident: str): &Enum
Returns enum by identifier. Returns nil if not exist any enum in this identifier.
FindTypeEnum
fn FindTypeEnum(mut self, ident: str): &TypeEnum
Returns type enum by identifier. Returns nil if not exist any type enum in this identifier.
Trait
struct Trait {
Token: &token::Token
Ident: str
Public: bool
Inherits: []&TypeSym
Methods: []&Func
Implemented: []&Struct
}
Trait.
Implemented Traits
Kind
Str
fn Str(self): str
Implement: Kind Returns Trait's identifier.
Equal
fn Equal(&self, other: &Type): bool
Reports whether types are same.
FindMethod
fn FindMethod(mut self, ident: str): &Func
Returns method by identifier. Returns nil if not exist any method in this identifier.
EnumItem
struct EnumItem {
Token: &token::Token
Ident: str
ValueSym: &ValueSym
}
Enum item.
AutoExpr
fn AutoExpr(self): bool
Reports whether item has auto expression.
Enum
struct Enum {
Token: &token::Token
Public: bool
Ident: str
TypeSym: &TypeSym
Items: []&EnumItem
}
Enum.
Implemented Traits
Kind
Str
fn Str(self): str
Implement: Kind Returns Enum's identifier.
Equal
fn Equal(&self, other: &Type): bool
Reports whether types are same.
FindItem
fn FindItem(mut self, ident: str): &EnumItem
Returns item by identifier. Returns nil if not exist any item in this identifier.
TypeEnumItem
struct TypeEnumItem {
Token: &token::Token
Ident: str
TypeSym: &TypeSym
}
TypeEnum item.
TypeEnum
struct TypeEnum {
Token: &token::Token
Public: bool
Ident: str
Items: []&TypeEnumItem
}
TypeEnum.
Implemented Traits
Kind
Str
fn Str(self): str
Implement: Kind Returns TypeEnum's identifier.
Equal
fn Equal(&self, other: &Type): bool
Reports whether types are same.
FindItem
fn FindItem(mut self, ident: str): &TypeEnumItem
Returns item by identifier. Returns nil if not exist any item in this identifier.
Impl
struct Impl {
// Equivalent to ast::Impl's base field.
Base: &ast::Type
// Equivalent to ast::Impl's dest field.
Dest: &ast::Type
// Equivalent to ast::Impl's methods field.
Methods: []&Func
}
Implementation.
IsTraitImpl
fn IsTraitImpl(self): bool
Reports whether implementation type is trait to structure.
IsStructImpl
fn IsStructImpl(self): bool
Reports whether implementation type is append to destination structure.
Scope
struct Scope {
Parent: &Scope
Unsafety: bool
Deferred: bool
Stmts: []Stmt
// Data of the child scope starting from the root scope.
// For the root scope, counting starts from 0. So the root scope will be 0.
// It increases by one for each child scope.
ChildIndex: int
// If the scope is a child scope,
// it contains the data of the statement in which it was appear.
StmtIndex: int
}
Scope.
If
struct If {
Expr: Expr
Scope: &Scope
}
Chain conditional node.
Else
struct Else {
Scope: &Scope
}
Default scope of conditional chain.
Conditional
struct Conditional {
Elifs: []&If // First not is root condition.
Default: &Else
}
Conditional chain.
InfIter
struct InfIter {
Scope: &Scope // See developer reference (8).
}
Infinity iteration.
WhileIter
struct WhileIter {
Scope: &Scope // See developer reference (8).
Expr: Expr // Can be nil if iteration is while-next kind.
Next: Stmt // Nil if iteration is not while-next kind.
}
While iteration.
IsWhileNext
fn IsWhileNext(self): bool
Reports whether iteration is while-next kind.
RangeIter
struct RangeIter {
Scope: &Scope // See developer reference (8).
Expr: &Value
ExprToken: &token::Token
KeyA: &Var
KeyB: &Var
}
Range iteration.
Continue
struct Continue {
It: uintptr
}
Continue statement.
Break
struct Break {
It: uintptr
Match: uintptr
Select: uintptr
}
Break statement.
Label
struct Label {
Ident: str
Scope: &Scope // Owner scope.
Index: int // Index of statement.
}
Label.
Goto
struct Goto {
Ident: str
Token: &token::Token
Label: &Label
Scope: &Scope // Owner scope.
Index: int // Index of statement.
}
Goto statement.
Postfix
struct Postfix {
Expr: Expr
Op: str
}
Postfix assignment.
Assign
struct Assign {
Left: &OperandExpr
Right: &OperandExpr
Op: &token::Token
}
Assignment.
MultiAssign
struct MultiAssign {
Decls: []&Var
Left: []&Value // Nil Model:s represents ignored expressions.
Right: Expr
Op: &token::Token
}
Multi-declarative assignment.
Match
struct Match {
Scope: &Scope // Owner scope. See developer reference (8).
Expr: &Value
TypeMatch: bool
Comptime: bool
Cases: []&Case
Default: &Case
}
Match-Case.
IsGenericTypeMatch
fn IsGenericTypeMatch(self): bool
Reports whether match is type-match for generic type.
Select
struct Select {
Scope: &Scope // Owner scope. See developer reference (8).
Cases: []&Case
Default: &Case
}
Select-Case.
Case
struct Case {
Owner: CaseOwner
Scope: &Scope
Exprs: []&Value
Next: &Case
}
Match-Case case.
Fall
struct Fall {
DestCase: uintptr
}
Fall statement.
Ret
struct Ret {
Func: &FuncIns
Expr: Expr
}
Return statement.
RetType
struct RetType {
TypeSym: &TypeSym
Idents: []&token::Token
}
Return type.
Param
struct Param {
Token: &token::Token
Mutable: bool
Variadic: bool
Reference: bool
TypeSym: &TypeSym
Ident: str
}
Parameter.
IsSelf
fn IsSelf(self): bool
Reports whether parameter is self (receiver) parameter.
IsRef
fn IsRef(self): bool
Reports whether self (receiver) parameter is reference.
Func
struct Func {
// Token of function declaration.
// It may be nil if function is created by a deferred scope.
Token: &token::Token
Global: bool
Unsafety: bool
Public: bool
Binded: bool
Statically: bool
Exceptional: bool
HasDefer: bool // Whether function has at least one deferred scope.
Ident: str
Directives: []&ast::Directive
// Scope is the scope of function, aka body.
// If this function is created by a deferred scope, the Scope.Deferred will be true.
// So it means this function is represents a deferred scope function.
// It may be a closure.
Scope: &ast::ScopeTree
Generics: []&ast::Generic
Result: &RetType
Params: []&Param
Owner: &Struct
// Function instances for each unique type combination of function call.
// Nil if function is never used.
Instances: []&FuncIns
// NOTE: contains filtered hidden or unexported fields
}
Function.
IsVoid
fn IsVoid(self): bool
Reports whether return type is void.
IsMethod
fn IsMethod(self): bool
Reports whether function is method.
IsEntryPoint
fn IsEntryPoint(self): bool
Reports whether function is entry point.
IsInit
fn IsInit(self): bool
Reports whether function is initializer function.
IsAnon
fn IsAnon(self): bool
Reports whether function is anonymous function.
AnyVar
fn AnyVar(self): bool
Reports whether function has return variable(s).
ParamIns
struct ParamIns {
Decl: &Param
Type: &Type
}
Parameter instance.
Str
fn Str(self): str
Implement: Kind Returns ParamIns's type kind as string.
FuncIns
struct FuncIns {
Owner: &StructIns
Decl: &Func
Generics: []&InsGeneric
Params: []&ParamIns
Result: &Type
Scope: &Scope
Refers: &ReferenceStack
Anon: bool
AsAnon: bool // Whether this function instance used as anonymous function.
CalledCo: bool // Whether this function instance used for concurrent call.
// NOTE: contains filtered hidden or unexported fields
}
Function instance.
Implemented Traits
Kind
Str
fn Str(self): str
Implement: Kind Returns function's type kind as string.
Equal
fn Equal(&self, other: &Type): bool
Reports whether types are same.
EqualFunc
fn EqualFunc(&self, &f: &FuncIns, responsive: bool): bool
Reports whether functions are equal. If the responsive is true, checks by responsiveness of functions. See: https://manual.jule.dev/responsiveness/mutability
Types
fn Types(mut self): []&Type
Returns all types of result. Returns nil if result is nil. Returns mutable slice if returns internal slice.
IsBuiltin
fn IsBuiltin(self): bool
Reports whether instance is built-in.
IsAnon
fn IsAnon(self): bool
Reports whether instance is anonymous function.
Same
fn Same(self, f: &FuncIns): bool
Reports whether instances are same. Returns true if declarations and generics are same.
GetKindStr
fn GetKindStr(self, ident: bool): str
Returns kind string of function instance. Appends identifier to kind of this instance. Does not appends identifier of this instance to kind if self.Decl is nil.
ReferenceStack
struct ReferenceStack {
// NOTE: contains filtered hidden or unexported fields
}
Stack for symbol references. It used by Sema to store necessary references.
List of necessary references;
- &FuncIns
- &StructIns
- &Trait
- &Var -> Only global ones.
Len
fn Len(self): int
Returns count of references.
At
fn At(mut self, i: int): any
Returns reference by index.
Push
fn Push(mut self, mut ref: any)
Push new reference to stack.
Exist
fn Exist[T](self, t: T): bool
Reports whether reference is exist.
Pass
struct Pass {
Token: &token::Token
Text: str
}
Directive pass.
ImportInfo
struct ImportInfo {
// Declaration.
Decl: &ast::Use
// Absolute path.
Path: str
// Use declaration path string.
// Quotes are not included.
LinkPath: str
// Package alias identifier.
Alias: str
// True if imported with Importer.GetImport function.
Duplicate: bool
// Is binded use declaration.
Binded: bool
// Is standard library package.
Std: bool
// Nil if package is cpp header.
Package: &Package
// Module identity.
ModId: int
}
Import information. Represents imported package by use declaration.
Implemented Traits
Lookup
SelectPackage
fn SelectPackage(mut self, fn(&ImportInfo): bool): &ImportInfo
Returns always nil.
FindVar
fn FindVar(mut self, ident: str, _: bool): &Var
Returns variable by identifier and binded state. Returns nil if not exist any variable in this identifier.
Lookups by import way such as identifier selection. Just lookups non-binded defines.
FindTypeAlias
fn FindTypeAlias(mut self, ident: str, _: bool): &TypeAlias
Returns type alias by identifier. Returns nil if not exist any type alias in this identifier.
Lookups by import way such as identifier selection. Just lookups non-binded defines.
FindStruct
fn FindStruct(mut self, ident: str, _: bool): &Struct
Returns struct by identifier and binded state. Returns nil if not exist any struct in this identifier.
Lookups by import way such as identifier selection. Just lookups non-binded defines.
FindFunc
fn FindFunc(mut self, ident: str, _: bool): &Func
Returns function by identifier and binded state. Returns nil if not exist any function in this identifier.
Lookups by import way such as identifier selection. Just lookups non-binded defines.
FindTrait
fn FindTrait(mut self, ident: str): &Trait
Returns trait by identifier. Returns nil if not exist any trait in this identifier.
Lookups by import way such as identifier selection.
FindEnum
fn FindEnum(mut self, ident: str): &Enum
Returns enum by identifier. Returns nil if not exist any enum in this identifier.
Lookups by import way such as identifier selection.
FindTypeEnum
fn FindTypeEnum(mut self, ident: str): &TypeEnum
Returns type enum by identifier. Returns nil if not exist any type enum in this identifier.
Lookups by import way such as identifier selection.
Package
struct Package {
// Symbol table for each package's file.
Files: []&SymTab
}
Package.
Implemented Traits
Lookup
SelectPackage
fn SelectPackage(mut self, fn(&ImportInfo): bool): &ImportInfo
Returns always nil.
FindVar
fn FindVar(mut self, ident: str, binded: bool): &Var
Returns variable by identifier and binded state. Returns nil if not exist any variable in this identifier.
FindTypeAlias
fn FindTypeAlias(mut self, ident: str, binded: bool): &TypeAlias
Returns type alias by identifier and binded state. Returns nil if not exist any type alias in this identifier.
FindStruct
fn FindStruct(mut self, ident: str, binded: bool): &Struct
Returns struct by identifier and binded state. Returns nil if not exist any struct in this identifier.
FindFunc
fn FindFunc(mut self, ident: str, binded: bool): &Func
Returns function by identifier and binded state. Returns nil if not exist any function in this identifier.
FindTrait
fn FindTrait(mut self, ident: str): &Trait
Returns trait by identifier. Returns nil if not exist any trait in this identifier.
FindEnum
fn FindEnum(mut self, ident: str): &Enum
Returns enum by identifier. Returns nil if not exist any enum in this identifier.
FindTypeEnum
fn FindTypeEnum(mut self, ident: str): &TypeEnum
Returns type enum by identifier. Returns nil if not exist any type enum in this identifier.
Var
struct Var {
Scope: &Scope
Token: &token::Token
Ident: str
Binded: bool
Constant: bool
Mutable: bool
Public: bool
Used: bool
Statically: bool
Reference: bool
Checked: bool
TypeSym: &TypeSym
ValueSym: &ValueSym
Refers: &ReferenceStack
Directives: []&ast::Directive
// The -2 means this variable is not one of the return variables.
// The -1 means this variable is just the single return variable one.
// The 0..n means this variable is the nth variable of the return variables.
RetOrder: int = -2
// This variable depended to these variables for initialization expression.
// Nil if not global variable.
Depends: []&Var
}
Variable.
IsInitialized
fn IsInitialized(self): bool
Reports whether variable is initialized explicitly.
IsTypeInferred
fn IsTypeInferred(self): bool
Reports whether variable is type inferred.
FuncPattern
struct FuncPattern{}
Pattern checker for functions and methods.
Str
static fn Str(f: &Func): bool
Reports whether function is the reserved Str function.
Value
struct Value {
Type: &Type
Mutable: bool
Reference: bool
Lvalue: bool
IsRune: bool
Model: Expr
// True if kind is declaration such as:
// - &Enum
// - &Struct
// - int type
// - bool type
Decl: bool
// Constant expression data.
Constant: &constant::Const
// NOTE: contains filtered hidden or unexported fields
}
Value.
IsNil
fn IsNil(self): bool
Reports whether Value is nil literal.
IsVoid
fn IsVoid(self): bool
Reports whether Value is void.
IsConst
fn IsConst(self): bool
Reports whether Value is constant expression.
GoodOperand
fn GoodOperand(self, mut &other: &Value): bool
See developer reference (9.2). Reports left and right operand is good order. If reports false, left and right operand should be swapped. Accepts itself as left operand.
ValueSym
struct ValueSym {
Expr: &ast::Expr
Value: &Value
}
Value.
InsGeneric
struct InsGeneric {
Type: &Type
Constraint: []&Type
}
Generic type for instance types.
TypeAlias
struct TypeAlias {
Scope: &ast::ScopeTree
Strict: bool
Public: bool
Binded: bool
Used: bool
Generic: bool
Token: &token::Token
Ident: str
TypeSym: &TypeSym
Generics: []&TypeAlias // See developer reference (1).
}
Type alias.
Type
struct Type {
Generic: bool
Variadic: bool
Kind: Kind
}
Evaluated type declaration.
Implemented Traits
Kind
Str
fn Str(self): str
Returns kind as string.
Equal
fn Equal(&self, other: &Type): bool
Reports whether types are same.
Binded
fn Binded(self): bool
Reports whether type is binded kind.
IsNil
fn IsNil(self): bool
Reports whether kind is "nil".
Void
fn Void(self): bool
Reports whether actual kind is "void".
ActualKind
fn ActualKind(mut self): Kind
Returns actual kind of the type, so returns the root type. If kind is a struct, which is implemented by the type statement, see developer reference (9) for details, returns the actual kind of the source type of the struct.
ActualEqual
fn ActualEqual(&self, other: &Type): bool
Reports whether actual kinds are equal.
Comparable
fn Comparable(self): bool
Reports whether actual kind is comparable.
Mutable
fn Mutable(self): bool
Reports whether actual kind is mutable.
Ordered
fn Ordered(self): bool
Reports whether actual kind supports ordered constraint.
NilCompatible
fn NilCompatible(self): bool
Reports whether actual kind is nil compatible.
GC
fn GC(self): bool
Reports whether actual kind performs garbage collection.
Variadicable
fn Variadicable(self): bool
Reports whether actual kind is variadicable.
Prim
fn Prim(mut self): &Prim
Returns primitive type if actual kind is primitive type, nil if not.
Chan
fn Chan(mut self): &Chan
Returns channel type if actual kind is channel, nil if not.
Sptr
fn Sptr(mut self): &Sptr
Returns reference type if actual kind is smart pointer, nil if not.
Ptr
fn Ptr(mut self): &Ptr
Returns pointer type if actual kind is pointer, nil if not.
Enum
fn Enum(mut self): &Enum
Returns enum type if actual kind is enum, nil if not.
TypeEnum
fn TypeEnum(mut self): &TypeEnum
Returns type enum if actual kind is type enum, nil if not.
Array
fn Array(mut self): &Array
Returns array type if actual kind is array, nil if not.
Slice
fn Slice(mut self): &Slice
Returns slice type if actual kind is slice, nil if not.
Func
fn Func(mut self): &FuncIns
Returns function type if actual kind is function, nil if not.
Struct
fn Struct(mut self): &StructIns
Returns struct type if actual kind is structure, nil if not.
Trait
fn Trait(mut self): &Trait
Returns trait type if actual kind is trait, nil if not.
Map
fn Map(mut self): &Map
Returns map type if actual kind is map, nil if not.
Tuple
fn Tuple(mut self): &Tuple
Returns tuple type if actual kind is tuple, nil if not.
TypeSym
struct TypeSym {
Decl: &ast::Type // Never changed by semantic analyzer.
Type: &Type
}
Type.
Prim
struct Prim {
Kind: str
}
Primitive type.
Implemented Traits
Kind
Str
fn Str(self): str
Returns kind.
Equal
fn Equal(&self, other: &Type): bool
Reports whether types are same.
IsConstraint
fn IsConstraint(self): bool
Reports whether type is built-in constraint.
IsI8
fn IsI8(self): bool
Reports whether type is primitive i8.
IsI16
fn IsI16(self): bool
Reports whether type is primitive i16.
IsI32
fn IsI32(self): bool
Reports whether type is primitive i32.
IsI64
fn IsI64(self): bool
Reports whether type is primitive i64.
IsU8
fn IsU8(self): bool
Reports whether type is primitive u8.
IsU16
fn IsU16(self): bool
Reports whether type is primitive u16.
IsU32
fn IsU32(self): bool
Reports whether type is primitive u32.
IsU64
fn IsU64(self): bool
Reports whether type is primitive u64.
IsF32
fn IsF32(self): bool
Reports whether type is primitive f32.
IsF64
fn IsF64(self): bool
Reports whether type is primitive f64.
IsInt
fn IsInt(self): bool
Reports whether type is primitive int.
IsUint
fn IsUint(self): bool
Reports whether type is primitive uint.
IsUintptr
fn IsUintptr(self): bool
Reports whether type is primitive uintptr.
IsBool
fn IsBool(self): bool
Reports whether type is primitive bool.
IsStr
fn IsStr(self): bool
Reports whether type is primitive str.
IsAny
fn IsAny(self): bool
Reports whether type is primitive any.
Chan
struct Chan {
Recv: bool
Send: bool
Elem: &Type
}
Channel type.
Implemented Traits
Kind
Str
fn Str(self): str
Returns smart pointer kind as string.
Equal
fn Equal(&self, other: &Type): bool
Reports whether types are same.
Sptr
struct Sptr {
Elem: &Type
}
Smart pointer.
Implemented Traits
Kind
Str
fn Str(self): str
Returns smart pointer kind as string.
Equal
fn Equal(&self, other: &Type): bool
Reports whether types are same.
Slice
struct Slice {
Elem: &Type
}
Slice type.
Implemented Traits
Kind
Str
fn Str(self): str
Returns slice kind as string.
Equal
fn Equal(&self, other: &Type): bool
Reports whether types are same.
Tuple
struct Tuple {
Types: []&Type
}
Tuple type.
Implemented Traits
Kind
Str
fn Str(self): str
Returns tuple kind as string.
Equal
fn Equal(&self, other: &Type): bool
Reports whether types are same.
Map
struct Map {
Key: &Type
Val: &Type
}
Map type.
Implemented Traits
Kind
Str
fn Str(self): str
Returns map kind as string.
Equal
fn Equal(&self, other: &Type): bool
Reports whether types are same.
Array
struct Array {
Auto: bool // Auto-sized array.
N: int
Elem: &Type
}
Array type.
Implemented Traits
Kind
Str
fn Str(self): str
Returns array kind as string.
Equal
fn Equal(&self, other: &Type): bool
Reports whether types are same.
Ptr
struct Ptr {
Elem: &Type
}
Pointer type.
Implemented Traits
Kind
Str
fn Str(self): str
Returns pointer kind as string.
Equal
fn Equal(&self, other: &Type): bool
Reports whether types are same.
IsUnsafe
fn IsUnsafe(self): bool
Reports whether pointer is unsafe pointer (*unsafe).
Expr
enum Expr: type {
&Type,
&constant::Const,
&Var,
&FuncIns,
&StructIns,
&OperandExpr,
&BinaryExpr,
&UnaryExpr,
&StructArgExpr,
&StructLitExpr,
&AllocStructLitExpr,
&CastingExpr,
&FuncCallExpr,
&SliceExpr,
&IndexingExpr,
&AnonFuncExpr,
&KeyValPairExpr,
&MapExpr,
&SlicingExpr,
&TraitSubIdentExpr,
&StructSubIdentExpr,
&StructStaticIdentExpr,
&ArrayExpr,
&TupleExpr,
&BuiltinPrintCallExpr,
&BuiltinPrintlnCallExpr,
&BuiltinNewCallExpr,
&BuiltinPanicCallExpr,
&BuiltinMakeCallExpr,
&BuiltinAppendCallExpr,
&BuiltinCopyCallExpr,
&BuiltinLenCallExpr,
&BuiltinCapCallExpr,
&BuiltinDeleteCallExpr,
&BuiltinErrorCallExpr,
&SizeofExpr,
&AlignofExpr,
&RuneExpr,
&BackendEmitExpr,
&FreeExpr,
&ChanRecv,
&ChanSend,
&BuiltinCloseCallExpr,
}
Expression model.
Stmt
enum Stmt: type {
&Scope,
&Var,
&Value,
&Conditional,
&InfIter,
&WhileIter,
&RangeIter,
&Continue,
&Label,
&Goto,
&Postfix,
&Assign,
&MultiAssign,
&Match,
&Fall,
&Break,
&Ret,
&Select,
}
Statement type.
CaseOwner
enum CaseOwner: type {
&Match,
&Select,
}
Valid owner types for Case.
Flag
enum Flag {
Default: 0, // Default semantic analysis of Jule.
Shadowing: 1 << 0, // Default + enable shadowing.
References: 1 << 1, // Default + enable reference collection.
}
Flags for semantic analysis.