feat(nexus): production modular HTTP/1.1 server + compiler fixes
- Rewrite apps/nexus with modular architecture: Config, Http, Errors, Parser, Router, Handlers, Server, Main - Use algebraic enums for ParseResult/FileResult/HttpError - Thread-pool server via Channel<ConnectionTask> and spawn - Fix C backend type ordering for generic struct instances (Array_T, Iter_T) and algebraic enum struct payloads - Collect Slice_T types from struct fields and enum payloads - Fix match lowering for simple enums (direct value compare) - Resolve match expression return type from first arm - Infer element type for for-in over Array<UserStruct> - Preserve generic type args in field access resolution - Add fflush to PrintLine/Print for immediate server logs - Add modern_features golden regression test - Regenerate golden expected.c files
This commit is contained in:
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
import std/[unittest, os, strutils]
|
||||
import ../bootstrap/[lexer, parser, sema, types]
|
||||
import std/[unittest, strutils]
|
||||
import ../bootstrap/[lexer, parser, sema]
|
||||
|
||||
proc checkSource(source: string): tuple[hasErrors: bool, diagnostics: seq[SemaDiagnostic]] =
|
||||
let lexRes = lexer.tokenize(source, "test.bux")
|
||||
|
||||
+2635
-2636
File diff suppressed because it is too large
Load Diff
+2625
-2626
File diff suppressed because it is too large
Load Diff
+2633
-2634
File diff suppressed because it is too large
Load Diff
+2613
-2614
File diff suppressed because it is too large
Load Diff
+2601
-2602
File diff suppressed because it is too large
Load Diff
+2633
-2634
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
[Package]
|
||||
Name = "modern_features"
|
||||
Version = "0.1.0"
|
||||
Type = "bin"
|
||||
|
||||
[Build]
|
||||
Output = "Bin"
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
||||
module Main {
|
||||
|
||||
import Std::Array::{Array, Array_New, Array_Push};
|
||||
|
||||
struct Record {
|
||||
name: String;
|
||||
value: int;
|
||||
}
|
||||
|
||||
struct Box {
|
||||
items: Array<Record>;
|
||||
}
|
||||
|
||||
enum Payload {
|
||||
Ok(Record),
|
||||
Err(String),
|
||||
}
|
||||
|
||||
enum Color { Red, Green }
|
||||
|
||||
func Name(c: Color) -> String {
|
||||
match c {
|
||||
Color::Red => "red",
|
||||
Color::Green => "green",
|
||||
}
|
||||
}
|
||||
|
||||
func Main() -> int {
|
||||
var box: Box;
|
||||
box.items = Array_New<Record>(4);
|
||||
Array_Push<Record>(&box.items, Record { name: "x", value: 10 });
|
||||
|
||||
for it in box.items {
|
||||
if it.value == 10 {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
var r: Payload;
|
||||
r.tag = Payload_Ok;
|
||||
r.data.Ok_0 = Record { name: "y", value: 20 };
|
||||
if r.data.Ok_0.value == 20 {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
+2623
-2624
File diff suppressed because it is too large
Load Diff
+2632
-2633
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -1,5 +1,5 @@
|
||||
import std/[unittest, strformat]
|
||||
import ../bootstrap/[lexer, parser, sema, hir, hir_lower, types, scope]
|
||||
import std/[unittest]
|
||||
import ../bootstrap/[lexer, parser, sema, hir, hir_lower, scope]
|
||||
|
||||
proc lowerSource(source: string): HirModule =
|
||||
let lexRes = tokenize(source, "<test>")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import std/[unittest, os, strutils]
|
||||
import ../bootstrap/[lexer, token, source_location]
|
||||
import std/[unittest, strutils]
|
||||
import ../bootstrap/[lexer, token]
|
||||
|
||||
proc tokenKinds(source: string): seq[TokenKind] =
|
||||
let res = tokenize(source, "<test>")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import std/[unittest, os, strutils]
|
||||
import std/[unittest, os]
|
||||
import ../bootstrap/[lexer, parser, ast, token]
|
||||
|
||||
proc parseSource(source: string): ParseResult =
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import std/[unittest, strutils]
|
||||
import ../bootstrap/[lexer, parser, sema, types]
|
||||
import ../bootstrap/[lexer, parser, sema]
|
||||
|
||||
proc checkSource(source: string): SemaResult =
|
||||
let lexRes = tokenize(source, "<test>")
|
||||
|
||||
Reference in New Issue
Block a user