normal destructuring with one line changed
This commit is contained in:
@@ -291,7 +291,7 @@ func main[argc: i64, argv: ptr] : i64
|
|||||||
c := new CHIP8
|
c := new CHIP8
|
||||||
c->init()
|
c->init()
|
||||||
|
|
||||||
~buffer, ok := io.read_binary_file(path)
|
buffer, ok := io.read_binary_file(path)
|
||||||
if !ok
|
if !ok
|
||||||
panic("failed to read file")
|
panic("failed to read file")
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func main[argc: i64, argv: ptr] : i64
|
|||||||
if i < url_len
|
if i < url_len
|
||||||
path = url->substr(i, url_len - i)
|
path = url->substr(i, url_len - i)
|
||||||
|
|
||||||
~s, ok := net.connect(host, 80)
|
s, ok := net.connect(host, 80)
|
||||||
if !ok
|
if !ok
|
||||||
panic("failed to connect")
|
panic("failed to connect")
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ include "std/io.zr"
|
|||||||
include "std/net.zr"
|
include "std/net.zr"
|
||||||
|
|
||||||
func main[] : i64
|
func main[] : i64
|
||||||
~s, ok := net.listen("127.0.0.1", 8000)
|
s, ok := net.listen("127.0.0.1", 8000)
|
||||||
if !ok
|
if !ok
|
||||||
panic("failed to listen")
|
panic("failed to listen")
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ include "std/io.zr"
|
|||||||
include "std/net.zr"
|
include "std/net.zr"
|
||||||
|
|
||||||
func main[] : i64
|
func main[] : i64
|
||||||
~s, ok := net.create_udp_server("127.0.0.1", 8000)
|
s, ok := net.create_udp_server("127.0.0.1", 8000)
|
||||||
if !ok
|
if !ok
|
||||||
panic("net.create_udp_server failed")
|
panic("net.create_udp_server failed")
|
||||||
|
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ impl Parser {
|
|||||||
Ok(Stmt::Break)
|
Ok(Stmt::Break)
|
||||||
} else if self.match_token(&[TokenType::KeywordContinue]) {
|
} else if self.match_token(&[TokenType::KeywordContinue]) {
|
||||||
Ok(Stmt::Continue)
|
Ok(Stmt::Continue)
|
||||||
} else if self.match_token(&[TokenType::Tilde]) {
|
} else if self.check(&TokenType::Identifier) && self.check_ahead(&TokenType::Comma) {
|
||||||
let mut targets = vec![];
|
let mut targets = vec![];
|
||||||
loop {
|
loop {
|
||||||
targets.push(self.consume(Identifier, "expected an identifier")?);
|
targets.push(self.consume(Identifier, "expected an identifier")?);
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ pub enum TokenType {
|
|||||||
ShiftLeft,
|
ShiftLeft,
|
||||||
ShiftRight,
|
ShiftRight,
|
||||||
Arrow,
|
Arrow,
|
||||||
Tilde,
|
|
||||||
|
|
||||||
Equal,
|
Equal,
|
||||||
DoubleEqual,
|
DoubleEqual,
|
||||||
@@ -179,7 +178,6 @@ impl<'a> Tokenizer<'a> {
|
|||||||
'%' => self.add_token(TokenType::Mod)?,
|
'%' => self.add_token(TokenType::Mod)?,
|
||||||
'^' => self.add_token(TokenType::Xor)?,
|
'^' => self.add_token(TokenType::Xor)?,
|
||||||
':' => self.add_token(TokenType::Colon)?,
|
':' => self.add_token(TokenType::Colon)?,
|
||||||
'~' => self.add_token(TokenType::Tilde)?,
|
|
||||||
'-' => {
|
'-' => {
|
||||||
if self.match_char('=') {
|
if self.match_char('=') {
|
||||||
self.add_token(TokenType::MinusEqual)?
|
self.add_token(TokenType::MinusEqual)?
|
||||||
|
|||||||
10
std/net.zr
10
std/net.zr
@@ -22,7 +22,7 @@ func net.listen[host: str, port: i64] : i64, bool
|
|||||||
_builtin_syscall(SYS_close, s)
|
_builtin_syscall(SYS_close, s)
|
||||||
return -1, false
|
return -1, false
|
||||||
|
|
||||||
~packed_host, ok := net.resolve(host)
|
packed_host, ok := net.resolve(host)
|
||||||
if !ok
|
if !ok
|
||||||
return -1, false
|
return -1, false
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ func net.connect[host: str, port: i64] : i64, bool
|
|||||||
if s < 0
|
if s < 0
|
||||||
return -1, false
|
return -1, false
|
||||||
|
|
||||||
~packed_host, ok := net.resolve(host)
|
packed_host, ok := net.resolve(host)
|
||||||
if !ok
|
if !ok
|
||||||
return -1, false
|
return -1, false
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ func net.UDPSocket.close_and_free[s: net.UDPSocket] : void
|
|||||||
func net.create_udp_client[host: str, port: i64] : net.UDPSocket, bool
|
func net.create_udp_client[host: str, port: i64] : net.UDPSocket, bool
|
||||||
s := new* net.UDPSocket
|
s := new* net.UDPSocket
|
||||||
|
|
||||||
~packed_host, ok := net.resolve(host)
|
packed_host, ok := net.resolve(host)
|
||||||
if !ok
|
if !ok
|
||||||
return 0 as net.UDPSocket, false
|
return 0 as net.UDPSocket, false
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ func net.create_udp_client[host: str, port: i64] : net.UDPSocket, bool
|
|||||||
return s, true
|
return s, true
|
||||||
|
|
||||||
func net.create_udp_server[host: str, port: i64] : net.UDPSocket, bool
|
func net.create_udp_server[host: str, port: i64] : net.UDPSocket, bool
|
||||||
~s, ok := net.create_udp_client(host, port)
|
s, ok := net.create_udp_client(host, port)
|
||||||
if !ok
|
if !ok
|
||||||
return 0 as net.UDPSocket, false
|
return 0 as net.UDPSocket, false
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ func net.resolve[domain: str] : i64, bool
|
|||||||
query := net.build_dns_query(domain, DNS_TYPE_A)
|
query := net.build_dns_query(domain, DNS_TYPE_A)
|
||||||
|
|
||||||
// TODO: this probably shouldnt be hardcoded
|
// TODO: this probably shouldnt be hardcoded
|
||||||
~s, ok := net.create_udp_client("1.1.1.1", 53)
|
s, ok := net.create_udp_client("1.1.1.1", 53)
|
||||||
if !ok
|
if !ok
|
||||||
query->free()
|
query->free()
|
||||||
return -1, false
|
return -1, false
|
||||||
|
|||||||
12
test.zr
12
test.zr
@@ -8,7 +8,7 @@ struct TestRunner
|
|||||||
custom_run_args: HashMap
|
custom_run_args: HashMap
|
||||||
|
|
||||||
func TestRunner.run_directory[tr: TestRunner, dir: str] : void
|
func TestRunner.run_directory[tr: TestRunner, dir: str] : void
|
||||||
~files, ok := os.list_directory(dir)
|
files, ok := os.list_directory(dir)
|
||||||
if !ok
|
if !ok
|
||||||
panic("failed to open test directory")
|
panic("failed to open test directory")
|
||||||
for i in 0..files->size
|
for i in 0..files->size
|
||||||
@@ -28,12 +28,12 @@ func TestRunner.run_test[tr: TestRunner, x: str] : void
|
|||||||
io.printf("Building %s...\n", x)
|
io.printf("Building %s...\n", x)
|
||||||
|
|
||||||
build_cmd := "./target/release/zern "->concat(x)
|
build_cmd := "./target/release/zern "->concat(x)
|
||||||
~custom_build_flags, ok := tr->custom_build_flags->get(name)
|
custom_build_flags, ok := tr->custom_build_flags->get(name)
|
||||||
if ok
|
if ok
|
||||||
build_cmd = build_cmd->concat(" ")->concat(custom_build_flags)
|
build_cmd = build_cmd->concat(" ")->concat(custom_build_flags)
|
||||||
|
|
||||||
build_start_time := os.time()
|
build_start_time := os.time()
|
||||||
~status, ok := os.run_shell_command(build_cmd)
|
status, ok := os.run_shell_command(build_cmd)
|
||||||
if !ok || status != 0
|
if !ok || status != 0
|
||||||
os.exit(1)
|
os.exit(1)
|
||||||
build_end_time := os.time()
|
build_end_time := os.time()
|
||||||
@@ -47,12 +47,12 @@ func TestRunner.run_test[tr: TestRunner, x: str] : void
|
|||||||
io.printf("Running %s...\n", x)
|
io.printf("Running %s...\n", x)
|
||||||
|
|
||||||
run_cmd := "./out"
|
run_cmd := "./out"
|
||||||
~custom_run_args, ok := tr->custom_run_args->get(name)
|
custom_run_args, ok := tr->custom_run_args->get(name)
|
||||||
if ok
|
if ok
|
||||||
run_cmd = run_cmd->concat(" ")->concat(custom_run_args)
|
run_cmd = run_cmd->concat(" ")->concat(custom_run_args)
|
||||||
|
|
||||||
run_start_time := os.time()
|
run_start_time := os.time()
|
||||||
~status, ok := os.run_shell_command(run_cmd)
|
status, ok := os.run_shell_command(run_cmd)
|
||||||
if !ok || status != 0
|
if !ok || status != 0
|
||||||
io.println("Test failed.")
|
io.println("Test failed.")
|
||||||
os.exit(1)
|
os.exit(1)
|
||||||
@@ -61,7 +61,7 @@ func TestRunner.run_test[tr: TestRunner, x: str] : void
|
|||||||
io.printf("Running %s took %dms\n", x, run_end_time - run_start_time)
|
io.printf("Running %s took %dms\n", x, run_end_time - run_start_time)
|
||||||
|
|
||||||
func main[] : i64
|
func main[] : i64
|
||||||
~status, ok := os.run_shell_command("cargo build --release")
|
status, ok := os.run_shell_command("cargo build --release")
|
||||||
if !ok || status != 0
|
if !ok || status != 0
|
||||||
os.exit(1)
|
os.exit(1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user