mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: streamline main function handling
* compiler: streamline C main function generation * fix most tests * compiler: fix for 'go update()' in graph.v . More precise parser error messages. * Fix temporarily examples/hot_reload/message.v by using os inside it (os.clear). * Make graph.v easier to quickly modify by defining y outside the loop. * Fix failure of /v/nv/compiler/tests/defer_test.v when run with 'v -g' (#line directive was not on its own line, but right after } ). * Do not pass the os.args to tests, even if the tests import os (they are more stable when run in a controlled environment). * fix declared and not used in the js backend. * fix js main => main__main too.
This commit is contained in:

committed by
Alexander Medvednikov

parent
0160c7a89d
commit
a4cbe78d97
@ -4,7 +4,8 @@ import gx
|
||||
import gg
|
||||
import time
|
||||
import glfw
|
||||
// import math
|
||||
import math
|
||||
import os
|
||||
|
||||
const (
|
||||
Size = 700
|
||||
@ -16,6 +17,7 @@ struct Context {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
os.clear()
|
||||
glfw.init()
|
||||
ctx:= &Context{
|
||||
gg: gg.new_context(gg.Cfg {
|
||||
@ -40,11 +42,12 @@ fn main() {
|
||||
fn (ctx &Context) draw() {
|
||||
ctx.gg.draw_line(0, Size / 2, Size, Size / 2) // x axis
|
||||
ctx.gg.draw_line(Size / 2, 0, Size / 2, Size) // y axis
|
||||
center := f64(Size / 2)
|
||||
center := f64(Size / 2)
|
||||
mut y := 0.0
|
||||
for x := -10.0; x <= 10.0; x += 0.002 {
|
||||
y := x * x - 1
|
||||
//y := (x + 3) * (x + 3) - 1
|
||||
//y := math.sqrt(30.0 - x * x)
|
||||
y = x * x - 1
|
||||
//y = (x + 3) * (x + 3) - 1
|
||||
//y = math.sqrt(30.0 - x * x)
|
||||
ctx.gg.draw_rect(center + x * Scale, center - y * Scale, 1, 1, gx.Black)
|
||||
//ctx.gg.draw_rect(center + x * Scale, center + y * Scale, 1, 1, gx.Black)
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// v -live message.v
|
||||
module main
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
[live]
|
||||
@ -10,6 +11,7 @@ fn print_message() {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
os.clear()
|
||||
for {
|
||||
print_message()
|
||||
time.sleep_ms(500)
|
||||
|
Reference in New Issue
Block a user