fix repl tests; change asm syntax a bit

pull/2796/head
Alexander Medvednikov 2019-11-18 04:53:46 +03:00
parent f7c7ffecb3
commit 4c0269597d
5 changed files with 11 additions and 15 deletions

View File

@ -29,9 +29,9 @@ else
echo "Self rebuild ($$VC_V => $$V_V)"; \ echo "Self rebuild ($$VC_V => $$V_V)"; \
./v -o v v.v; \ ./v -o v v.v; \
fi) fi)
./v build module vlib/builtin ./v build module vlib/builtin > /dev/null
./v build module vlib/strings ./v build module vlib/strings > /dev/null
./v build module vlib/strconv ./v build module vlib/strconv > /dev/null
endif endif
rm -rf vc/ rm -rf vc/
@echo "V has been successfully built" @echo "V has been successfully built"

View File

@ -9,7 +9,7 @@ fn (p mut Parser) inline_asm() {
p.error('asm() needs to be run unside `unsafe {}`') p.error('asm() needs to be run unside `unsafe {}`')
} }
p.next() p.next()
p.check(.lpar) p.check(.lcbr)
s := p.check_string() s := p.check_string()
p.genln('asm("$s"') p.genln('asm("$s"')
for p.tok == .str { for p.tok == .str {
@ -28,11 +28,8 @@ fn (p mut Parser) inline_asm() {
} }
p.check(.rpar) p.check(.rpar)
p.genln('($var_name)') p.genln('($var_name)')
} }
} }
p.genln(');') p.genln(');')
p.check(.rpar) p.check(.rcbr)
} }

View File

@ -82,7 +82,7 @@ fn (v mut V) cc() {
// TODO : try and remove the below workaround options when the corresponding // TODO : try and remove the below workaround options when the corresponding
// warnings are totally fixed/removed // warnings are totally fixed/removed
'-Wno-unused-variable', '-Wno-unused-variable',
'-Wno-unused-but-set-variable', //'-Wno-unused-but-set-variable',
'-Wno-unused-parameter', '-Wno-unused-parameter',
'-Wno-unused-result', '-Wno-unused-result',
'-Wno-missing-braces', '-Wno-missing-braces',

View File

@ -433,7 +433,7 @@ pub fn (v mut V) generate_main() {
if !v.table.main_exists() && !v.pref.is_test { if !v.table.main_exists() && !v.pref.is_test {
// It can be skipped in single file programs // It can be skipped in single file programs
// But make sure that there's some code outside of main() // But make sure that there's some code outside of main()
if v.pref.is_script && cgen.fn_main.trim_space() != ''{ if (v.pref.is_script && cgen.fn_main.trim_space() != '') || v.pref.is_repl {
//println('Generating main()...') //println('Generating main()...')
v.gen_main_start(true) v.gen_main_start(true)
cgen.genln('$cgen.fn_main;') cgen.genln('$cgen.fn_main;')
@ -955,7 +955,6 @@ pub fn new_v(args[]string) &V {
is_vlines: '-g' in args && !('-cg' in args) is_vlines: '-g' in args && !('-cg' in args)
is_keep_c: '-keep_c' in args is_keep_c: '-keep_c' in args
is_cache: '-cache' in args is_cache: '-cache' in args
is_stats: '-stats' in args is_stats: '-stats' in args
obfuscate: obfuscate obfuscate: obfuscate
is_prof: '-prof' in args is_prof: '-prof' in args

View File

@ -2,25 +2,25 @@ fn test_inline_asm() {
a := 10 a := 10
b := 0 b := 0
unsafe { unsafe {
asm ( asm {
"movl %1, %%eax;" "movl %1, %%eax;"
"movl %%eax, %0;" "movl %%eax, %0;"
:"=r"(b) :"=r"(b)
:"r"(a) :"r"(a)
:"%eax" :"%eax"
) }
} }
assert a == 10 assert a == 10
assert b == 10 assert b == 10
// //
e := 0 e := 0
unsafe { unsafe {
asm( asm {
//".intel_syntax noprefix;" //".intel_syntax noprefix;"
//"mov %0, 5" //"mov %0, 5"
"movl $5, %0" "movl $5, %0"
:"=a"(e) :"=a"(e)
) }
} }
assert e == 5 assert e == 5
} }