Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix_lambda_opt
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Nov 26, 2023
2 parents 1d54d18 + 51bb276 commit 88325dd
Show file tree
Hide file tree
Showing 449 changed files with 10,671 additions and 11,388 deletions.
10 changes: 4 additions & 6 deletions bench/vectors/vectors.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ struct Vector {
z f64
}

const (
boids_count = 10000
max_coordinate = 10000.0
cohesion_distance = 10.0
separation_distance = 5.0
)
const boids_count = 10000
const max_coordinate = 10000.0
const cohesion_distance = 10.0
const separation_distance = 5.0

@[direct_array_access]
fn main() {
Expand Down
34 changes: 16 additions & 18 deletions cmd/tools/check_os_api_parity.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,22 @@ import v.ast
import rand
import term

const (
base_os = 'linux'
os_names = ['linux', 'macos', 'windows', 'freebsd', 'openbsd', 'solaris', 'termux']
skip_modules = [
'builtin.bare',
'builtin.linux_bare.old',
'builtin.js',
'strconv',
'strconv.ftoa',
'hash',
'strings',
'crypto.rand',
'os.bare',
'os2',
'szip',
'v.eval',
]
)
const base_os = 'linux'
const os_names = ['linux', 'macos', 'windows', 'freebsd', 'openbsd', 'solaris', 'termux']
const skip_modules = [
'builtin.bare',
'builtin.linux_bare.old',
'builtin.js',
'strconv',
'strconv.ftoa',
'hash',
'strings',
'crypto.rand',
'os.bare',
'os2',
'szip',
'v.eval',
]

struct App {
diff_cmd string
Expand Down
82 changes: 36 additions & 46 deletions cmd/tools/gen_vc.v
Original file line number Diff line number Diff line change
Expand Up @@ -22,60 +22,50 @@ import net.urllib
// --force force update even if already up to date

// git credentials
const (
git_username = os.getenv('GITUSER')
git_password = os.getenv('GITPASS')
)
const git_username = os.getenv('GITUSER')
const git_password = os.getenv('GITPASS')

// repository
const (
// git repo
git_repo_v = 'github.com/vlang/v'
git_repo_vc = 'github.com/vlang/vc'
// local repo directories
git_repo_dir_v = 'v'
git_repo_dir_vc = 'vc'
)
// git repo
const git_repo_v = 'github.com/vlang/v'
const git_repo_vc = 'github.com/vlang/vc'
// local repo directories
const git_repo_dir_v = 'v'
const git_repo_dir_vc = 'vc'

// gen_vc
const (
// name
app_name = 'gen_vc'
// version
app_version = '0.1.3'
// description
app_description = "This tool regenerates V's bootstrap .c files every time the V master branch is updated."
// assume something went wrong if file size less than this
too_short_file_limit = 5000
// create a .c file for these os's
vc_build_oses = [
'nix',
// all nix based os
'windows',
]
)
// name
const app_name = 'gen_vc'
// version
const app_version = '0.1.3'
// description
const app_description = "This tool regenerates V's bootstrap .c files every time the V master branch is updated."
// assume something went wrong if file size less than this
const too_short_file_limit = 5000
// create a .c file for these os's
const vc_build_oses = [
'nix',
// all nix based os
'windows',
]

// default options (overridden by flags)
const (
// gen_vc working directory
work_dir = '/tmp/gen_vc'
// dont push anything to remote repo
dry_run = false
// server port
server_port = 7171
// log file
log_file = '${work_dir}/log.txt'
// log_to is either 'file' or 'terminal'
log_to = 'terminal'
)
// gen_vc working directory
const work_dir = '/tmp/gen_vc'
// dont push anything to remote repo
const dry_run = false
// server port
const server_port = 7171
// log file
const log_file = '${work_dir}/log.txt'
// log_to is either 'file' or 'terminal'
const log_to = 'terminal'

// errors
const (
err_msg_build = 'error building'
err_msg_make = 'make failed'
err_msg_gen_c = 'failed to generate .c file'
err_msg_cmd_x = 'error running cmd'
)
const err_msg_build = 'error building'
const err_msg_make = 'make failed'
const err_msg_gen_c = 'failed to generate .c file'
const err_msg_cmd_x = 'error running cmd'

struct GenVC {
// logger
Expand Down
4 changes: 1 addition & 3 deletions cmd/tools/modules/scripting/scripting.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import os
import term
import time

const (
term_colors = term.can_show_color_on_stdout()
)
const term_colors = term.can_show_color_on_stdout()

pub fn set_verbose(on bool) {
// setting a global here would be the obvious solution,
Expand Down
6 changes: 2 additions & 4 deletions cmd/tools/oldv.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import flag
import scripting
import vgit

const (
tool_version = '0.0.4'
tool_description = ' Checkout an old V and compile it as it was on specific commit.
const tool_version = '0.0.4'
const tool_description = ' Checkout an old V and compile it as it was on specific commit.
| This tool is useful, when you want to discover when something broke.
| It is also useful, when you just want to experiment with an older historic V.
|
Expand All @@ -25,7 +24,6 @@ const (
| ## until you find the commit, where the problem first occurred.
| ## When you finish, do not forget to do:
| git bisect reset'.strip_margin()
)

struct Context {
mut:
Expand Down
6 changes: 2 additions & 4 deletions cmd/tools/performance_compare.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import flag
import scripting
import vgit

const (
tool_version = '0.0.6'
tool_description = " Compares V executable size and performance,
const tool_version = '0.0.6'
const tool_description = " Compares V executable size and performance,
| between 2 commits from V's local git history.
| When only one commit is given, it is compared to master.
| ".strip_margin()
)

struct Context {
cwd string // current working folder
Expand Down
9 changes: 4 additions & 5 deletions cmd/tools/repeat.v
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,10 @@ fn (a Aints) str() string {
'ms ± σ: ${a.stddev:4.1f}ms, min: ${a.imin:4}ms, max: ${a.imax:4}ms, runs:${a.values.len:3}, nmins:${a.nmins:2}, nmaxs:${a.nmaxs:2}'
}

const (
max_fail_percent = 100 * 1000
max_time = 60 * 1000 // ms
performance_regression_label = 'Performance regression detected, failing since '
)
const max_fail_percent = 100 * 1000
const max_time = 60 * 1000 // ms

const performance_regression_label = 'Performance regression detected, failing since '

fn main() {
mut context := Context{}
Expand Down
8 changes: 3 additions & 5 deletions cmd/tools/test_if_v_test_system_works.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ module main
import os
import rand

const (
vexe = os.quoted_path(get_vexe_path())
vroot = os.dir(vexe)
tdir = new_tdir()
)
const vexe = os.quoted_path(get_vexe_path())
const vroot = os.dir(vexe)
const tdir = new_tdir()

fn get_vexe_path() string {
env_vexe := os.getenv('VEXE')
Expand Down
8 changes: 3 additions & 5 deletions cmd/tools/vast/test/demo.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import math
import time { Time, now }

// const decl
const (
a = 1
b = 3
c = 'c'
)
const a = 1
const b = 3
const c = 'c'

// struct decl
struct Point {
Expand Down
18 changes: 7 additions & 11 deletions cmd/tools/vbin2v.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import os
import flag
import strings

const (
tool_version = '0.0.4'
tool_description = 'Converts a list of arbitrary files into a single v module file.'
)
const tool_version = '0.0.4'
const tool_description = 'Converts a list of arbitrary files into a single v module file.'

struct Context {
mut:
Expand Down Expand Up @@ -38,27 +36,25 @@ fn (context Context) header() string {
header_s += '// v bin2v ${allfiles} ${soptions}\n'
header_s += '// Please, do not edit this file.\n'
header_s += '// Your changes may be overwritten.\n'
header_s += 'const (\n'
return header_s
}

fn (context Context) footer() string {
return ')\n'
return ''
}

fn (context Context) file2v(bname string, fbytes []u8, bn_max int) string {
mut sb := strings.new_builder(1000)
bn_diff_len := bn_max - bname.len
sb.write_string('\t${bname}_len' + ' '.repeat(bn_diff_len - 4) + ' = ${fbytes.len}\n')
sb.write_string('const ${bname}_len' + ' = ${fbytes.len}\n')
fbyte := fbytes[0]
bnmae_line := '\t${bname}' + ' '.repeat(bn_diff_len) + ' = [u8(${fbyte}), '
bnmae_line := 'const ${bname}' + ' = [u8(${fbyte}), '
sb.write_string(bnmae_line)
mut line_len := bnmae_line.len + 3
for i := 1; i < fbytes.len; i++ {
b := int(fbytes[i]).str()
if line_len > 94 {
if line_len > 98 {
sb.go_back(1)
sb.write_string('\n\t\t')
sb.write_string('\n\t')
line_len = 8
}
if i == fbytes.len - 1 {
Expand Down
11 changes: 5 additions & 6 deletions cmd/tools/vbump.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import os
import regex
import semver

const (
tool_name = os.file_name(os.executable())
tool_version = '0.1.0'
tool_description = '\n Bump the semantic version of the v.mod and/or specified files.
const tool_name = os.file_name(os.executable())
const tool_version = '0.1.0'
const tool_description = '\n Bump the semantic version of the v.mod and/or specified files.
The first instance of a version number is replaced with the new version.
Additionally, the line affected must contain the word "version" in any
Expand All @@ -34,8 +33,8 @@ Examples:
Upgrade the minor version in sample.v only
v bump --minor sample.v
'
semver_query = r'((0)|([1-9]\d*)\.){2}(0)|([1-9]\d*)(\-[\w\d\.\-_]+)?(\+[\w\d\.\-_]+)?'
)

const semver_query = r'((0)|([1-9]\d*)\.){2}(0)|([1-9]\d*)(\-[\w\d\.\-_]+)?(\+[\w\d\.\-_]+)?'

struct Options {
show_help bool
Expand Down
21 changes: 9 additions & 12 deletions cmd/tools/vbump_test.v
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import os

const (
vexe = @VEXE
tfolder = os.join_path(os.vtmp_dir(), 'vbump')
)
const vexe = @VEXE
const tfolder = os.join_path(os.vtmp_dir(), 'vbump')

fn testsuite_begin() {
os.mkdir_all(tfolder) or {}
Expand Down Expand Up @@ -59,18 +57,17 @@ version = '1.5.1'
import os
import flag
const (
tool_name = os.file_name(os.executable())
tool_version = '0.1.33'
)
const tool_name = os.file_name(os.executable())
const tool_version = '0.1.33'
fn main() {
// stuff
}
"
line: 6
expected_patch: " tool_version = '0.1.34'"
expected_minor: " tool_version = '0.2.0'"
expected_major: " tool_version = '1.0.0'"
line: 5
expected_patch: "const tool_version = '0.1.34'"
expected_minor: "const tool_version = '0.2.0'"
expected_major: "const tool_version = '1.0.0'"
},
]

Expand Down
28 changes: 13 additions & 15 deletions cmd/tools/vcheck-md.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,19 @@ import term
import v.help
import regex

const (
too_long_line_length_example = 120
too_long_line_length_codeblock = 120
too_long_line_length_table = 120
too_long_line_length_link = 150
too_long_line_length_other = 100
term_colors = term.can_show_color_on_stderr()
hide_warnings = '-hide-warnings' in os.args || '-w' in os.args
show_progress = os.getenv('GITHUB_JOB') == '' && '-silent' !in os.args
non_option_args = cmdline.only_non_options(os.args[2..])
is_verbose = os.getenv('VERBOSE') != ''
vcheckfolder = os.join_path(os.vtmp_dir(), 'vcheck_${os.getuid()}')
should_autofix = os.getenv('VAUTOFIX') != ''
vexe = @VEXE
)
const too_long_line_length_example = 120
const too_long_line_length_codeblock = 120
const too_long_line_length_table = 120
const too_long_line_length_link = 150
const too_long_line_length_other = 100
const term_colors = term.can_show_color_on_stderr()
const hide_warnings = '-hide-warnings' in os.args || '-w' in os.args
const show_progress = os.getenv('GITHUB_JOB') == '' && '-silent' !in os.args
const non_option_args = cmdline.only_non_options(os.args[2..])
const is_verbose = os.getenv('VERBOSE') != ''
const vcheckfolder = os.join_path(os.vtmp_dir(), 'vcheck_${os.getuid()}')
const should_autofix = os.getenv('VAUTOFIX') != ''
const vexe = @VEXE

struct CheckResult {
pub mut:
Expand Down
Loading

0 comments on commit 88325dd

Please sign in to comment.