From f630d3f34240fc2036c502ee7e80f7779c71eba1 Mon Sep 17 00:00:00 2001 From: Shivanjan Chakravorty Date: Sat, 6 Jul 2019 15:37:44 +0530 Subject: [PATCH] main: vrepl interactive shell update --- compiler/main.v | 50 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/compiler/main.v b/compiler/main.v index 93a9df14ca..f8e7dcd55b 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -963,6 +963,7 @@ fn run_repl() []string { println('Use Ctrl-C or `exit` to exit') println('For now you have to use println() to print values, this will be fixed soon\n') file := TmpPath + '/vrepl.v' + temp_file := TmpPath + '/vrepl_temp.v' mut lines := []string for { print('>>> ') @@ -982,13 +983,52 @@ fn run_repl() []string { lines << void_line source_code := lines.join('\n') + '\n' + line os.write_file(file, source_code) - mut v := new_v( ['v', '-repl', file]) - v.compile() - s := os.exec(TmpPath + '/vrepl') - println(s) + s := os.exec('v run '+TmpPath+'/vrepl.v') + mut vals := s.split('\n') + if s.contains('panic: ') { + if !s.contains('declared and not used') { + for i:=1; i