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)
trait Importer
trait Lookup
trait Kind
struct Enum
fn String(*self): string
fn Equal(&self, other: &Type): bool
fn FindItem(mut *self, name: string): &Var
struct TypeEnumItem
struct TypeEnum
fn String(*self): string
fn Equal(&self, other: &Type): bool
struct Value
fn IsNil(*self): bool
fn IsVoid(*self): bool
fn IsConst(*self): bool
fn GoodOperand(*self, mut other: &Value): bool
type Flag
struct ReturnType
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 String(*self): string
struct FuncIns
fn String(*self): string
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 GetKindString(*self, name: bool): string
struct ImportInfo
fn SelectPackage(mut *self, fn(&ImportInfo): bool): &ImportInfo
fn FindVar(mut *self, name: string, _: bool): &Var
fn FindTypeAlias(mut *self, name: string, _: bool): &TypeAlias
fn FindStruct(mut *self, name: string, _: bool): &Struct
fn FindFunc(mut *self, name: string, _: bool): &Func
fn FindTrait(mut *self, name: string): &Trait
fn FindEnum(mut *self, name: string): &Enum
fn FindTypeEnum(mut *self, name: string): &TypeEnum
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 BuiltinRealCallExpr
struct BuiltinImagCallExpr
struct BuiltinCmplxCallExpr
struct BuiltinFutureCallExpr
struct BuiltinReadyCallExpr
struct BuiltinClearCallExpr
struct SizeofExpr
struct AlignofExpr
struct RuneExpr
struct BackendEmitExpr
struct AddrcallExpr
struct Package
fn SelectPackage(mut *self, fn(&ImportInfo): bool): &ImportInfo
fn FindVar(mut *self, name: string, _extern: bool): &Var
fn FindTypeAlias(mut *self, name: string, _extern: bool): &TypeAlias
fn FindStruct(mut *self, name: string, _extern: bool): &Struct
fn FindFunc(mut *self, name: string, _extern: bool): &Func
fn FindTrait(mut *self, name: string): &Trait
fn FindEnum(mut *self, name: string): &Enum
fn FindTypeEnum(mut *self, name: string): &TypeEnum
struct FuncPattern
fn Main(f: &Func): bool
fn Init(f: &Func): bool
fn String(f: &Func): bool
fn ReadyParam(mut p: &ParamIns): 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 Throw
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 Return
struct Field
struct Struct
fn FindMethod(mut *self, name: string, _static: bool): &Func
fn FindField(mut *self, name: string): &Field
fn IsImplements(*self, t: &Trait): bool
fn HasRefAccessible(*self): bool
struct FieldIns
struct StructIns
fn String(*self): string
fn Equal(&self, other: &Type): bool
fn Same(*self, s: &StructIns): bool
fn FindMethod(mut *self, name: string, _static: bool): &Func
fn FindField(mut *self, name: string): &FieldIns
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 SymTab
fn SelectPackage(mut *self, selector: fn(&ImportInfo): bool): &ImportInfo
fn FindVar(mut *self, name: string, _extern: bool): &Var
fn FindTypeAlias(mut *self, name: string, _extern: bool): &TypeAlias
fn FindStruct(mut *self, name: string, _extern: bool): &Struct
fn FindFunc(mut *self, name: string, _extern: bool): &Func
fn FindTrait(mut *self, name: string): &Trait
fn FindEnum(mut *self, name: string): &Enum
fn FindTypeEnum(mut *self, name: string): &TypeEnum
struct Trait
fn String(*self): string
fn Equal(&self, other: &Type): bool
fn FindMethod(mut *self, name: string): &Func
struct ConstraintMask
fn String(*self): string
struct InsGeneric
struct TypeAlias
struct Type
fn String(*self): string
fn Equal(&self, other: &Type): bool
fn Extern(*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 Prim
fn String(*self): string
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 IsString(*self): bool
fn IsAny(*self): bool
struct Chan
fn String(*self): string
fn Equal(&self, other: &Type): bool
struct Sptr
fn String(*self): string
fn Equal(&self, other: &Type): bool
struct Slice
fn String(*self): string
fn Equal(&self, other: &Type): bool
struct Tuple
fn String(*self): string
fn Equal(&self, other: &Type): bool
struct Map
fn String(*self): string
fn Equal(&self, other: &Type): bool
struct Array
fn String(*self): string
fn Equal(&self, other: &Type): bool
struct Ptr
fn String(*self): string
fn Equal(&self, other: &Type): bool
fn IsUnsafe(*self): bool
struct Var
fn IsInitialized(*self): bool
fn IsTypeInferred(*self): bool
fn IsEnumField(*self): bool
enum FuncOwner: type
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 (
F_USED = 1 << iota
F_VARIADIC
F_GENERIC
F_MUTABLE
F_COMPARABLE
F_HAS_DEFER
F_ANON
F_AS_ANON
F_CALLED_SPAWN
F_IOTA
F_CONST
F_TYPE
F_FUTURE
F_READY
// Internal sema flags.
// This flags may be passed without documentation.
F_CHECKED
F_RELOADED
F_ONELINER
)Flags for Flag.
const (
// Scope is deferred.
ST_DEFER: ScopeTrait = 1 << iota
// Scope is unsafe.
ST_UNSAFE
// Scope is an infinite scope.
// This passed when scope owner is exactly and infinite iteration,
// or while-next iteration with no condition.
ST_INFINITE
// Scope is an error handling scope.
ST_ERROR_HANDLER
)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 buildConstraints:
- importer's main package path should be set.
- importer's module must be point to the package's module, if exist.
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: int): (&SymTab, []log::Log)Same as [AnalyzePackage], but it takes a singe file.
Importer
trait Importer {
// Returns FileSet by ID.
// Returns nil if ID is not matched with any FileSet.
fn GetFileSet(mut *self, id: int): &token::FileSet
// Reports whether the build tag is defined.
fn HasTag(mut *self, tag: string): bool
// 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 by ID.
fn ModByID(mut *self, id: mod::ID): &mod::Mod
// Registers the current module.
// Sets the module identity to a valid ID and
// then registers it as a used module.
//
// If the current module is nil, then it does nothing.
// If the current module is already registered, then it does nothing.
fn RegisterMod(mut *self)
// Sets path as the main package path.
fn SetMainPackagePath(mut *self, path: string)
// Returns the main package path, specified with [SetMainPackagePath].
// The default value is empty string.
fn GetMainPackagePath(mut *self): string
// 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: string): &ImportInfo
// Path is the directory path of package to import.
// Should return abstract syntax tree of package files.
// Logs accepts as error.
// Updates module to package's module if exist when updateMod is true.
// But the module and package will not be registered.
// Package and module can be registered with [Imported].
// For only module, it can be registered with [RegisterMod].
//
// The module identity will be invalid ID.
// The [Imported] or [RegisterMod] will assign a valid ID when registered.
fn ImportPackage(mut *self, path: string, updateMod: bool): ([]&ast::AST, []log::Log)
// Invoke after the package is imported.
// Registers package as an imported and used package.
// If the current module is not registered, sets module identitity and
// register it as used modules.
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
// Returns File by path.
// This function accepted as returns already included file.
// If returns not-nil value, will be used instead of IncludeFile if possible.
fn GetFile(mut *self, path: string): resource::File
// Includes the file by path, returns nil if failed.
fn IncludeFile(mut *self, path: string): resource::File
// Invoked after the file is included.
fn IncludedFile(mut *self, mut file: resource::File)
}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.
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 external state.
// Returns nil if did not found any match.
fn FindVar(mut *self, name: string, _extern: bool): &Var
// Find type alias by identifier and external state.
// Returns nil if did not found any match.
fn FindTypeAlias(mut *self, name: string, _extern: bool): &TypeAlias
// Find structure by identifier and external state.
// Returns nil if did not found any match.
fn FindStruct(mut *self, name: string, _extern: bool): &Struct
// Find function by identifier and external state.
// Returns nil if did not found any match.
fn FindFunc(mut *self, name: string, _extern: bool): &Func
// Find trait by identifier.
// Returns nil if did not found any match.
fn FindTrait(mut *self, name: string): &Trait
// Find enum by identifier.
// Returns nil if did not found any match.
fn FindEnum(mut *self, name: string): &Enum
// Find type enum by identifier.
// Returns nil if did not found any match.
fn FindTypeEnum(mut *self, name: string): &TypeEnum
}Generic behavior of lookupable types. Typically it is a scope like global scope, function scope or etc.
Kind
trait Kind {
fn String(*self): string
fn Equal(&self, other: &Type): bool
}Kind of type declaration.
Enum
struct Enum {
AST: &ast::Enum
FullName: string // See developer reference (16).
Type: &Type
Items: []&Var // See developer reference (14).
// NOTE: contains filtered hidden or unexported fields
}Enum.
Implemented Traits
Kind
String
fn String(*self): stringImplement: Kind Returns Enum's identifier.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
FindItem
fn FindItem(mut *self, name: string): &VarReturns item by identifier. Returns nil if not exist any item in this identifier.
TypeEnumItem
struct TypeEnumItem {
AST: &ast::TypeEnumItem
Type: &Type
}TypeEnum item.
TypeEnum
struct TypeEnum {
AST: &ast::TypeEnum
FullName: string // See developer reference (16).
Items: []&TypeEnumItem
// NOTE: contains filtered hidden or unexported fields
}TypeEnum.
Implemented Traits
Kind
String
fn String(*self): stringImplement: Kind Returns TypeEnum's identifier.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
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.
Flag
type Flag: uintA commonf flagset for sema. May contain internal flags of semantic analysis.
ReturnType
struct ReturnType {
AST: &ast::ReturnType
Type: &Type
}Return type.
Param
struct Param {
AST: &ast::Param
Type: &Type
}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 {
AST: &ast::Func
Result: &ReturnType
Params: []&Param
Owner: FuncOwner
// Function instances for each unique type combination of function call.
// Nil if function is never used.
Instances: []&FuncIns
// Possible flags are:
// F_HAS_DEFER: if function has at least one deferred scope.
// F_FUTURE: if function is a #future
// F_READY: if function is a #ready
Flags: Flag
// 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.
String
fn String(*self): stringImplement: 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
// Possible flags are:
// F_ANON: if function instance is an anonymous function literal
// F_AS_ANON: if function instance used as anonymous function
// F_CALLED_SPAWN: if function instance used for concurrent call
Flags: Flag
// NOTE: contains filtered hidden or unexported fields
}Function instance.
Implemented Traits
Kind
String
fn String(*self): stringImplement: 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.
GetKindString
fn GetKindString(*self, name: bool): stringReturns 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.
ImportInfo
struct ImportInfo {
// Declaration.
Decl: &ast::Use
// Absolute path.
Path: string
// Use declaration path string.
// Quotes are not included.
LinkPath: string
// Package alias identifier.
Alias: string
// True if imported with Importer.GetImport function.
Duplicate: bool
// Is external use declaration.
Extern: bool
// Is standard library package.
Std: bool
// Nil if package is external header.
Package: &Package
// Module ID.
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: string, _: bool): &VarReturns variable by identifier and external state. Returns nil if not exist any variable in this identifier.
Lookups by import way such as identifier selection. Just lookups non-external defines.
FindTypeAlias
fn FindTypeAlias(mut *self, name: string, _: 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-external defines.
FindStruct
fn FindStruct(mut *self, name: string, _: bool): &StructReturns struct by identifier and external state. Returns nil if not exist any struct in this identifier.
Lookups by import way such as identifier selection. Just lookups non-external defines.
FindFunc
fn FindFunc(mut *self, name: string, _: bool): &FuncReturns function by identifier and external state. Returns nil if not exist any function in this identifier.
Lookups by import way such as identifier selection. Just lookups non-external defines.
FindTrait
fn FindTrait(mut *self, name: string): &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: string): &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: string): &TypeEnumReturns type enum by identifier. Returns nil if not exist any type enum in this identifier.
Lookups by import way such as identifier selection.
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
IsSpawn: bool
Expr: Expr
Args: []Expr
Handler: &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: &Value
Cap: &Value
}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.
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 cmplx function calls.
BuiltinFutureCallExpr
struct BuiltinFutureCallExpr {
Owner: &FuncIns
Ready: &Value
Suspend: &Value
}Expression Model: for built-in future function calls.
BuiltinReadyCallExpr
struct BuiltinReadyCallExpr {
Status: &Value
}Expression Model: for built-in ready function calls.
BuiltinClearCallExpr
struct BuiltinClearCallExpr {
Value: &Value
}Expression Model: for built-in clear 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: string
// 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.
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: string, _extern: bool): &VarReturns variable by identifier and external state. Returns nil if not exist any variable in this identifier.
FindTypeAlias
fn FindTypeAlias(mut *self, name: string, _extern: bool): &TypeAliasReturns type alias by identifier and external state. Returns nil if not exist any type alias in this identifier.
FindStruct
fn FindStruct(mut *self, name: string, _extern: bool): &StructReturns struct by identifier and external state. Returns nil if not exist any struct in this identifier.
FindFunc
fn FindFunc(mut *self, name: string, _extern: bool): &FuncReturns function by identifier and external state. Returns nil if not exist any function in this identifier.
FindTrait
fn FindTrait(mut *self, name: string): &TraitReturns trait by identifier. Returns nil if not exist any trait in this identifier.
FindEnum
fn FindEnum(mut *self, name: string): &EnumReturns enum by identifier. Returns nil if not exist any enum in this identifier.
FindTypeEnum
fn FindTypeEnum(mut *self, name: string): &TypeEnumReturns type enum by identifier. Returns nil if not exist any type enum in this identifier.
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.
String
fn String(f: &Func): boolReports whether function is the reserved String function.
ReadyParam
fn ReadyParam(mut p: &ParamIns): boolReports whether the parameter is a good `ready` function response parameter.
ScopeTrait
type ScopeTrait: intRepresents traits of a scope.
Scope
struct Scope {
Traits: ScopeTrait
Owner: uintptr // Memory address of the owner.
Parent: &Scope
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.
Throw
struct Throw {
Func: &FuncIns
Error: &Value
}Throw statement.
Label
struct Label {
Name: string
Scope: &Scope // Owner scope.
Index: int // Index of statement.
}Label.
Direction
type Direction: intBasic direction flags.
Goto
struct Goto {
Name: string
Token: &token::Token
Label: &Label
Scope: &Scope // Owner scope.
Index: int // Index of statement.
Direction: Direction
}Goto statement.
Postfix
struct Postfix {
Expr: Expr
Op: string
}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
Cases: []&Case
Default: &Case
// Possible flags are:
// F_TYPE: if it is a type match statement
// F_CONST: if it is a comptime match statement
Flags: Flag
}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 // Nil for select statements. Refer to Stmt field.
Next: &Case
// Possible in select statements;
// - "<-chan", represented as &Value
// - "chan<-foo", represented as &Value
// - "x = <-chan", represented as &Assign
// - "x := <-chan", represented as &Var
Stmt: Stmt
}Match-Case case.
Fall
struct Fall {
DestCase: uintptr
}Fall statement.
Return
struct Return {
Func: &FuncIns
Expr: Expr
}Return statement.
Field
struct Field {
AST: &ast::Field
Owner: &Struct
Type: &Type
Tags: map[string]string // Tags in key:value format.
}Field.
Struct
struct Struct {
AST: &ast::Struct
// This structure depended to these structures, except external 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
FullName: string // See developer reference (16).
Fields: []&Field
Methods: []&Func
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: string, _static: bool): &FuncReturns method by identifier. Returns nil if not exist any method in this identifier.
FindField
fn FindField(mut *self, name: string): &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
Refers: &ReferenceStack
// Possible flags are:
// F_MUTABLE: if structure has fields with mutable types
// F_COMPARABLE: if all structure fields are comparable
Flags: Flag
// NOTE: contains filtered hidden or unexported fields
}Structure instance.
Implemented Traits
Kind
String
fn String(*self): stringImplement: 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: string, _static: bool): &FuncReturns method by identifier. Returns nil if not exist any method in this identifier.
FindField
fn FindField(mut *self, name: string): &FieldInsReturns field by identifier. Returns nil if not exist any field in this identifier.
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 and non-constant 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
Args: []string
}Directive pass.
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: []&ast::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: string, _extern: bool): &VarReturns variable by identifier and external state. Returns nil if refenrece not exist any variable in this identifier.
FindTypeAlias
fn FindTypeAlias(mut *self, name: string, _extern: bool): &TypeAliasReturns type alias by identifier and external state. Returns nil if not exist any type alias in this identifier.
FindStruct
fn FindStruct(mut *self, name: string, _extern: bool): &StructReturns struct by identifier and external state. Returns nil if not exist any struct in this identifier.
FindFunc
fn FindFunc(mut *self, name: string, _extern: bool): &FuncReturns function by identifier and external state. Returns nil if not exist any function in this identifier.
FindTrait
fn FindTrait(mut *self, name: string): &TraitReturns trait by identifier. Returns nil if not exist any trait in this identifier.
FindEnum
fn FindEnum(mut *self, name: string): &EnumReturns enum by identifier. Returns nil if not exist any enum in this identifier.
FindTypeEnum
fn FindTypeEnum(mut *self, name: string): &TypeEnumReturns type enum by identifier. Returns nil if not exist any type enum in this identifier.
Trait
struct Trait {
AST: &ast::Trait
FullName: string // See developer reference (16).
Inherits: []&Type
Methods: []&Func
Implemented: []&Struct
// NOTE: contains filtered hidden or unexported fields
}Trait.
Implemented Traits
Kind
String
fn String(*self): stringImplement: Kind Returns Trait's identifier.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
FindMethod
fn FindMethod(mut *self, name: string): &FuncReturns method by identifier. Returns nil if not exist any method in this identifier.
ConstraintMask
struct ConstraintMask {
Deep: bool // Whether the operator ~ used.
Type: &Type
}Single mask value for a constraint.
String
fn String(*self): stringInsGeneric
struct InsGeneric {
Type: &Type
Constraint: []ConstraintMask
}Generic type for instance types.
TypeAlias
struct TypeAlias {
AST: &ast::TypeAlias
Scope: &ast::Scope
FullName: string // See developer reference (16).
Type: &Type
Generics: []&ast::Generic // See the developer reference (3).
// Possible flags are:
// F_USED: if type alias is used in code
// F_GENERIC: if type alias is generic
Flags: Flag
}Type alias.
Type
struct Type {
Provider: string // Identifier of the type alias, if type provided by a type alias.
Kind: Kind
// Possible flags are:
// F_VARIADIC: if type is variadic
// F_GENERIC: if type is resolved from a generic type alias
Flags: Flag
}Evaluated type declaration.
Implemented Traits
Kind
String
fn String(*self): stringReturns kind as string.
Equal
fn Equal(&self, other: &Type): boolReports whether types are same.
Extern
fn Extern(*self): boolReports whether type is external 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.
Prim
struct Prim {
Kind: string
}Primitive type.
Implemented Traits
Kind
String
fn String(*self): stringReturns 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.
IsString
fn IsString(*self): boolReports whether type is primitive string.
IsAny
fn IsAny(*self): boolReports whether type is primitive any.
Chan
struct Chan {
Recv: bool
Send: bool
Value: &Type
}Channel type.
Implemented Traits
Kind
String
fn String(*self): stringReturns 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
String
fn String(*self): stringReturns 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
String
fn String(*self): stringReturns 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
String
fn String(*self): stringReturns 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
String
fn String(*self): stringReturns 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
String
fn String(*self): stringReturns 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
String
fn String(*self): stringReturns 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).
Var
struct Var {
AST: &ast::Var
Scope: &Scope
Type: &Type
Value: &Value
Refers: &ReferenceStack
// 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.
// Possible flags are:
// F_USED: if variable is used in code
// F_IOTA: if enumerable iota variable used in the expression
Flags: Flag
}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.
FuncOwner
enum FuncOwner: type {
&Struct,
&Trait,
}Types of a potential owner of a function.
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,
&BuiltinRealCallExpr,
&BuiltinImagCallExpr,
&BuiltinCmplxCallExpr,
&BuiltinFutureCallExpr,
&BuiltinReadyCallExpr,
&BuiltinClearCallExpr,
&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,
&Return,
&Select,
&Use,
&Throw,
}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.