http server
This commit is contained in:
13
specs.md
13
specs.md
@@ -932,9 +932,14 @@ Built-in functions are declared in `std.sx` with the `#builtin` suffix, which te
|
||||
|
||||
### Math
|
||||
- `sqrt(x: $T) -> T` — square root (maps to LLVM intrinsic)
|
||||
- `sin(x: $T) -> T` — sine (maps to LLVM intrinsic)
|
||||
- `cos(x: $T) -> T` — cosine (maps to LLVM intrinsic)
|
||||
|
||||
### Memory
|
||||
- `alloc(size: s64) -> string` — allocate `size` bytes of memory, returned as a string slice
|
||||
- `malloc(size: s64) -> *void` — allocate `size` bytes of heap memory
|
||||
- `free(ptr: *void) -> void` — free previously allocated memory
|
||||
- `memcpy(dst: *void, src: *void, size: s64) -> *void` — copy `size` bytes from `src` to `dst`
|
||||
- `memset(dst: *void, val: s64, size: s64) -> void` — fill `size` bytes at `dst` with `val`
|
||||
- `size_of($T: Type) -> s64` — size of type `T` in bytes
|
||||
|
||||
### Type Introspection
|
||||
@@ -943,7 +948,9 @@ Built-in functions are declared in `std.sx` with the `#builtin` suffix, which te
|
||||
- `field_count($T: Type) -> s64` — returns the number of fields (struct), variants (enum), or elements (vector) in type `T`
|
||||
- `field_name($T: Type, idx: s64) -> string` — returns the name of the `idx`-th field (struct) or variant (enum) of type `T`
|
||||
- `field_value(s: $T, idx: s64) -> Any` — returns the `idx`-th field (struct) or element (vector) of `s`, boxed as `Any`
|
||||
- `field_value_int($T: Type, idx: s64) -> s64` — returns the integer value of the `idx`-th enum variant
|
||||
- `field_index($T: Type, val: T) -> s64` — returns the sequential variant index for an explicit enum value (reverse of `field_value_int`). Returns `-1` if no variant matches.
|
||||
- `is_flags($T: Type) -> bool` — returns `true` if `T` is a flags enum (declared with `#flags`)
|
||||
|
||||
### Type Conversion
|
||||
- `cast(Type) expr` — prefix operator that converts `expr` to `Type`. Examples: `cast(s32) 3.14`, `cast(f64) n`. When `Type` is a runtime `Type` value inside a type-category match arm, the compiler generates a dispatch switch over all types in the category, monomorphizing the callee for each concrete type.
|
||||
@@ -1031,14 +1038,14 @@ Functions within a namespaced import can call each other without the namespace p
|
||||
mul :: (base: $T, exp: T) -> T { base * exp; }
|
||||
|
||||
// modules/std/std.sx
|
||||
print :: (str: string) -> void #builtin;
|
||||
out :: (str: string) -> void #builtin;
|
||||
|
||||
// main.sx
|
||||
std :: #import "modules/std.sx";
|
||||
#import "modules/std/math.sx";
|
||||
|
||||
main :: () -> s32 {
|
||||
std.print("hello there");
|
||||
std.out("hello there");
|
||||
mul(5, 2);
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user