fix fn main generation
parent
f725aa2e8d
commit
1d9916f93e
22
v.v
22
v.v
|
@ -13,21 +13,21 @@ import (
|
|||
|
||||
const (
|
||||
known_commands = ['run', 'build', 'version', 'doc']
|
||||
simple_tools = ['fmt', 'up', 'create', 'test', 'test-fmt', 'test-compiler', 'build-tools', 'build-examples', 'build-vbinaries']
|
||||
simple_tools = ['fmt', 'up', 'create', 'test', 'test-fmt', 'test-compiler', 'build-tools',
|
||||
'build-examples', 'build-vbinaries']
|
||||
)
|
||||
|
||||
fn main() {
|
||||
is_verbose := '-verbose' in os.args || '--verbose' in os.args
|
||||
is_verbose := '-verbose' in os.args || '--verbose' in os.args
|
||||
// t := time.ticks()
|
||||
// defer { println(time.ticks() - t) }
|
||||
args := compiler.env_vflags_and_os_args()
|
||||
options, command := compiler.get_v_options_and_main_command( args )
|
||||
if is_verbose {
|
||||
eprintln('v args: $args')
|
||||
eprintln('v command: $command')
|
||||
eprintln('v options: $options')
|
||||
}
|
||||
|
||||
options,command := compiler.get_v_options_and_main_command(args)
|
||||
if is_verbose {
|
||||
eprintln('v args: $args')
|
||||
eprintln('v command: $command')
|
||||
eprintln('v options: $options')
|
||||
}
|
||||
// external tool
|
||||
if command in simple_tools {
|
||||
compiler.launch_tool('v' + command)
|
||||
|
@ -114,7 +114,9 @@ fn v_command(command string, args []string) {
|
|||
mod := args.last()
|
||||
os.system('$vexe build module vlib$os.path_separator' + args.last())
|
||||
vhfile := filepath.join(compiler.v_modules_path,'vlib','${mod}.vh')
|
||||
txt := os.read_file(vhfile) or { panic(err) }
|
||||
txt := os.read_file(vhfile) or {
|
||||
panic(err)
|
||||
}
|
||||
println(txt)
|
||||
// v.gen_doc_html_for_module(args.last())
|
||||
}
|
||||
|
|
|
@ -40,7 +40,12 @@ fn (g mut Gen) stmt(node ast.Stmt) {
|
|||
g.writeln(';')
|
||||
}
|
||||
ast.FnDecl {
|
||||
g.write('$it.typ.name ${it.name}(')
|
||||
if it.name == 'main' {
|
||||
g.write('int ${it.name}(')
|
||||
}
|
||||
else {
|
||||
g.write('$it.typ.name ${it.name}(')
|
||||
}
|
||||
for arg in it.args {
|
||||
g.write(arg.typ.name + ' ' + arg.name)
|
||||
}
|
||||
|
@ -48,6 +53,9 @@ fn (g mut Gen) stmt(node ast.Stmt) {
|
|||
for stmt in it.stmts {
|
||||
g.stmt(stmt)
|
||||
}
|
||||
if it.name == 'main' {
|
||||
g.writeln('return 0;')
|
||||
}
|
||||
g.writeln('}')
|
||||
}
|
||||
ast.Return {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
fn main() int {
|
||||
fn main() {
|
||||
a := 10
|
||||
return 0
|
||||
}
|
||||
|
|
|
@ -48,8 +48,7 @@ fn init_user() {
|
|||
}
|
||||
}
|
||||
|
||||
fn main() int {
|
||||
return 0
|
||||
fn main() {
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue