diff --git a/0.3_roadmap.txt b/0.3_roadmap.txt index 7a5d68db6c..28d8b58e4d 100644 --- a/0.3_roadmap.txt +++ b/0.3_roadmap.txt @@ -3,6 +3,7 @@ - make `-autofree` the default - coroutines ++ channels - lock{} - thread safe arrays/maps - C2V translator diff --git a/vlib/v/gen/js/js.v b/vlib/v/gen/js/js.v index 78571f12a2..1a13a8439f 100644 --- a/vlib/v/gen/js/js.v +++ b/vlib/v/gen/js/js.v @@ -280,12 +280,19 @@ pub fn (mut g JsGen) typ(t table.Type) string { .interface_ { styp = g.js_name(sym.name) } + .rune { + styp = 'any' + } } - /* else { + /* + else { println('jsgen.typ: Unhandled type $t') styp = sym.name - } */ - if styp.starts_with('JS.') { return styp[3..] } + } + */ + if styp.starts_with('JS.') { + return styp[3..] + } return styp } @@ -1108,7 +1115,7 @@ fn (mut g JsGen) gen_array_init_expr(it ast.ArrayInit) { // 2) Give the code unnecessary complexity // 3) Have several limitations like missing most `Array.prototype` methods // 4) Modern engines can optimize regular arrays into typed arrays anyways, - // offering similar performance + // offering similar performance if it.has_len { t1 := g.new_tmp_var() t2 := g.new_tmp_var() @@ -1259,17 +1266,21 @@ fn (mut g JsGen) gen_if_expr(node ast.IfExpr) { g.expr(branch.cond) g.writeln(') {') } else if i == node.branches.len - 1 && node.has_else { - /* if is_guard { + /* + if is_guard { //g.writeln('} if (!$guard_ok) { /* else */') - } else { */ + } else { + */ g.writeln('} else {') // } } g.stmts(branch.stmts) } - /* if is_guard { + /* + if is_guard { g.write('}') - } */ + } + */ g.writeln('}') g.writeln('') } @@ -1334,7 +1345,8 @@ fn (mut g JsGen) gen_infix_expr(it ast.InfixExpr) { g.write('.push(') if r_sym.kind == .array { g.write('...') - } // arr << [1, 2] + } + // arr << [1, 2] g.expr(it.right) g.write(')') } else if r_sym.kind in [.array, .map, .string] && it.op in [.key_in, .not_in] { diff --git a/vlib/v/table/atypes.v b/vlib/v/table/atypes.v index 0688312f3e..86202ae323 100644 --- a/vlib/v/table/atypes.v +++ b/vlib/v/table/atypes.v @@ -15,8 +15,8 @@ import strings pub type Type int -pub type TypeInfo = Alias | Array | ArrayFixed | Chan | Enum | FnType | GenericStructInst | Interface | - Map | MultiReturn | Struct | SumType +pub type TypeInfo = Alias | Array | ArrayFixed | Chan | Enum | FnType | GenericStructInst | + Interface | Map | MultiReturn | Struct | SumType pub enum Language { v @@ -305,7 +305,7 @@ pub const ( pub const ( builtin_type_names = ['void', 'voidptr', 'charptr', 'byteptr', 'i8', 'i16', 'int', 'i64', 'u16', 'u32', 'u64', 'any_int', 'f32', 'f64', 'any_float', 'string', 'ustring', 'char', 'byte', 'bool', - 'none', 'array', 'array_fixed', 'map', 'chan', 'any', 'struct', 'mapnode', 'size_t'] + 'none', 'array', 'array_fixed', 'map', 'chan', 'any', 'struct', 'mapnode', 'size_t', 'rune'] ) pub struct MultiReturn { @@ -338,6 +338,7 @@ pub enum Kind { f64 char size_t + rune bool none_ string @@ -593,6 +594,12 @@ pub fn (mut t Table) register_builtin_type_symbols() { source_name: 'size_t' mod: 'builtin' }) + t.register_type_symbol({ + kind: .size_t + name: 'rune' + source_name: 'rune' + mod: 'builtin' + }) // TODO: remove. for v1 map compatibility map_string_string_idx := t.find_or_register_map(string_type, string_type) map_string_int_idx := t.find_or_register_map(string_type, int_type) @@ -671,6 +678,7 @@ pub fn (k Kind) str() string { .interface_ { 'interface' } .ustring { 'ustring' } .generic_struct_inst { 'generic_struct_inst' } + .rune { 'rune' } } return k_str } @@ -756,7 +764,7 @@ pub mut: pub struct Chan { pub mut: - elem_type Type + elem_type Type } pub struct Map { diff --git a/vlib/v/util/vtest/vtest.v b/vlib/v/util/vtest/vtest.v index 7a4572a3f9..0f55080fc5 100644 --- a/vlib/v/util/vtest/vtest.v +++ b/vlib/v/util/vtest/vtest.v @@ -7,6 +7,7 @@ pub struct FilterVTestConfig { fix_slashes bool = true } +// if VTEST_ONLY env var is set, returns tests that match the query pub fn filter_vtest_only(paths []string, config FilterVTestConfig) []string { mut res := []string{} patterns := os.getenv('VTEST_ONLY').split(',')