std/jule/sema
Index
Variables
fn AnalyzePackage(mut files: []&ast::AST, mut importer: Importer, flags: int): (&Package, []log::Log)
fn AnalyzeFile(mut f: &ast::AST, mut importer: Importer, flags: int): (&SymTab, []log::Log)
fn Fastmemcopy(mut t: &Type): (r: bool)
trait Importer
trait Kind
trait Lookup
struct Field
struct Struct
fn FindMethod(mut *self, name: str, _static: bool): &Func
fn FindField(mut *self, name: 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, name: str, _static: bool): &Func
fn FindField(mut *self, name: str): &FieldIns
struct OperandExpr
struct BinaryExpr
struct UnaryExpr
struct StructArgExpr
struct StructLitExpr
struct AllocStructLitExpr
struct CastingExpr
struct TypeAssertionExpr
struct FuncCallExpr
struct SliceExpr
struct IndexingExpr
struct AnonFuncExpr
struct KeyValueExpr
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 BuiltinRealCallExpr
struct BuiltinImagCallExpr
struct BuiltinCmplxCallExpr
struct SizeofExpr
struct AlignofExpr
struct RuneExpr
struct BackendEmitExpr
struct AddrcallExpr
struct SymTab
fn SelectPackage(mut *self, selector: fn(&ImportInfo): bool): &ImportInfo
fn FindVar(mut *self, name: str, _bind: bool): &Var
fn FindTypeAlias(mut *self, name: str, _bind: bool): &TypeAlias
fn FindStruct(mut *self, name: str, _bind: bool): &Struct
fn FindFunc(mut *self, name: str, _bind: bool): &Func
fn FindTrait(mut *self, name: str): &Trait
fn FindEnum(mut *self, name: str): &Enum
fn FindTypeEnum(mut *self, name: str): &TypeEnum
struct Trait
fn Str(*self): str
fn Equal(&self, other: &Type): bool
fn FindMethod(mut *self, name: str): &Func
struct Enum
fn Str(*self): str
fn Equal(&self, other: &Type): bool
fn FindItem(mut *self, name: str): &Var
struct TypeEnumItem
struct TypeEnum
fn Str(*self): str
fn Equal(&self, other: &Type): bool
struct Impl
fn IsTraitImpl(*self): bool
fn IsStructImpl(*self): bool
type ScopeTrait
struct Scope
struct Use
struct If
struct Else
struct Conditional
struct InfIter
struct WhileIter
fn IsWhileNext(*self): bool
struct RangeIter
struct Continue
struct Break
struct Label
type Direction
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 IsSmartptr(*self): bool
fn IsRefptr(*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, name: 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, name: str, _: bool): &Var
fn FindTypeAlias(mut *self, name: str, _: bool): &TypeAlias
fn FindStruct(mut *self, name: str, _: bool): &Struct
fn FindFunc(mut *self, name: str, _: bool): &Func
fn FindTrait(mut *self, name: str): &Trait
fn FindEnum(mut *self, name: str): &Enum
fn FindTypeEnum(mut *self, name: str): &TypeEnum
struct Package
fn SelectPackage(mut *self, fn(&ImportInfo): bool): &ImportInfo
fn FindVar(mut *self, name: str, _bind: bool): &Var
fn FindTypeAlias(mut *self, name: str, _bind: bool): &TypeAlias
fn FindStruct(mut *self, name: str, _bind: bool): &Struct
fn FindFunc(mut *self, name: str, _bind: bool): &Func
fn FindTrait(mut *self, name: str): &Trait
fn FindEnum(mut *self, name: str): &Enum
fn FindTypeEnum(mut *self, name: str): &TypeEnum
struct Var
fn IsInitialized(*self): bool
fn IsTypeInferred(*self): bool
fn IsEnumField(*self): bool
struct FuncPattern
fn Main(f: &Func): bool
fn Init(f: &Func): bool
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 ConstraintMask
fn Str(*self): str
struct InsGeneric
struct TypeAlias
struct Type
fn Str(*self): str
fn Equal(&self, other: &Type): bool
fn Bind(*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 SoftStruct(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 IsCmplx64(*self): bool
fn IsCmplx128(*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 RetState
Variables
const (
Default = 1 << iota // Default semantic analysis of Jule.
Shadowing // Default + enable shadowing.
)Flags for semantic analysis.
const (
// Scope is an infinite scope.
// This passed when scope owner is exactly and infinite iteration,
// or while-next iteration with no condition.
ST_INFINITE: ScopeTrait = 1 << iota
)Scope traits.
const (
UP: Direction = iota
DOWN
)Directions.
AnalyzePackage
fn AnalyzePackage(mut files: []&ast::AST, mut importer: Importer, flags: int): (&Package, []log::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 declarationsDependent Parameters:
working-directory: uses working directory path provided by build
std-path: uses standard library path provided by buildRisks:
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: int): (&SymTab, []log::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 declarationsDependent Parameters:
working-directory: uses working directory path provided by build
std-path: uses standard library path provided by buildRisks:
You can pass nil to importer, but panics if importer is nil and
semantic analyzer used nil importer.Fastmemcopy
fn Fastmemcopy(mut t: &Type): (r: bool)Reports whether type supports fastmemcopy implementation. Which is highly optimized variant of the built-in copy function.
Importer
trait Importer {
// Set current module.
// Set to nil if module is not exist.
fn SetMod(mut *self, mut mod: &mod::Mod)
// Returns current module.
// Returns nil if module is not exist.
fn GetMod(mut *self): &mod::Mod
// Returns module path by identity.
fn ModById(mut *self, id: mod::ID): &mod::Mod
// 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, []log::Log)
// Invoked after the package is imported.
// Sets module identitity of imported package to current module.
fn Imported(mut *self, mut &ImportInfo)
// Returns all imported packages.
// The return value may be mutable reference to the internal buffer.
// Packages should be ordered by FIFO; starting with the first deepest
// imported package, and ending with the last imported package.
fn AllPackages(mut *self): []&ImportInfo
}Package importer for the semantic analysis. 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 bind state.
// Returns nil if did not found any match.
fn FindVar(mut *self, name: str, _bind: bool): &Var
// Find type alias by identifier and bind state.
// Returns nil if did not found any match.
fn FindTypeAlias(mut *self, name: str, _bind: bool): &TypeAlias
// Find structure by identifier and bind state.
// Returns nil if did not found any match.
fn FindStruct(mut *self, name: str, _bind: bool): &Struct
// Find function by identifier and bind state.
// Returns nil if did not found any match.
fn FindFunc(mut *self, name: str, _bind: bool): &Func
// Find trait by identifier.
// Returns nil if did not found any match.
fn FindTrait(mut *self, name: str): &Trait
// Find enum by identifier.
// Returns nil if did not found any match.
fn FindEnum(mut *self, name: str): &Enum
// Find type enum by identifier.
// Returns nil if did not found any match.
fn FindTypeEnum(mut *self, name: 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.
Name: str
TypeSym: &TypeSym
Tag: &token::Token // Tag declaration.
Tags: map[str]str // Tags in key:value format.
}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
Name: str
Fields: []&Field
Methods: []&Func
Public: bool
Bind: 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, name: str, _static: bool): &FuncReturns method by identifier. Returns nil if not exist any method in this identifier.
FindField
fn FindField(mut *self, name: str): &FieldReturns field by identifier. Returns nil if not exist any field in this identifier.
IsImplements
fn IsImplements(*self, t: &Trait): boolReports whether structure implements given trait.
HasRefAccessible
fn HasRefAccessible(*self): boolReports whether structure has only reference-type-accessible defines.
FieldIns
struct FieldIns {
Owner: &StructIns
Decl: &Field
Type: &Type
}Field instance.
StructIns
struct StructIns {
Source: &Type // See developer reference (9).
Decl: &Struct
Generics: []&InsGeneric
Fields: []&FieldIns
Methods: []&Func
Mutable: bool // This structure has mutable defines.
Comparable: bool
Refers: &ReferenceStack
// NOTE: contains filtered hidden or unexported fields
}Structure instance.
Implemented Traits
Kind
Str
fn Str(*self): strImplement: Kind Returns Struct's type kind as string.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
Same
fn Same(*self, s: &StructIns): boolReports whether instances are same. Returns true if declarations and generics are same.
FindMethod
fn FindMethod(mut *self, name: str, _static: bool): &FuncReturns method by identifier. Returns nil if not exist any method in this identifier.
FindField
fn FindField(mut *self, name: str): &FieldInsReturns 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)(myFloat)
TypeAssertionExpr
struct TypeAssertionExpr {
Token: &token::Token
Expr: &Value
Type: &Type
}Type assertion expression model. For example: myExpr.(destType)
FuncCallExpr
struct FuncCallExpr {
Token: &token::Token
Func: &FuncIns
IsCo: bool
Expr: Expr
Args: []Expr
Except: &Scope // Nil for ignored.
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.
KeyValueExpr
struct KeyValueExpr {
Key: Expr
Value: Expr
}Key-value expression pair model.
MapExpr
struct MapExpr {
Kind: &Map
Entries: []&KeyValueExpr
}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.
BuiltinRealCallExpr
struct BuiltinRealCallExpr {
Cmplx: &Value
}Expression Model: for built-in real function calls.
BuiltinImagCallExpr
struct BuiltinImagCallExpr {
Cmplx: &Value
}Expression Model: for built-in imag function calls.
BuiltinCmplxCallExpr
struct BuiltinCmplxCallExpr {
Real: &Value
Imag: &Value
}Expression Model: for built-in imag 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.
AddrcallExpr
struct AddrcallExpr {
Addr: &Value
Args: []&Value
Result: &Type // Nil for void.
}Expression Model: for address-based function call.
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): &ImportInfoReturns imported package by selector. Returns nil if selector returns false for all packages. Returns nil if selector is nil.
FindVar
fn FindVar(mut *self, name: str, _bind: bool): &VarReturns variable by identifier and bind state. Returns nil if refenrece not exist any variable in this identifier.
FindTypeAlias
fn FindTypeAlias(mut *self, name: str, _bind: bool): &TypeAliasReturns type alias by identifier and bind state. Returns nil if not exist any type alias in this identifier.
FindStruct
fn FindStruct(mut *self, name: str, _bind: bool): &StructReturns struct by identifier and bind state. Returns nil if not exist any struct in this identifier.
FindFunc
fn FindFunc(mut *self, name: str, _bind: bool): &FuncReturns function by identifier and bind state. Returns nil if not exist any function in this identifier.
FindTrait
fn FindTrait(mut *self, name: str): &TraitReturns trait by identifier. Returns nil if not exist any trait in this identifier.
FindEnum
fn FindEnum(mut *self, name: str): &EnumReturns enum by identifier. Returns nil if not exist any enum in this identifier.
FindTypeEnum
fn FindTypeEnum(mut *self, name: str): &TypeEnumReturns type enum by identifier. Returns nil if not exist any type enum in this identifier.
Trait
struct Trait {
Token: &token::Token
Name: str
Public: bool
Inherits: []&TypeSym
Methods: []&Func
Implemented: []&Struct
}Trait.
Implemented Traits
Kind
Str
fn Str(*self): strImplement: Kind Returns Trait's identifier.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
FindMethod
fn FindMethod(mut *self, name: str): &FuncReturns method by identifier. Returns nil if not exist any method in this identifier.
Enum
struct Enum {
Token: &token::Token
Public: bool
Name: str
TypeSym: &TypeSym
Items: []&Var // See developer reference (14).
}Enum.
Implemented Traits
Kind
Str
fn Str(*self): strImplement: Kind Returns Enum's identifier.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
FindItem
fn FindItem(mut *self, name: str): &VarReturns item by identifier. Returns nil if not exist any item in this identifier.
TypeEnumItem
struct TypeEnumItem {
Token: &token::Token
TypeSym: &TypeSym
}TypeEnum item.
TypeEnum
struct TypeEnum {
Token: &token::Token
Public: bool
Name: str
Items: []&TypeEnumItem
}TypeEnum.
Implemented Traits
Kind
Str
fn Str(*self): strImplement: Kind Returns TypeEnum's identifier.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
Impl
struct Impl {
// Equivalent to ast::Impl's base field.
Base: &ast::Expr
// Equivalent to ast::Impl's dest field.
Dest: &ast::Expr
// Equivalent to ast::Impl's methods field.
Methods: []&Func
}Implementation.
IsTraitImpl
fn IsTraitImpl(*self): boolReports whether implementation type is trait to structure.
IsStructImpl
fn IsStructImpl(*self): boolReports whether implementation type is append to destination structure.
ScopeTrait
type ScopeTrait: intRepresents traits of a scope.
Scope
struct Scope {
Traits: ScopeTrait
Owner: uintptr // Memory address of the owner.
Parent: &Scope
Unsafe: 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.
Use
struct Use {
Value: &Value
}Use statement.
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): boolReports 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 {
Name: str
Scope: &Scope // Owner scope.
Index: int // Index of statement.
}Label.
Direction
type Direction: intBasic direction flags.
Goto
struct Goto {
Name: str
Token: &token::Token
Label: &Label
Scope: &Scope // Owner scope.
Index: int // Index of statement.
Direction: Direction
}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): boolReports 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
Names: []&token::Token
}Return type.
Param
struct Param {
Token: &token::Token
Mutable: bool
Variadic: bool
Reference: bool
TypeSym: &TypeSym
Name: str
}Parameter.
IsSelf
fn IsSelf(*self): boolReports whether parameter is self (receiver) parameter.
IsSmartptr
fn IsSmartptr(*self): boolReports whether self (receiver) parameter is smart pointer.
IsRefptr
fn IsRefptr(*self): boolReports whether self (receiver) parameter is reference pointer.
Func
struct Func {
// Token of function declaration.
// It may be nil if function is created by a deferred scope.
Token: &token::Token
Global: bool
Unsafe: bool
Public: bool
Bind: bool
Static: bool
Exceptional: bool
HasDefer: bool // Whether function has at least one deferred scope.
Name: 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): boolReports whether return type is void.
IsMethod
fn IsMethod(*self): boolReports whether function is method.
IsEntryPoint
fn IsEntryPoint(*self): boolReports whether function is entry point.
IsInit
fn IsInit(*self): boolReports whether function is initializer function.
IsAnon
fn IsAnon(*self): boolReports whether function is anonymous function.
AnyVar
fn AnyVar(*self): boolReports whether function has return variable(s).
ParamIns
struct ParamIns {
Decl: &Param
Type: &Type
}Parameter instance.
Str
fn Str(*self): strImplement: Kind Returns ParamIns's type kind as string.
FuncIns
struct FuncIns {
Owner: &StructIns
Decl: &Func
Generics: []&InsGeneric
Params: []&ParamIns
Result: &Type // Result type of the instance, nil for void.
Scope: &Scope
Refers: &ReferenceStack
Anon: bool // Whether this function instance is anonymous function literal.
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): strImplement: Kind Returns function's type kind as string.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
EqualFunc
fn EqualFunc(&self, f: &FuncIns, responsive: bool): boolReports 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): []&TypeReturns all types of result. Returns nil if result is nil. Returns mutable slice if returns internal slice.
IsBuiltin
fn IsBuiltin(*self): boolReports whether instance is built-in.
IsAnon
fn IsAnon(*self): boolReports whether instance is anonymous function.
Same
fn Same(*self, f: &FuncIns): boolReports whether instances are same. Returns true if declarations and generics are same.
GetKindStr
fn GetKindStr(*self, name: bool): strReturns 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): intReturns count of references.
At
fn At(mut *self, i: int): anyReturns reference by index.
Push
fn Push(mut *self, mut ref: any)Push new reference to stack.
Exist
fn Exist[T](*self, t: T): boolReports 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.
Bind: bool
// Is standard library package.
Std: bool
// Nil if package is cpp header.
Package: &Package
// Module identity.
ModID: mod::ID
}Import information. Represents imported package by use declaration.
Implemented Traits
Lookup
SelectPackage
fn SelectPackage(mut *self, fn(&ImportInfo): bool): &ImportInfoReturns always nil.
FindVar
fn FindVar(mut *self, name: str, _: bool): &VarReturns variable by identifier and bind state. Returns nil if not exist any variable in this identifier.
Lookups by import way such as identifier selection. Just lookups non-bind defines.
FindTypeAlias
fn FindTypeAlias(mut *self, name: str, _: bool): &TypeAliasReturns 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-bind defines.
FindStruct
fn FindStruct(mut *self, name: str, _: bool): &StructReturns struct by identifier and bind state. Returns nil if not exist any struct in this identifier.
Lookups by import way such as identifier selection. Just lookups non-bind defines.
FindFunc
fn FindFunc(mut *self, name: str, _: bool): &FuncReturns function by identifier and bind state. Returns nil if not exist any function in this identifier.
Lookups by import way such as identifier selection. Just lookups non-bind defines.
FindTrait
fn FindTrait(mut *self, name: str): &TraitReturns 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, name: str): &EnumReturns 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, name: str): &TypeEnumReturns 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): &ImportInfoReturns always nil.
FindVar
fn FindVar(mut *self, name: str, _bind: bool): &VarReturns variable by identifier and bind state. Returns nil if not exist any variable in this identifier.
FindTypeAlias
fn FindTypeAlias(mut *self, name: str, _bind: bool): &TypeAliasReturns type alias by identifier and bind state. Returns nil if not exist any type alias in this identifier.
FindStruct
fn FindStruct(mut *self, name: str, _bind: bool): &StructReturns struct by identifier and bind state. Returns nil if not exist any struct in this identifier.
FindFunc
fn FindFunc(mut *self, name: str, _bind: bool): &FuncReturns function by identifier and bind state. Returns nil if not exist any function in this identifier.
FindTrait
fn FindTrait(mut *self, name: str): &TraitReturns trait by identifier. Returns nil if not exist any trait in this identifier.
FindEnum
fn FindEnum(mut *self, name: str): &EnumReturns enum by identifier. Returns nil if not exist any enum in this identifier.
FindTypeEnum
fn FindTypeEnum(mut *self, name: str): &TypeEnumReturns type enum by identifier. Returns nil if not exist any type enum in this identifier.
Var
struct Var {
Scope: &Scope
Token: &token::Token
Name: str
Bind: bool
Constant: bool
Mutable: bool
Public: bool
Used: bool
Static: bool
Reference: bool
Checked: bool
TypeSym: &TypeSym
ValueSym: &ValueSym
Refers: &ReferenceStack
Directives: []&ast::Directive
// Return variable state for this variable.
RetState: RetState
// The 0..n means this variable is the nth variable of the return variables.
// This order is not useful if variable is not associated with the return type.
RetOrder: int
// This variable depended to these variables for initialization expression.
// Nil if not global variable.
Depends: []&Var
// See developer reference (13).
GroupIndex: int // Index of variable in the group, if variable is grouped.
Group: []&Var // All variables of group in define order, if variable is grouped.
Iota: bool // The enumerable iota variable used in the expression.
}Variable.
IsInitialized
fn IsInitialized(*self): boolReports whether variable is initialized explicitly.
IsTypeInferred
fn IsTypeInferred(*self): boolReports whether variable is type inferred.
IsEnumField
fn IsEnumField(*self): boolReports whether variable is enum field.
FuncPattern
struct FuncPattern{}Pattern checker for functions and methods.
Main
fn Main(f: &Func): boolReports whether function is the reserved main function.
Init
fn Init(f: &Func): boolReports whether function is the reserved init function.
Str
fn Str(f: &Func): boolReports 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
// If this is true, Model might be nil or something.
// Use the Type field to handle declaration type.
Decl: bool
// Constant expression data.
Constant: &constant::Const
// NOTE: contains filtered hidden or unexported fields
}Value.
IsNil
fn IsNil(*self): boolReports whether Value is nil literal.
IsVoid
fn IsVoid(*self): boolReports whether Value is void.
IsConst
fn IsConst(*self): boolReports whether Value is constant expression.
GoodOperand
fn GoodOperand(*self, mut other: &Value): boolSee 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.
ConstraintMask
struct ConstraintMask {
Deep: bool // Whether the operator ~ used.
Type: &Type
}Single mask value for a constraint.
Str
fn Str(*self): strInsGeneric
struct InsGeneric {
Type: &Type
Constraint: []ConstraintMask
}Generic type for instance types.
TypeAlias
struct TypeAlias {
Scope: &ast::ScopeTree
Strict: bool
Public: bool
Bind: bool
Used: bool
Generic: bool
Token: &token::Token
Name: str
TypeSym: &TypeSym
Generics: []&ast::Generic // See the developer reference (3).
}Type alias.
Type
struct Type {
Provider: str // Identifier of the type alias, if type provided by a type alias.
Generic: bool
Variadic: bool
Kind: Kind
}Evaluated type declaration.
Implemented Traits
Kind
Str
fn Str(*self): strReturns kind as string.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
Bind
fn Bind(*self): boolReports whether type is bind kind.
IsNil
fn IsNil(*self): boolReports whether kind is "nil".
Void
fn Void(*self): boolReports whether actual kind is "void".
ActualKind
fn ActualKind(mut *self): KindReturns 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): boolReports whether actual kinds are equal.
Comparable
fn Comparable(*self): boolReports whether actual kind is comparable.
Mutable
fn Mutable(*self): boolReports whether actual kind is mutable.
Ordered
fn Ordered(*self): boolReports whether actual kind supports ordered constraint.
NilCompatible
fn NilCompatible(*self): boolReports whether actual kind is nil compatible.
GC
fn GC(*self): boolReports whether actual kind performs garbage collection.
Variadicable
fn Variadicable(*self): boolReports whether actual kind is variadicable.
Prim
fn Prim(mut *self): &PrimReturns primitive type if actual kind is primitive type, nil if not.
Chan
fn Chan(mut *self): &ChanReturns channel type if actual kind is channel, nil if not.
Sptr
fn Sptr(mut *self): &SptrReturns reference type if actual kind is smart pointer, nil if not.
Ptr
fn Ptr(mut *self): &PtrReturns pointer type if actual kind is pointer, nil if not.
Enum
fn Enum(mut *self): &EnumReturns enum type if actual kind is enum, nil if not.
TypeEnum
fn TypeEnum(mut *self): &TypeEnumReturns type enum if actual kind is type enum, nil if not.
Array
fn Array(mut *self): &ArrayReturns array type if actual kind is array, nil if not.
Slice
fn Slice(mut *self): &SliceReturns slice type if actual kind is slice, nil if not.
Func
fn Func(mut *self): &FuncInsReturns function type if actual kind is function, nil if not.
Struct
fn Struct(mut *self): &StructInsReturns struct type if actual kind is structure, nil if not.
SoftStruct
fn SoftStruct(mut *self): &StructInsReturns struct type if actual kind is structure. If type kind is the strict type alias source, returns the underlying structure type of the strict type alias.
Trait
fn Trait(mut *self): &TraitReturns trait type if actual kind is trait, nil if not.
Map
fn Map(mut *self): &MapReturns map type if actual kind is map, nil if not.
Tuple
fn Tuple(mut *self): &TupleReturns tuple type if actual kind is tuple, nil if not.
TypeSym
struct TypeSym {
Decl: &ast::Expr // Never changed by semantic analyzer.
Type: &Type
}Type.
Prim
struct Prim {
Kind: str
}Primitive type.
Implemented Traits
Kind
Str
fn Str(*self): strReturns kind.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
IsConstraint
fn IsConstraint(*self): boolReports whether type is built-in constraint.
IsI8
fn IsI8(*self): boolReports whether type is primitive i8.
IsI16
fn IsI16(*self): boolReports whether type is primitive i16.
IsI32
fn IsI32(*self): boolReports whether type is primitive i32.
IsI64
fn IsI64(*self): boolReports whether type is primitive i64.
IsU8
fn IsU8(*self): boolReports whether type is primitive u8.
IsU16
fn IsU16(*self): boolReports whether type is primitive u16.
IsU32
fn IsU32(*self): boolReports whether type is primitive u32.
IsU64
fn IsU64(*self): boolReports whether type is primitive u64.
IsF32
fn IsF32(*self): boolReports whether type is primitive f32.
IsF64
fn IsF64(*self): boolReports whether type is primitive f64.
IsCmplx64
fn IsCmplx64(*self): boolReports whether type is primitive cmplx64.
IsCmplx128
fn IsCmplx128(*self): boolReports whether type is primitive cmplx128.
IsInt
fn IsInt(*self): boolReports whether type is primitive int.
IsUint
fn IsUint(*self): boolReports whether type is primitive uint.
IsUintptr
fn IsUintptr(*self): boolReports whether type is primitive uintptr.
IsBool
fn IsBool(*self): boolReports whether type is primitive bool.
IsStr
fn IsStr(*self): boolReports whether type is primitive str.
IsAny
fn IsAny(*self): boolReports whether type is primitive any.
Chan
struct Chan {
Recv: bool
Send: bool
Value: &Type
}Channel type.
Implemented Traits
Kind
Str
fn Str(*self): strReturns smart pointer kind as string.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
Sptr
struct Sptr {
Value: &Type
}Smart pointer.
Implemented Traits
Kind
Str
fn Str(*self): strReturns smart pointer kind as string.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
Slice
struct Slice {
Value: &Type
}Slice type.
Implemented Traits
Kind
Str
fn Str(*self): strReturns slice kind as string.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
Tuple
struct Tuple {
Types: []&Type
}Tuple type.
Implemented Traits
Kind
Str
fn Str(*self): strReturns tuple kind as string.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
Map
struct Map {
Key: &Type
Value: &Type
}Map type.
Implemented Traits
Kind
Str
fn Str(*self): strReturns map kind as string.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
Array
struct Array {
Auto: bool // Auto-sized array.
N: int
Value: &Type
}Array type.
Implemented Traits
Kind
Str
fn Str(*self): strReturns array kind as string.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
Ptr
struct Ptr {
Value: &Type
}Pointer type.
Implemented Traits
Kind
Str
fn Str(*self): strReturns pointer kind as string.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
IsUnsafe
fn IsUnsafe(*self): boolReports whether pointer is unsafe pointer (*unsafe).
Expr
enum Expr: type {
&Type,
&constant::Const,
&Var,
&FuncIns,
&StructIns,
&BinaryExpr,
&UnaryExpr,
&StructLitExpr,
&AllocStructLitExpr,
&CastingExpr,
&FuncCallExpr,
&SliceExpr,
&IndexingExpr,
&AnonFuncExpr,
&MapExpr,
&SlicingExpr,
&TraitSubIdentExpr,
&StructSubIdentExpr,
&StructStaticIdentExpr,
&ArrayExpr,
&TupleExpr,
&BuiltinPrintCallExpr,
&BuiltinPrintlnCallExpr,
&BuiltinNewCallExpr,
&BuiltinPanicCallExpr,
&BuiltinMakeCallExpr,
&BuiltinAppendCallExpr,
&BuiltinCopyCallExpr,
&BuiltinLenCallExpr,
&BuiltinCapCallExpr,
&BuiltinDeleteCallExpr,
&BuiltinErrorCallExpr,
&BuiltinRealCallExpr,
&BuiltinImagCallExpr,
&BuiltinCmplxCallExpr,
&SizeofExpr,
&AlignofExpr,
&RuneExpr,
&BackendEmitExpr,
&ChanRecv,
&ChanSend,
&BuiltinCloseCallExpr,
&TypeAssertionExpr,
&AddrcallExpr,
}Expression model.
Stmt
enum Stmt: type {
&Scope,
&Var,
&Value,
&Conditional,
&InfIter,
&WhileIter,
&RangeIter,
&Continue,
&Label,
&Goto,
&Postfix,
&Assign,
&MultiAssign,
&Match,
&Fall,
&Break,
&Ret,
&Select,
&Use,
}Statement type.
CaseOwner
enum CaseOwner: type {
&Match,
&Select,
}Valid owner types for Case.
RetState
enum RetState {
NA, // Variable is not associated with return type.
Single, // Variable is associated with the single return type.
Tuple, // Variable is associated with the tuple return type.
}Return variable states.