--enable-globals

pull/2650/head
Alexander Medvednikov 2019-11-05 02:43:52 +03:00
parent f8d14a216b
commit f60d44eda9
2 changed files with 8 additions and 2 deletions

View File

@ -116,6 +116,7 @@ pub mut:
//generating_vh bool
comptime_define string // -D vfmt for `if $vfmt {`
fast bool // use tcc/x64 codegen
enable_globals bool // allow __global for low level code
}
// Should be called by main at the end of the compilation process, to cleanup
@ -934,6 +935,7 @@ pub fn new_v(args[]string) &V {
is_run: 'run' in args
autofree: '-autofree' in args
compress: '-compress' in args
enable_globals: '--enable-globals' in args
fast: '-fast' in args
is_repl: is_repl
build_mode: build_mode

View File

@ -373,8 +373,12 @@ fn (p mut Parser) parse(pass Pass) {
.key_global {
if !p.pref.translated && !p.pref.is_live &&
!p.builtin_mod && !p.pref.building_v &&
p.mod != 'ui' && !os.getwd().contains('/volt') {
p.error('__global is only allowed in translated code')
p.mod != 'ui' && !os.getwd().contains('/volt') &&
!p.pref.enable_globals
{
p.error('use `v --enable-globals ...` to enable globals')
//p.error('__global is only allowed in translated code')
}
p.next()
name := p.check_name()