mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: public consts and structs
This commit is contained in:
@@ -100,6 +100,7 @@ mut:
|
||||
line_nr int
|
||||
token_idx int // this is a token index, which will be used by error reporting
|
||||
is_for_var bool
|
||||
is_public bool // for consts
|
||||
}
|
||||
|
||||
struct Type {
|
||||
@@ -108,6 +109,7 @@ mut:
|
||||
mod string
|
||||
name string
|
||||
cat TypeCategory
|
||||
is_public bool
|
||||
fields []Var
|
||||
methods []Fn
|
||||
parent string
|
||||
@@ -254,10 +256,10 @@ fn new_table(obfuscate bool) &Table {
|
||||
for c in reserved_type_param_names {
|
||||
t.register_type(c)
|
||||
}
|
||||
t.register_const('stdin', 'int', 'main')
|
||||
t.register_const('stdout', 'int', 'main')
|
||||
t.register_const('stderr', 'int', 'main')
|
||||
t.register_const('errno', 'int', 'main')
|
||||
t.register_const('stdin', 'int', 'main', true)
|
||||
t.register_const('stdout', 'int', 'main', true)
|
||||
t.register_const('stderr', 'int', 'main', true)
|
||||
t.register_const('errno', 'int', 'main', true)
|
||||
t.register_type_with_parent('map_string', 'map')
|
||||
t.register_type_with_parent('map_int', 'map')
|
||||
return t
|
||||
@@ -306,13 +308,14 @@ fn (table &Table) known_mod(mod string) bool {
|
||||
return mod in table.modules
|
||||
}
|
||||
|
||||
fn (t mut Table) register_const(name, typ, mod string) {
|
||||
t.consts << Var {
|
||||
fn (t mut Table) register_const(name, typ, mod string, is_pub bool) {
|
||||
t.consts << Var{
|
||||
name: name
|
||||
typ: typ
|
||||
is_const: true
|
||||
mod: mod
|
||||
idx: -1
|
||||
is_public: is_pub
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user