mirror of
https://github.com/vlang/v.git
synced 2025-09-17 19:36:35 -04:00
markused: make work with json
This commit is contained in:
parent
95e5ba44ae
commit
c03b4f68fc
@ -34,6 +34,10 @@ fn np(path string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_simple() {
|
fn test_simple() {
|
||||||
|
// if true {
|
||||||
|
// return
|
||||||
|
//}
|
||||||
|
|
||||||
t1 := np(os.join_path(tfolder, 't1'))
|
t1 := np(os.join_path(tfolder, 't1'))
|
||||||
t2 := np(os.join_path(tfolder, 't2'))
|
t2 := np(os.join_path(tfolder, 't2'))
|
||||||
t3 := np(os.join_path(tfolder, 't3'))
|
t3 := np(os.join_path(tfolder, 't3'))
|
||||||
|
@ -259,6 +259,7 @@ fn map_free_string(pkey voidptr) {
|
|||||||
fn map_free_nop(_ voidptr) {
|
fn map_free_nop(_ voidptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@[markused]
|
||||||
fn new_map(key_bytes int, value_bytes int, hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn) map {
|
fn new_map(key_bytes int, value_bytes int, hash_fn MapHashFn, key_eq_fn MapEqFn, clone_fn MapCloneFn, free_fn MapFreeFn) map {
|
||||||
metasize := int(sizeof(u32) * (init_capicity + extra_metas_inc))
|
metasize := int(sizeof(u32) * (init_capicity + extra_metas_inc))
|
||||||
// for now assume anything bigger than a pointer is a string
|
// for now assume anything bigger than a pointer is a string
|
||||||
|
@ -32,6 +32,7 @@ pub mut:
|
|||||||
used_veb_types []Type // veb context types, filled in by checker
|
used_veb_types []Type // veb context types, filled in by checker
|
||||||
used_maps int // how many times maps were used, filled in by markused
|
used_maps int // how many times maps were used, filled in by markused
|
||||||
used_arrays int // how many times arrays were used, filled in by markused
|
used_arrays int // how many times arrays were used, filled in by markused
|
||||||
|
// json bool // json is imported
|
||||||
}
|
}
|
||||||
|
|
||||||
@[unsafe]
|
@[unsafe]
|
||||||
@ -65,7 +66,7 @@ pub mut:
|
|||||||
sumtypes map[int]SumTypeDecl
|
sumtypes map[int]SumTypeDecl
|
||||||
cmod_prefix string // needed for ast.type_to_str(Type) while vfmt; contains `os.`
|
cmod_prefix string // needed for ast.type_to_str(Type) while vfmt; contains `os.`
|
||||||
is_fmt bool
|
is_fmt bool
|
||||||
used_features &UsedFeatures = &UsedFeatures{} // filled in by the checker/markused, when pref.skip_unused = true;
|
used_features &UsedFeatures = &UsedFeatures{} // filled in by the builder via markused module, when pref.skip_unused = true;
|
||||||
veb_res_idx_cache int // Cache of `veb.Result` type
|
veb_res_idx_cache int // Cache of `veb.Result` type
|
||||||
veb_ctx_idx_cache int // Cache of `veb.Context` type
|
veb_ctx_idx_cache int // Cache of `veb.Context` type
|
||||||
panic_handler FnPanicHandler = default_table_panic_handler
|
panic_handler FnPanicHandler = default_table_panic_handler
|
||||||
|
@ -196,6 +196,9 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
|
|||||||
all_fn_root_names << k
|
all_fn_root_names << k
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// if mfn.name == 'before_request' {
|
||||||
|
// all_fn_root_names << k
|
||||||
|
//}
|
||||||
|
|
||||||
// sync:
|
// sync:
|
||||||
if k == 'sync.new_channel_st' {
|
if k == 'sync.new_channel_st' {
|
||||||
@ -338,6 +341,8 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
|
|||||||
|
|
||||||
if 'C.cJSON_Parse' in all_fns {
|
if 'C.cJSON_Parse' in all_fns {
|
||||||
all_fn_root_names << 'tos5'
|
all_fn_root_names << 'tos5'
|
||||||
|
all_fn_root_names << 'time.unix' // used by json
|
||||||
|
table.used_features.used_maps++ // json needs new_map etc
|
||||||
}
|
}
|
||||||
mut walker := Walker.new(
|
mut walker := Walker.new(
|
||||||
table: table
|
table: table
|
||||||
@ -349,6 +354,7 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
|
|||||||
)
|
)
|
||||||
// println( all_fns.keys() )
|
// println( all_fns.keys() )
|
||||||
walker.mark_markused_fns() // tagged with `@[markused]`
|
walker.mark_markused_fns() // tagged with `@[markused]`
|
||||||
|
|
||||||
walker.mark_markused_consts() // tagged with `@[markused]`
|
walker.mark_markused_consts() // tagged with `@[markused]`
|
||||||
walker.mark_markused_globals() // tagged with `@[markused]`
|
walker.mark_markused_globals() // tagged with `@[markused]`
|
||||||
walker.mark_exported_fns()
|
walker.mark_exported_fns()
|
||||||
@ -405,6 +411,7 @@ pub fn mark_used(mut table ast.Table, mut pref_ pref.Preferences, ast_files []&a
|
|||||||
walker.mark_const_as_used(kcon)
|
walker.mark_const_as_used(kcon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table.used_features.used_fns = walker.used_fns.move()
|
table.used_features.used_fns = walker.used_fns.move()
|
||||||
table.used_features.used_consts = walker.used_consts.move()
|
table.used_features.used_consts = walker.used_consts.move()
|
||||||
table.used_features.used_globals = walker.used_globals.move()
|
table.used_features.used_globals = walker.used_globals.move()
|
||||||
|
@ -335,6 +335,7 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
|
|||||||
res.use_cache = true
|
res.use_cache = true
|
||||||
res.skip_unused = true
|
res.skip_unused = true
|
||||||
} */
|
} */
|
||||||
|
mut no_skip_unused := false
|
||||||
|
|
||||||
mut command, mut command_idx := '', 0
|
mut command, mut command_idx := '', 0
|
||||||
for i := 0; i < args.len; i++ {
|
for i := 0; i < args.len; i++ {
|
||||||
@ -602,6 +603,7 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
|
|||||||
res.skip_unused = true
|
res.skip_unused = true
|
||||||
}
|
}
|
||||||
'-no-skip-unused' {
|
'-no-skip-unused' {
|
||||||
|
no_skip_unused = true
|
||||||
res.skip_unused = false
|
res.skip_unused = false
|
||||||
}
|
}
|
||||||
'-compress' {
|
'-compress' {
|
||||||
@ -1134,6 +1136,13 @@ pub fn parse_args_and_show_errors(known_external_commands []string, args []strin
|
|||||||
res.build_options = m.keys()
|
res.build_options = m.keys()
|
||||||
// eprintln('>> res.build_options: $res.build_options')
|
// eprintln('>> res.build_options: $res.build_options')
|
||||||
res.fill_with_defaults()
|
res.fill_with_defaults()
|
||||||
|
if res.backend == .c {
|
||||||
|
// res.skip_unused = true
|
||||||
|
if no_skip_unused {
|
||||||
|
res.skip_unused = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return res, command
|
return res, command
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user