This commit is contained in:
Michael Sippel 2024-12-24 12:51:36 +01:00
parent 4bc7fd1788
commit 12c0a008df
Signed by: senvas
GPG key ID: F96CF119C34B64A6
19 changed files with 220 additions and 534 deletions

View file

@ -13,8 +13,8 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
symbols.write().unwrap().declare_proc_parse(
"dup",
vec!["T"],
vec!["T~machine.Word"],
vec!["T~machine.Word", "T~machine.Word"],
vec!["machine.Word"],
vec!["machine.Word", "machine.Word"],
);
/* drop topmost element
@ -30,7 +30,7 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
symbols.write().unwrap().declare_proc_parse(
"emit",
vec![],
vec!["Char~Unicode~_2^32~_2^64~machine.UInt64~machine.Word"],
vec!["Char~Unicode~_2^32~machine.Int64~machine.Word"],
vec![],
);
symbols.write().unwrap().declare_proc_parse(
@ -53,49 +53,54 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
symbols.write().unwrap().declare_proc_parse(
"i+",
vec![],
vec![
"_2^64~machine.UInt64~machine.Word",
"_2^64~machine.UInt64~machine.Word",
],
vec!["_2^64~machine.UInt64~machine.Word"],
vec!["machine.Int64","machine.Int64"],
vec!["machine.Int64"],
);
symbols.write().unwrap().declare_proc_parse(
"u+",
vec![],
vec!["machine.UInt64","machine.UInt64"],
vec!["machine.UInt64"],
);
symbols.write().unwrap().declare_proc_parse(
"i-",
vec![],
vec![
"_2^64~machine.UInt64~machine.Word",
"_2^64~machine.UInt64~machine.Word",
],
vec!["_2^64~machine::UInt64~machine.Word"],
vec!["machine.Int64","machine.Int64"],
vec!["machine.Int64"],
);
symbols.write().unwrap().declare_proc_parse(
"u-",
vec![],
vec!["machine.UInt64","machine.UInt64"],
vec!["machine.UInt64"],
);
symbols.write().unwrap().declare_proc_parse(
"i*",
vec![],
vec![
"_2^64~machine.UInt64~machine.Word",
"_2^64~machine.UInt64~machine.Word",
"machine.Int64~machine.Word",
"machine.Int64~machine.Word",
],
vec!["_2^64~machine.UInt64~machine.Word"],
vec!["machine.Int64~machine.Word"],
);
symbols.write().unwrap().declare_proc_parse(
"i/",
vec![],
vec![
"_2^64~machine.UInt64~machine.Word",
"_2^64~machine.UInt64~machine.Word",
"machine.Int64~machine.Word",
"machine.Int64~machine.Word",
],
vec!["_2^64~machine.UInt64~machine.Word"],
vec!["machine.Int64~machine.Word"],
);
symbols.write().unwrap().declare_proc_parse(
"i%",
vec![],
vec![
"_2^64~machine.UInt64~machine.Word",
"_2^64~machine.UInt64~machine.Word",
"machine.Int64~machine.Word",
"machine.Int64~machine.Word",
],
vec!["_2^64~machine.UInt64~machine.Word"],
vec!["machine.Int64~machine.Word"],
);
symbols.write().unwrap().declare_proc_parse(
"f+",
vec![],
@ -146,6 +151,9 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
vec!["~machine.f64~machine.Word"],
);
linker.add_procedure("u+", tisc::Assembler::new().inst(tisc::VM_Instruction::IntAdd).build());
linker.add_procedure("u-", tisc::Assembler::new().inst(tisc::VM_Instruction::IntSub).build());
linker.add_procedure("i+", tisc::Assembler::new().inst(tisc::VM_Instruction::IntAdd).build());
linker.add_procedure("i-", tisc::Assembler::new().inst(tisc::VM_Instruction::IntSub).build());
linker.add_procedure("i*", tisc::Assembler::new().inst(tisc::VM_Instruction::IntMul).build());
@ -162,24 +170,24 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
symbols.write().unwrap().declare_proc_parse(
"bit-neg",
vec![], vec!["machine.Word", "machine.Word"], vec!["machine.Word"],
vec![], vec!["machine.Word"], vec!["machine.Word"],
);
symbols.write().unwrap().declare_proc_parse(
"bit-and",
vec![], vec!["machine.Word", "machine.Word"], vec!["machine.Word"],
);
);
symbols.write().unwrap().declare_proc_parse(
"bit-or",
vec![], vec!["machine.Word", "machine.Word"], vec!["machine.Word"],
);
);
symbols.write().unwrap().declare_proc_parse(
"bit-xor",
vec![], vec!["machine.Word", "machine.Word"], vec!["machine.Word"],
);
symbols.write().unwrap().declare_proc_parse(
symbols.write().unwrap().declare_proc_parse(
"bit-shl",
vec![], vec!["machine.Word", "machine.Word"], vec!["machine.Word"],
);
);
symbols.write().unwrap().declare_proc_parse(
"bit-shr",
vec![], vec!["machine.Word", "machine.Word"], vec!["machine.Word"],
@ -217,12 +225,11 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
linker.add_procedure("!", tisc::Assembler::new().inst(tisc::VM_Instruction::Store).build());
let section_id = linker.add_static("data-frame-ptr", vec![0x1000]);
symbols.write().unwrap().declare_static_parse(
"data-frame-ptr",
"<MutRef <Seq machine.Word>>~machine.Address~machine.Word",
);
linker.add_static("data-frame-ptr", vec![0x1000]);
symbols.write().unwrap().declare_proc_parse(
"data-frame-set",

View file

@ -324,7 +324,6 @@ impl Scope {
}
pub fn declare_static(&mut self, name: String, typ: laddertypes::TypeTerm, export: bool) {
eprintln!("add {} export {}", name, export);
self.symbols.insert(
name,
SymbolDef::StaticRef {

View file

@ -163,7 +163,7 @@ impl LTExpr {
);
// todo examine stack ..
return
if errors.len() == 0 {
result_type = sugared_result_type.desugar(&mut *super_scope.write().unwrap());
@ -355,7 +355,7 @@ impl Statement {
Statement::Expr(expr) => {
let t = expr.infer_type(scope)?;
let symb = expr.export_symbols();
// let symb = expr.export_symbols();
// eprintln!("expr statement: import symbols from expr {:?}", symb);
// scope.write().unwrap().import( symb );
@ -384,4 +384,3 @@ impl Statement {
}
}
}

View file

@ -1,4 +1,5 @@
export {
/*
let angle-normalize =
λ a : Angle
~ Degree
@ -16,4 +17,5 @@ export {
~
~ machine.Float64
↦ f/ a 360 ;
*/
}

31
lt-stdlib/bool.lt Normal file
View file

@ -0,0 +1,31 @@
/*
*
*/
export {
let bool-norm =
λ { x: Bool ~ machine.Word; }
↦ if(x) {
(1 des machine.Word) as Bool;
} else {
(0 des machine.Word) as Bool;
};
let bool-neg =
λ { x: Bool ~ machine.Word; }
↦ (bit-and (bit-neg (bool-norm x)) 1) as Bool;
let bool-or =
λ { a: Bool ~ machine.Word;
b: Bool ~ machine.Word; }
↦ (bit-or a b) as Bool ~ machine.Word;
let bool-and =
λ{ a: Bool ~ machine.Word;
b: Bool ~ machine.Word; }
↦ (bit-and (bool-norm a) (bool-norm b)) as Bool ~ machine.Word;
let bool-xor =
λ{ a: Bool ~ machine.Word;
b: Bool ~ machine.Word; }
↦ (bit-xor (bool-norm a) (bool-norm b)) as Bool ~ machine.Word;
}

View file

@ -1,63 +0,0 @@
export {
/* todo: allow machine.UInt8 in the VM
*/
let morph-rgb-to-hsv = λ{
{
red: _[0,1] ~ _256 ~ machine.UInt64;
green: _[0,1] ~ _256 ~ machine.UInt64;
blue: _[0,1] ~ _256 ~ machine.UInt64;
} : <Color sRGB>
~ RGB
~ <Vec3 _[0,1] ~ _256 ~ machine.UInt64>;
}
/*
-> <Color sRGB>
~ HSV
~ {
hue: Angle ~ Degrees ~ _0,360 ~ _360 ~ machine.UInt64 ;
sat: _[0,1] ~ _256 ~ machine.UInt64;
val: _[0,1] ~ _256 ~ machine.UInt64;
}
~ <Vec3 machine.UInt64>
*/
↦ {
let channel_max = int-max (int-max red green) blue;
let channel_min = int-min (int-min red green) blue;
let channel_delta = i- channel_max channel_min;
/* value */
channel_max;
/* saturation */
i/ (i* 255 channel_delta) channel_max;
/* hue */
i% (i/ (i* 60
if( int-eq channel_max red ) { i+ (i* 0 255) (i- green blue); }
else {
if( int-eq channel_max green ) { i+ (i* 2 255) (i- blue red); }
else { i+ (i* 4 255) (i- red green); };
}
)
channel_delta
)
360;
};
/*
let get-srgb-luminance =
-> _[0,1] ~ machine.Float64
λ{r:,g:,b:} : <Color sRGB> ~ RGB ~ <Vec3 _[0,1] ~ machine.Float64>
{
machine.Float64.mul red 0.22248840;
machine.Float64.mul green 0.71690369;
machine.Float64.mul blue 0.06060791;
machine.Float64.add;
machine.Float64.add;
// add (add (mul r 0.2) (mul g 0.7)) (mul b 0.6)
};
*/
}

View file

@ -1,10 +0,0 @@
export {
let complex-magnitude = λ{
{ re: , im: }
:
~ Cartesian
~ <Vec2 ~ machine.Float64>
} -> ↦ {
}
}

View file

@ -3,25 +3,27 @@
*/
export {
import "int.lt";
/* Euclidean Algorithm to calculate greatest common divisor
*/
let gcd = λ{
a : ~ machine.Int64;
b : ~ machine.Int64;
a : machine.Int64 ~ machine.Word;
b :machine.Int64 ~ machine.Word;
} ↦ {
while( b ) {
while( int-gt b 0 ) {
let tmp = i% a b;
! a b;
! b tmp;
}
};
a;
};
/* least common multiple
*/
let lcm = λ{
a : ~ machine.Int64;
b : ~ machine.Int64;
a : machine.Int64 ~ machine.Word;
b : machine.Int64 ~ machine.Word;
} ↦ i* (int-abs a) (i/ (int-abs b) (gcd a b));
};

View file

@ -1,61 +0,0 @@
export {
/* Platform Specific Types */
type machine.Float16 = IEEE-754.half ~ <machine.Bits 16>;
type machine.Float32 = IEEE-754.single ~ <machine.Bits 32>;
type machine.Float64 = IEEE-754.double ~ <machine.Bits 64>;
overload + = λ{
a: ~ machine.Float16 ;
b: ~ machine.Float16 ;
} -> ~ machine.Float16 ↦ {
machine.Float16.add a b;
};
overload * = λ{
a: ~ machine.Float16 ;
b: ~ machine.Float16 ;
} -> ~ machine.Float16 ↦ {
machine.Float16.mul a b;
};
let Sign = enum { Positive; Negative; };
let Sign.Positive : <machine.Bits 1> = 0;
let Sign.Negative : <machine.Bits 1> = 1;
let softfloat16-mul = λ{
{
a.sign: Sign
~ <machine.Bits 1>
;
a.exponent: _[-14,15]
~ <BiasedInt -14>
~ _32
~ <PosInt 2 BigEndian>
~ <Seq <Digit 2>~Bit >
~ <machine.Bits 5>
;
a.significand: _2048
~ <PosInt 2 BigEndian>
~ <Seq <Digit2> ~ Bit>
~ <machine.Bits 11>
;
} :
~ IEEE-754.Half
~ <machine.Bits 16>
;
{
b.sign: <machine.Bits 1>;
} : ~ IEEE-754.Half ~ <machine.Bits 16> ;
} -> result: ~ IEEE~754.Half ~ <machine.Bits 16> ↦ {
/* 1. unify */
/* 2. add exponent */
+ a.exponent b.exponent;
/* 3. normaize */
result.sign = bit-xor a.sign b.sign ;
}
}

View file

@ -1,138 +0,0 @@
/* C++ */
template <typename T>
struct Sample {
T value;
};
template<> struct Sample< uint8_t > {
constexpr uint8_t min = std::numeric_limits<uint8_t>::min();
constexpr uint8_t max = std::numeric_limits<uint8_t>::max();
};
template<> struct Sample< uint16_t > {
constexpr uint16_t min = std::numeric_limits<uint16_t>::min();
constexpr uint16_t max = std::numeric_limits<uint16_t>::max();
};
template<> struct Sample< uint32_t > {
constexpr uint32_t min = std::numeric_limits<uint32_t>::min();
constexpr uint32_t max = std::numeric_limits<uint32_t>::max();
};
template<> struct Sample< float > {
constexpr float min = 0.0;
constexpr float max = 1.0;
};
template<> struct Sample< double > {
constexpr double min = 0.0;
constexpr double max = 1.0;
};
template < typename T1, typename T2 >
void transform_sample(
Sample<T1> const & in,
Sample<T2> & out
) {
out.value = static_cast<T1>( in.value * static_cast<T1>(Sample<T2>::max) ) / Sample<T1>::min;
}
/* LT IR */
@isomorphism
transform_sample <F: f32 | f64>
:: Sample ~ < 0,1> ~ f64
-> Sample ~ < 0,1> ~ _2^256 ~ u8
transform_sample f = floor( f * 256.0 ) as _2^256 ~ u8
@isomorphism
transform_sample :: Sample ~ < 0,1> ~ _2^256 ~ u8
-> Sample ~ < 0,1> ~ f64
transform_sample i = (i as ~f64) / 256.0
transform_sample <T1 T2> :: Sample~~T1 -> ~T2
transform_sample v
void main() {
// read Audio streams
for( unsigned i = 0; i < )
}
/* LT IR */
type Color~RGB = { r|red: _0,1; g|green: _0,1; b|blue: _0,1; }
type Color~HSL = { h|hue: _0,1; s|saturation: _0,1; l|lightness: _0,1; }
validate <> :: f64 -> {}
validate x = {}
morph :: Color~RGB -> Color~HSL
morph (r,g,b) = {
let h = .. TODO ..
...
(h,s,l)
}
morph :: _0,1 ~ f64 -> _0,1 ~ _256
morph x = (x * 256.0) % 256
morph :: _0,1 ~ _256 -> _0,1 ~ f64
morph x = (x as f64 / 256.0)
infix * :: ~f64 -> ~f64 -> ~f64
infix * a b = f64.mul a b
clamp :: -> -> ->
clamp minVal maxVal x = if x < minVal { minVal }
else if x > maxVal { maxVal }
else { x }
saturate :: -> Color~HSL -> Color~HSL
saturate f {h,s,l} = { h, clamp(f*s, 0.0, 1.0), l }
saturate_image :: -> [Color~HSL] -> [Color~HSL]
saturate_image f pixels = map saturate pixels
{
let width : = 4;
let height : = 2;
let pixels
: [
[
[ Color
~RGB
~[ _0,1
~_256
~<PosInt 16 BE>
~[<Digit 16>~Char]
; 3]
; width]
~<SepSeq Char ",[ ]*">~<Wrapped Char "[" "]">~[Char]
; height]
~<SepSeq Char ",[ ]*">~<Wrapped Char "[" "]">~[Char]
= [
[000000, 001122, 22ff33, ffe384],
[ff3344, abcdef, ffeebb, 44bb22]
];
pixels = saturate_image 0.3 pixels
let packed_buf = array_layout_rot
<
[[Color~RGB~[_0,1; 3]; width]; height],
[[Color; width]; height]; 3]
>
pixels;
}
brighten_image :: -> -> [Color] [[ Color~RGB~[~f64; 3]; width]; height] )

View file

@ -1,18 +1,95 @@
/* Two's complement Signed Integers
*/
export {
let int-sign = λx:~machine.Int64 ↦ bit-and (bit-shr x 63) 1;
let int-neg = λx:~machine.Int64 ↦ i+ (bit-neg x) 1;
let int-abs = λx:~machine.Int64 ↦ if( int-sign x ) { int-neg x; } else { x; };
let int-lt = λ{ a:~machine.Int64; b:~machine.Int64; } ↦ int-sign (i- a b);
let int-gt = λ{ a:~machine.Int64; b:~machine.Int64; } ↦ int-sign (i- b a);
let int-eq = λ{ a:~machine.Int64; b:~machine.Int64; } ↦ if (bit-xor a b) { 0; } else { 1; };
let int-lte = λ{ a:~machine.Int64; b:~machine.Int64; } ↦ bit-or (int-lt a b) (int-eq a b);
let int-gte = λ{ a:~machine.Int64; b:~machine.Int64; } ↦ bit-or (int-gt a b) (int-eq a b);
let int-min = λ{ a:~machine.Int64; b:~machine.Int64; } ↦ if( int-lt a b ) { a; } else { b; };
let int-max = λ{ a:~machine.Int64; b:~machine.Int64; } ↦ if( int-gt a b ) { a; } else { b; };
};
import "./lt-stdlib/bool.lt";
let int-sign =
λ x: machine.Int64~machine.Word
↦ (bit-and (bit-shr (x des machine.Word) 63) 1) as Bool;
let int-neg =
λ x: machine.Int64~machine.Word
↦ i+ ((bit-neg x) as machine.Int64) 1;
let int-abs =
λ x: machine.Int64~machine.Word
↦ if( int-sign x ) { int-neg x; } else { x; };
let int-lt =
λ{ a: machine.Int64~machine.Word;
b: machine.Int64~machine.Word; }
↦ int-sign (i- a b);
let int-gt =
λ{ a: machine.Int64~machine.Word;
b: machine.Int64~machine.Word; }
↦ int-sign (i- b a);
let int-neq =
λ{ a: machine.Int64~machine.Word;
b: machine.Int64~machine.Word; }
↦ (bit-xor a b) as Bool;
let int-eq =
λ{ a: machine.Int64~machine.Word;
b: machine.Int64~machine.Word; }
↦ bool-neg (int-neq a b);
let int-lte =
λ{ a: machine.Int64~machine.Word;
b: machine.Int64~machine.Word; }
↦ bool-or (int-lt a b) (int-eq a b);
let int-gte =
λ{ a: machine.Int64~machine.Word;
b: machine.Int64~machine.Word; }
↦ bool-or (int-gt a b) (int-eq a b);
let int-min =
λ{ a: machine.Int64~machine.Word;
b: machine.Int64~machine.Word; }
↦ if (int-lt a b) { a; } else { b; };
let int-max =
λ{ a:machine.Int64~machine.Word;
b:machine.Int64~machine.Word; }
↦ if (int-gt a b) { a; } else { b; };
/*
type machine.UInt64 = <UnsignedBinaryInt 64> ~ machine.Word;
impl _2^64 for machine.UInt64 {
let + = machine.UInt64.add;
let - = machine.UInt64.sub;
let * = machine.UInt64.mul;
let / = machine.UInt64.div;
let % = machine.UInt64.rem;
};
type machine.Int64 = <TwosComplementInt 64> ~ machine.Word;
let machine.Int64.add =
λ{ a: machine.Int64;
b: machine.Int64; }
↦ ((u+ ((a des machine.Word) as machine.UInt64)
((b des machine.Word) as machine.UInt64))
des machine.Word) as machine.Int64;
type =~ <PosInt 2^64 BigEndian> ~ <Seq <Digit 2^64>~_2^64~machine.UInt64>;
impl < -2^63-1 +2^63> for <TwosComplementInt 64> {
let + = machine.Int64.add;
let - = machine.Int64.sub;
let * = machine.Int64.mul;
let / = machine.Int64.div;
let % = machine.Int64.rem;
};
*/
/*
let int-onescomplement-neg =
λ x : < -2^63 +2^63> ~ <OnesComplementInt 64> ~ machine.Word
↦ (bit-neg x) as < -2^63 +2^63> ~ <OnesComplementInt 64>;
let int-twoscomplement-neg =
λ x : < -2^63-1 +2^63> ~ <TwosComplementInt 64> ~ machine.Word
↦ (i+ 1 ((bit-neg x) as machine.Int64)) as < -2^63-1 +2^63>;
*/
};

11
lt-stdlib/makefile Normal file
View file

@ -0,0 +1,11 @@
TARGETS=$(shell find -name '*.lt' | sed -E 's~\.lt~\.o~')
all: $(TARGETS)
%.o: %.lt
ltcc $< -o target/$@
clean:
cd target && rm $(TARGETS)

View file

@ -1,63 +0,0 @@
/* Positional Integer
*/
export {
let fmt-uint-radix = λ{
radix : ~ _2^64 ~ machine.UInt64;
x : ~ _2^64 ~ machine.UInt64;
} ↦ {
if( x ) {
while( x ) {
let digit = (i% x radix);
if( int-lt digit 10 ) {
i+ '0' digit;
} else {
i+ (i- 'a' 10) digit;
};
! x (i/ x radix);
}
} else {
'0';
};
};
let uint-machine-to-posint =
λ{
radix: ~ _2^64 ~ machine.UInt64;
value: ~ _2^64 ~ machine.UInt64;
}
/*
::>
~ <PosInt radix BigEndian>
~ <Seq <Digit radix>
~ _radix
~ _2^64
~ machine.UInt64>
~ <LengthPrefixedArray machine.UInt64>
*/
↦ {
let len = 0;
while( value ) {
/* push digit to sequence on stack */
i% value radix;
! value (i/ value radix);
! len (i+ len 1);
}
/* push length of sequence to stack */
len;
};
let fmt-int-radix = λ{
radix: ~ _2^64 ~ machine.UInt64;
x : ~ machine.Int64;
} ↦ {
fmt-uint-radix radix (int-abs x);
if( int-sign x ) { '-'; };
};
let fmt-uint = λx: ↦ fmt-uint-radix 10 x;
let fmt-int = λx: ↦ fmt-int-radix 10 x;
}

View file

@ -1,19 +1,30 @@
export {
import "int.lt";
import "euclidean.lt";
/* Implementation of Rational Numbers
*/
let ratio-sign = λ{
p: machine.Int64 ~ machine.Word;
q: machine.Int64 ~ machine.Word;
}
↦ bool-xor (int-sign p) (int-sign q);
let ratio-scale = λ{
{p:; q:;} : ~ <Ratio ~machine.UInt64> ;
n : ~ machine.UInt64 ;
{
p: machine.Int64~machine.Word;
q: machine.Int64~machine.Word;
} : ~ <Ratio machine.Int64~machine.Word>;
n : machine.Int64 ~machine.Word;
} ↦ {
i* q n;
i* p n;
};
let ratio-normalize = λ{
p: ~machine.Int64;
q: ~machine.Int64;
} : ~ <Ratio ~machine.Int64>
p: machine.Int64 ~ machine.Word;
q: machine.Int64 ~ machine.Word;
} : ~ <Ratio machine.Int64 ~ machine.Word>
↦ {
let s = gcd p q;
i/ q s;
@ -21,8 +32,14 @@ export {
};
let ratio-add = λ{
{ap:; aq:;}: ~ <Ratio ~ _2^64 ~ machine.UInt64> ;
{bp:; bq:;}: ~ <Ratio ~ _2^64 ~ machine.UInt64> ;
{
ap:machine.Int64~machine.Word;
aq:machine.Int64~machine.Word;
}: ~ <Ratio machine.Int64 ~ machine.Word> ;
{
bp:machine.Int64~machine.Word;
bq:machine.Int64~machine.Word;
}: ~ <Ratio machine.Int64 ~ machine.Word> ;
} ↦ {
let l = lcm aq bq;
let a = i/ l aq;
@ -33,13 +50,20 @@ export {
};
let ratio-mul = λ{
{ap:; aq:;}: ~ <Ratio ~ _2^64 ~ machine.Int64> ;
{bp:; bq:;}: ~ <Ratio ~ _2^64 ~ machine.Int64> ;
{
ap:machine.Int64~machine.Word;
aq:machine.Int64~machine.Word;
}: ~ <Ratio machine.Int64 ~ machine.Word> ;
{
bp:machine.Int64~machine.Word;
bq:machine.Int64~machine.Word;
}: ~ <Ratio machine.Int64 ~ machine.Word> ;
} ↦ ratio-normalize (i* ap bp) (i* aq bq);
/*
let fmt-ratio = λ{ p:; q:; }: ~<Ratio > ↦ {
fmt-int q;':';fmt-int p;
};
*/
}

View file

@ -1,6 +1,8 @@
export {
/* output nullterminated string directly from datastack
*/
/*
let print-nullterm =
λ{} : < Seq Char~Ascii~machine.Word >
~ < NullTerminatedArray machine.Word >
@ -8,5 +10,6 @@ export {
while(dup) { emit; }
drop;
};
*/
}

View file

@ -1,41 +0,0 @@
#complexity O(n)
let strlen-nullterm =
λ str : &[Char~Ascii~machine::Word]
~ &<NullTerminatedSeq machine::Word>
~ machine::Address
~ machine::Word
->
~ _2^64
~ machine::UInt64
~ machine::Word
{
let mut len = 0;
while ( @str ) {
! len (i+ len 1);
! str (i+ str 1);
}
len;
};
#complexity O(1)
let strlen-lenprefix =
λ str : &[Char~Ascii~machine::Word]
~ &<LenPrefixArray machine::Word>
~ &{
len : _2^64
~ machine::UInt64
~ machine::Word,
data : [machine::Word]
}
~ machine::Address
~ machine::Word
->
~ _2^64
~ machine::UInt64
~ machine::Word
{
str.len
};

View file

@ -1,70 +0,0 @@
type Vec = ΛT ↦ Struct {
len : _2^64 ~ machine.UInt64 ~ machine.Word ;
capacity : _2^64 ~ machine.UInt64 ~ machine.Word ;
data : <RefMut T> ~ machine.Address ~ machine.UInt64 ~ machine.Word ;
};
let yellow:Color~RGB~Vec3i = {
0;
220;
220;
};
let fn = λx::{
3;
};
let swap = λ{x;y;}:{T;T;} ↦ :{x;y;}
let n :
~_2^64
~machine.UInt64
~machine.Word
=
~<PosInt 16 BigEndian>
~<Seq <Digit 16>
~ Char >
: CF03;
λ{} -> {x y} : <Vec2 >
↦ {
10;
5;
}
let Vec.new = ΛT ↦ λ{} ↦ self:<Vec T>{
let sizeofT = 1;
!self <Vec T>{
};
!self.len 0;
!self.capacity 10;
!self.data malloc (i* self.capacity sizeofT);
};
let Vec.drop = ΛT ↦ λself:<Vec T> ↦ {
mfree self.data;
};
let vec-get =
Λ T
↦ λ vec: <Vec T>
↦ λ idx: _2^64 ~ machine.UInt64 ~ machine.Word
↦ T {
if( int-lt idx vec.len ) {
let j = 0;
let sizeofT = 1; /* todo: <sizeof T> */
while( int-lt j sizeofT ) {
@ (i+ vec.data
(i+ (i* idx sizeofT) j));
! j (i+ j 1);
};
} else {
print-nullterm 'o''u''t'' ''o''f'' ''b''o''u''n''d''s''\n''\0'
};
};

View file

@ -1,23 +0,0 @@
export {
/* Vec3i
*/
let vec3i-add = λ{
{ ax:_2^64; ay:_2^64; az:_2^64; } : <Vec3 _2^64~machine.Int64>;
{ bx:_2^64; by:_2^64; bz:_2^64; } : <Vec3 _2^64~machine.Int64>;
} ↦ {
i+ az bz;
i+ ay by;
i+ ax bx;
};
let fmt-vec3i =
λ{ x:_2^64; y:_2^64; z:_2^64; } : <Vec3 _2^64~machine.Int64>
↦ {
'}';
fmt-int z; '='; 'z'; ' '; ';';
fmt-int y; '='; 'y'; ' '; ';';
fmt-int x; '='; 'x'; '{';
};
}

View file

@ -25,6 +25,7 @@ fn main() {
println!("{}\n{}", source_path.bold().yellow(), "------------".green());
println!("{}", "Symbols".bold().white());
obj_file.symbols.sort_by(|(n0,a0), (n1,a1)| a0.cmp(a1));
for (name, addr) in obj_file.symbols.iter() {
println!("{} @ {}", name.bold().yellow(), format!("{:#010x}", addr).blue());
}
@ -47,4 +48,3 @@ fn main() {
println!("{}\n", "============".green());
}
}