Skip to content

Commit

Permalink
V 0.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed May 20, 2024
1 parent 774253e commit 736067d
Show file tree
Hide file tree
Showing 8 changed files with 425 additions and 61 deletions.
333 changes: 333 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions cmd/tools/changelog_helper.v
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn (mut app App) process_line(text string) ! {
// exit(0)
//}
if (semicolon_pos < 15
&& prefix in ['checker', 'cgen', 'parser', 'v.parser', 'ast', 'jsgen', 'v.gen.js', 'fmt', 'vfmt'])
&& prefix in ['checker', 'cgen', 'parser', 'v.parser', 'ast', 'jsgen', 'v.gen.js', 'fmt', 'vfmt', 'tools'])
|| (semicolon_pos < 30 && prefix.contains(', ')) {
s = '- ' + text[semicolon_pos + 2..].capitalize()
}
Expand Down Expand Up @@ -348,12 +348,6 @@ const db_strings = [
'pg:',
]

const improvements_strings = [
'all:',
'v:',
'coroutines:',
]

const parser_strings = [
'parser:',
'ast:',
Expand All @@ -367,6 +361,7 @@ const stdlib_strings = [
'sync:',
'datatypes:',
'math:',
'math.',
'math.big',
'crypto',
'sokol',
Expand All @@ -376,11 +371,11 @@ const stdlib_strings = [
'toml:',
'vlib:',
'arrays:',
'math.',
'os.',
'term:',
'sync.',
'builtin:',
'builtin,',
'strconv',
'readline',
'cli:',
Expand Down Expand Up @@ -439,6 +434,13 @@ fn is_internal(text string) bool {
return is_xxx(text, internal_strings)
}

const improvements_strings = [
'all:',
'v:',
'coroutines:',
'autofree',
]

fn is_improvements(text string) bool {
return is_xxx(text, improvements_strings)
}
Expand Down Expand Up @@ -469,6 +471,8 @@ const tools_strings = [
'vtest',
'repl',
'REPL',
'vet',
'tools.',
]

fn is_tools(text string) bool {
Expand Down
2 changes: 1 addition & 1 deletion v.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Module {
name: 'V'
description: 'The V programming language.'
version: '0.4.5'
version: '0.4.6'
license: 'MIT'
repo_url: 'https://github.com/vlang/v'
dependencies: []
Expand Down
4 changes: 4 additions & 0 deletions vlib/builtin/int.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ module builtin
// ----- value to string functions -----
//

pub struct VContext {
allocator int
}

// type u8 = byte
type byte = u8

Expand Down
2 changes: 1 addition & 1 deletion vlib/semver/v.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Module {
name: 'semver'
version: '0.4.5'
version: '0.4.6'
deps: []
}
22 changes: 22 additions & 0 deletions vlib/v/checker/fn.v
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,14 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
continue
}
}
// if first_sym.name == 'VContext' && f.params[0].name == 'ctx' { // TODO use int comparison for perf
//}
/*
if param_typ_sym.info is ast.Struct && param_typ_sym.name == 'VContext' {
c.note('ok', call_arg.pos)
continue
}
*/
c.error('${err.msg()} in argument ${i + 1} to `${fn_name}`', call_arg.pos)
}
if final_param_sym.kind == .struct_ && arg_typ !in [ast.voidptr_type, ast.nil_type]
Expand Down Expand Up @@ -2644,6 +2652,7 @@ fn (mut c Checker) check_expected_arg_count(mut node ast.CallExpr, f &ast.Fn) !
}
if nr_args < min_required_params {
if min_required_params == nr_args + 1 {
// params struct?
last_typ := f.params.last().typ
last_sym := c.table.sym(last_typ)
if last_sym.info is ast.Struct {
Expand All @@ -2658,6 +2667,19 @@ fn (mut c Checker) check_expected_arg_count(mut node ast.CallExpr, f &ast.Fn) !
return
}
}
// Implicit context first arg?
/*
first_typ := f.params[0].typ
first_sym := c.table.sym(first_typ)
if first_sym.info is ast.Struct {
if c.fileis('a.v') {
if first_sym.name == 'VContext' && f.params[0].name == 'ctx' { // TODO use int comparison for perf
// c.error('got ctx ${first_sym.name}', node.pos)
return
}
}
}
*/
}
c.error('expected ${min_required_params} arguments, but got ${nr_args}', node.pos)
return error('')
Expand Down
51 changes: 0 additions & 51 deletions vlib/v/util/version/version.c.v
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
module version

import os

pub const v_version = '0.4.5'

// vhash() returns the build string C.V_COMMIT_HASH . See cmd/tools/gen_vc.v .
pub fn vhash() string {
mut buf := [50]u8{}
Expand All @@ -14,50 +10,3 @@ pub fn vhash() string {
return tos_clone(bp)
}
}

pub fn full_hash() string {
build_hash := vhash()
current_hash := @VCURRENTHASH
if build_hash == current_hash {
return build_hash
}
return '${build_hash}.${current_hash}'
}

// full_v_version() returns the full version of the V compiler
pub fn full_v_version(is_verbose bool) string {
if is_verbose {
return 'V ${version.v_version} ${full_hash()}'
}
return 'V ${version.v_version} ${@VCURRENTHASH}'
}

// githash tries to find the current git commit hash for the specified
// project path by parsing the relevant files in its `.git/` folder.
pub fn githash(path string) !string {
// .git/HEAD
git_head_file := os.join_path(path, '.git', 'HEAD')
if !os.exists(git_head_file) {
return error('failed to find `${git_head_file}`')
}
// 'ref: refs/heads/master' ... the current branch name
head_content := os.read_file(git_head_file) or {
return error('failed to read `${git_head_file}`')
}
current_branch_hash := if head_content.starts_with('ref: ') {
rev_rel_path := head_content.replace('ref: ', '').trim_space()
rev_file := os.join_path(path, '.git', rev_rel_path)
// .git/refs/heads/master
if !os.exists(rev_file) {
return error('failed to find revision file `${rev_file}`')
}
// get the full commit hash contained in the ref heads file
os.read_file(rev_file) or { return error('failed to read revision file `${rev_file}`') }
} else {
head_content
}
desired_hash_length := 7
return current_branch_hash[0..desired_hash_length] or {
error('failed to limit hash `${current_branch_hash}` to ${desired_hash_length} characters')
}
}
52 changes: 52 additions & 0 deletions vlib/v/util/version/version.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
module version

import os

pub const v_version = '0.4.6'

pub fn full_hash() string {
build_hash := vhash()
current_hash := @VCURRENTHASH
if build_hash == current_hash {
return build_hash
}
return '${build_hash}.${current_hash}'
}

// full_v_version() returns the full version of the V compiler
pub fn full_v_version(is_verbose bool) string {
if is_verbose {
return 'V ${version.v_version} ${full_hash()}'
}
return 'V ${version.v_version} ${@VCURRENTHASH}'
}

// githash tries to find the current git commit hash for the specified
// project path by parsing the relevant files in its `.git/` folder.
pub fn githash(path string) !string {
// .git/HEAD
git_head_file := os.join_path(path, '.git', 'HEAD')
if !os.exists(git_head_file) {
return error('failed to find `${git_head_file}`')
}
// 'ref: refs/heads/master' ... the current branch name
head_content := os.read_file(git_head_file) or {
return error('failed to read `${git_head_file}`')
}
current_branch_hash := if head_content.starts_with('ref: ') {
rev_rel_path := head_content.replace('ref: ', '').trim_space()
rev_file := os.join_path(path, '.git', rev_rel_path)
// .git/refs/heads/master
if !os.exists(rev_file) {
return error('failed to find revision file `${rev_file}`')
}
// get the full commit hash contained in the ref heads file
os.read_file(rev_file) or { return error('failed to read revision file `${rev_file}`') }
} else {
head_content
}
desired_hash_length := 7
return current_branch_hash[0..desired_hash_length] or {
error('failed to limit hash `${current_branch_hash}` to ${desired_hash_length} characters')
}
}

0 comments on commit 736067d

Please sign in to comment.