diff --git a/vlib/benchmark/benchmark.v b/vlib/benchmark/benchmark.v index e45edec79b..a7f1837b76 100644 --- a/vlib/benchmark/benchmark.v +++ b/vlib/benchmark/benchmark.v @@ -24,7 +24,7 @@ bmark.stop() // call when you want to finalize the benchmark println( bmark.total_message('remarks about the benchmark') ) ``` -benchmark.start() and b.measure() are convenience methods, +benchmark.start() and b.measure() are convenience methods, intended to be used in combination. Their goal is to make benchmarking of small snippets of code as *short*, easy to write, and then to read and analyze the results, as possible. diff --git a/vlib/os/os.v b/vlib/os/os.v index fb662325e7..a3e255967f 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -704,14 +704,15 @@ pub fn get_raw_line() string { } } $else { max := size_t(0) - mut buf := byteptr(0) - nr_chars := C.getline(&charptr(buf), &max, stdin) - defer { unsafe{ free(buf) } } + mut buf := charptr(0) + nr_chars := C.getline(&buf, &max, stdin) + //defer { unsafe{ free(buf) } } if nr_chars == 0 || nr_chars == -1 { return '' } - res := tos_clone( buf ) - return res + return tos3(buf) + //res := tos_clone(buf) + //return res } } diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 35e7ab1f20..44957a722c 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -12,7 +12,7 @@ import ( ) const ( - max_nr_errors = 30 + max_nr_errors = 50 ) pub struct Checker { diff --git a/vlib/v/eval/eval.v b/vlib/v/eval/eval.v index 3894cfb85e..e316d90347 100644 --- a/vlib/v/eval/eval.v +++ b/vlib/v/eval/eval.v @@ -15,6 +15,7 @@ pub struct Eval { mut: checker checker.Checker vars map[string]Var + table &table.Table } pub struct Var { @@ -22,6 +23,7 @@ pub struct Var { } pub fn (e mut Eval) eval(file ast.File, table &table.Table) string { + e.table = table mut res := '' e.checker = checker.new_checker(table) for stmt in file.stmts { @@ -61,6 +63,9 @@ fn (e mut Eval) stmt(node ast.Stmt) string { print_object(o) return o.str() } + // ast.StructDecl { + // println('s decl') + // } ast.VarDecl { e.vars[it.name] = Var{ value: e.expr(it.expr) diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index ae7c7b37a4..a08ddae574 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -762,7 +762,7 @@ pub fn (p mut Parser) expr(precedence int) (ast.Expr,table.Type) { p.check(.rcbr) } else { - p.error('pexpr(): bad token `$p.tok.str()`') + p.error('parser: expr(): bad token `$p.tok.str()`') } } // Infix diff --git a/vlib/v/parser/parser_test.v b/vlib/v/parser/parser_test.v index eb3d15bb4d..4a7c00fb48 100644 --- a/vlib/v/parser/parser_test.v +++ b/vlib/v/parser/parser_test.v @@ -10,8 +10,11 @@ import ( ) fn test_eval() { + /* inputs := [ // + '2+2', + 'struct User { age int }', '2+3', '4', 'x := 10', @@ -32,9 +35,11 @@ fn test_eval() { '20', // ] - /* table := table.new_table() - mut scope := &ast.Scope{start_pos: 0, parent: 0} + mut scope := &ast.Scope{ + start_pos: 0 + parent: 0 + } mut stmts := []ast.Stmt for input in inputs { stmts << parse_stmt(input, table, scope) @@ -50,8 +55,9 @@ fn test_eval() { println('eval done') println(s) assert s == expected.join('\n') - // exit(0) + exit(0) */ + return } fn test_parse_file() { @@ -87,7 +93,10 @@ fn test_one() { ] expected := 'int a = 10;int b = -a;int c = 20;' table := table.new_table() - mut scope := &ast.Scope{start_pos: 0, parent: 0} + mut scope := &ast.Scope{ + start_pos: 0 + parent: 0 + } mut e := []ast.Stmt for line in input { e << parse_stmt(line, table, scope) @@ -179,7 +188,10 @@ fn test_parse_expr() { mut e := []ast.Stmt table := table.new_table() mut checker := checker.new_checker(table) - mut scope := &ast.Scope{start_pos: 0, parent: 0} + mut scope := &ast.Scope{ + start_pos: 0 + parent: 0 + } for s in input { println('\n\nst="$s"') e << parse_stmt(s, table, scope)