v2.types #
fn init_universe #
fn init_universe() &Scope
fn new_module #
fn new_module(name string, path string) &Module
fn new_scope #
fn new_scope(parent &Scope) &Scope
fn Checker.new #
fn Checker.new(prefs &pref.Preferences, file_set &token.FileSet, env &Environment) &Checker
fn Environment.new #
fn Environment.new() &Environment
fn (Checker) get_module_scope #
fn (mut c Checker) get_module_scope(module_name string, parent &Scope) &Scope
fn (Checker) check_files #
fn (mut c Checker) check_files(files []ast.File)
fn (Checker) check_file #
fn (mut c Checker) check_file(file ast.File)
fn (Checker) preregister_scopes #
fn (mut c Checker) preregister_scopes(file ast.File)
fn (Checker) preregister_types #
fn (mut c Checker) preregister_types(file ast.File)
fn (Checker) preregister_fn_signatures #
fn (mut c Checker) preregister_fn_signatures(file ast.File)
fn (Checker) take_deferred #
fn (mut c Checker) take_deferred() []Deferred
take_deferred returns and clears the deferred items
fn (Checker) add_deferred #
fn (mut c Checker) add_deferred(items []Deferred)
add_deferred adds deferred items from another checker (used in parallel checking)
fn (Checker) process_struct_deferred #
fn (mut c Checker) process_struct_deferred()
process_struct_deferred processes only struct_decl deferred items Used after Phase 1 to resolve struct fields before full checking
fn (Checker) process_all_deferred #
fn (mut c Checker) process_all_deferred()
process_all_deferred processes all deferred items in proper order
type Object #
type Object = Const | Fn | Global | Module | SmartCastSelector | Type
fn (Object) typ #
fn (obj &Object) typ() Type
type Type #
type Type = Alias
| Array
| ArrayFixed
| Channel
| Char
| Enum
| FnType
| ISize
| Interface
| Map
| NamedType
| Nil
| None
| OptionType
| Pointer
| Primitive
| ResultType
| Rune
| String
| Struct
| SumType
| Thread
| Tuple
| USize
| Void
Todo: fix nested sum type in tinyv (like TS)
enum DeferredKind #
enum DeferredKind {
fn_decl
fn_decl_generic
struct_decl
const_decl
}
enum Properties #
enum Properties {
boolean
float
integer
unsigned
untyped
}
struct Alias #
struct Alias {
pub:
name string
pub mut:
base_type Type
}
struct Array #
struct Array {
pub:
elem_type Type
}
struct Deferred #
struct Deferred {
pub:
kind DeferredKind
func fn () = unsafe { nil }
scope &Scope
}
struct Environment #
struct Environment {
pub mut:
// errors with no default value
scopes shared map[string]&Scope = map[string]&Scope{}
// types map[int]Type
// methods - shared for parallel type checking
methods shared map[string][]&Fn = map[string][]&Fn{}
generic_types map[string][]map[string]Type
cur_generic_types []map[string]Type
}
struct Field #
struct Field {
pub:
name string
typ Type
}
struct NamedType { name string }
struct Module #
struct Module {
name string
path string
imports []Module
scope &Scope = new_scope(unsafe { nil })
}
struct Pointer #
struct Pointer {
pub:
base_type Type
}
struct Primitive #
struct Primitive {
pub:
// kind PrimitiveKind
props Properties
size u8
}
Todo: decide if kind will be used or just propertiesenum PrimitiveKind { bool_ i8_ i16_ // i32_ int_ i64_ // u8_ byte_ u16_ u32_ u64_ untyped_int untyped_float }
struct Scope #
struct Scope {
parent &Scope = unsafe { nil }
mut:
objects map[string]Object
// TODO: try implement using original concept
field_smartcasts map[string]Type
// smartcasts map[string]Type
// TODO: it may be more efficient looking up local vars using an ID
// even if we had to store them in two different places. investigate.
// variables []Object
start int
end int
}
fn (Scope) lookup_field_smartcast #
fn (mut s Scope) lookup_field_smartcast(name string) ?Type
Todo: try implement the alternate method I was experimenting with (SmartCastSelector)i'm not sure if it is actually possible though. need to explore it.
fn (Scope) lookup #
fn (mut s Scope) lookup(name string) ?Object
fn (Scope) lookup_parent #
fn (mut s Scope) lookup_parent(name string, pos token.Pos) ?Object
fn (Scope) lookup_parent_with_scope #
fn (mut s Scope) lookup_parent_with_scope(name string, pos token.Pos) ?(&Scope, Object)
fn (Scope) insert #
fn (mut s Scope) insert(name string, obj Object)
fn (Scope) print #
fn (s &Scope) print(recurse_parents bool)
struct Struct #
struct Struct {
pub:
name string
generic_params []string
pub mut:
embedded []Struct
// embedded []Type
fields []Field
// fields map[string]Type
// methods []Method
}
struct Method { name string typ FnType }