From f60d44eda9eb5b70cacea114fb07c11faf31cb34 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 5 Nov 2019 02:43:52 +0300 Subject: [PATCH] --enable-globals --- vlib/compiler/main.v | 2 ++ vlib/compiler/parser.v | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/vlib/compiler/main.v b/vlib/compiler/main.v index 550266bb50..0b1f18812d 100644 --- a/vlib/compiler/main.v +++ b/vlib/compiler/main.v @@ -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 diff --git a/vlib/compiler/parser.v b/vlib/compiler/parser.v index b59f44b397..d2e651f65b 100644 --- a/vlib/compiler/parser.v +++ b/vlib/compiler/parser.v @@ -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()