wip
This commit is contained in:
parent
4bc7fd1788
commit
12c0a008df
19 changed files with 220 additions and 534 deletions
|
@ -13,8 +13,8 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
|
||||||
symbols.write().unwrap().declare_proc_parse(
|
symbols.write().unwrap().declare_proc_parse(
|
||||||
"dup",
|
"dup",
|
||||||
vec!["T"],
|
vec!["T"],
|
||||||
vec!["T~machine.Word"],
|
vec!["machine.Word"],
|
||||||
vec!["T~machine.Word", "T~machine.Word"],
|
vec!["machine.Word", "machine.Word"],
|
||||||
);
|
);
|
||||||
|
|
||||||
/* drop topmost element
|
/* drop topmost element
|
||||||
|
@ -30,7 +30,7 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
|
||||||
symbols.write().unwrap().declare_proc_parse(
|
symbols.write().unwrap().declare_proc_parse(
|
||||||
"emit",
|
"emit",
|
||||||
vec![],
|
vec![],
|
||||||
vec!["Char~Unicode~ℤ_2^32~ℤ_2^64~machine.UInt64~machine.Word"],
|
vec!["Char~Unicode~ℤ_2^32~machine.Int64~machine.Word"],
|
||||||
vec![],
|
vec![],
|
||||||
);
|
);
|
||||||
symbols.write().unwrap().declare_proc_parse(
|
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(
|
symbols.write().unwrap().declare_proc_parse(
|
||||||
"i+",
|
"i+",
|
||||||
vec![],
|
vec![],
|
||||||
vec![
|
vec!["machine.Int64","machine.Int64"],
|
||||||
"ℤ_2^64~machine.UInt64~machine.Word",
|
vec!["machine.Int64"],
|
||||||
"ℤ_2^64~machine.UInt64~machine.Word",
|
);
|
||||||
],
|
symbols.write().unwrap().declare_proc_parse(
|
||||||
vec!["ℤ_2^64~machine.UInt64~machine.Word"],
|
"u+",
|
||||||
|
vec![],
|
||||||
|
vec!["machine.UInt64","machine.UInt64"],
|
||||||
|
vec!["machine.UInt64"],
|
||||||
);
|
);
|
||||||
symbols.write().unwrap().declare_proc_parse(
|
symbols.write().unwrap().declare_proc_parse(
|
||||||
"i-",
|
"i-",
|
||||||
vec![],
|
vec![],
|
||||||
vec![
|
vec!["machine.Int64","machine.Int64"],
|
||||||
"ℤ_2^64~machine.UInt64~machine.Word",
|
vec!["machine.Int64"],
|
||||||
"ℤ_2^64~machine.UInt64~machine.Word",
|
);
|
||||||
],
|
symbols.write().unwrap().declare_proc_parse(
|
||||||
vec!["ℤ_2^64~machine::UInt64~machine.Word"],
|
"u-",
|
||||||
|
vec![],
|
||||||
|
vec!["machine.UInt64","machine.UInt64"],
|
||||||
|
vec!["machine.UInt64"],
|
||||||
);
|
);
|
||||||
symbols.write().unwrap().declare_proc_parse(
|
symbols.write().unwrap().declare_proc_parse(
|
||||||
"i*",
|
"i*",
|
||||||
vec![],
|
vec![],
|
||||||
vec![
|
vec![
|
||||||
"ℤ_2^64~machine.UInt64~machine.Word",
|
"machine.Int64~machine.Word",
|
||||||
"ℤ_2^64~machine.UInt64~machine.Word",
|
"machine.Int64~machine.Word",
|
||||||
],
|
],
|
||||||
vec!["ℤ_2^64~machine.UInt64~machine.Word"],
|
vec!["machine.Int64~machine.Word"],
|
||||||
);
|
);
|
||||||
symbols.write().unwrap().declare_proc_parse(
|
symbols.write().unwrap().declare_proc_parse(
|
||||||
"i/",
|
"i/",
|
||||||
vec![],
|
vec![],
|
||||||
vec![
|
vec![
|
||||||
"ℤ_2^64~machine.UInt64~machine.Word",
|
"machine.Int64~machine.Word",
|
||||||
"ℤ_2^64~machine.UInt64~machine.Word",
|
"machine.Int64~machine.Word",
|
||||||
],
|
],
|
||||||
vec!["ℤ_2^64~machine.UInt64~machine.Word"],
|
vec!["machine.Int64~machine.Word"],
|
||||||
);
|
);
|
||||||
symbols.write().unwrap().declare_proc_parse(
|
symbols.write().unwrap().declare_proc_parse(
|
||||||
"i%",
|
"i%",
|
||||||
vec![],
|
vec![],
|
||||||
vec![
|
vec![
|
||||||
"ℤ_2^64~machine.UInt64~machine.Word",
|
"machine.Int64~machine.Word",
|
||||||
"ℤ_2^64~machine.UInt64~machine.Word",
|
"machine.Int64~machine.Word",
|
||||||
],
|
],
|
||||||
vec!["ℤ_2^64~machine.UInt64~machine.Word"],
|
vec!["machine.Int64~machine.Word"],
|
||||||
);
|
);
|
||||||
|
|
||||||
symbols.write().unwrap().declare_proc_parse(
|
symbols.write().unwrap().declare_proc_parse(
|
||||||
"f+",
|
"f+",
|
||||||
vec![],
|
vec![],
|
||||||
|
@ -146,6 +151,9 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
|
||||||
vec!["ℝ~machine.f64~machine.Word"],
|
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::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::IntSub).build());
|
||||||
linker.add_procedure("i*", tisc::Assembler::new().inst(tisc::VM_Instruction::IntMul).build());
|
linker.add_procedure("i*", tisc::Assembler::new().inst(tisc::VM_Instruction::IntMul).build());
|
||||||
|
@ -162,7 +170,7 @@ pub fn init_runtime(linker: &mut Linker) -> Arc<RwLock<Scope>> {
|
||||||
|
|
||||||
symbols.write().unwrap().declare_proc_parse(
|
symbols.write().unwrap().declare_proc_parse(
|
||||||
"bit-neg",
|
"bit-neg",
|
||||||
vec![], vec!["machine.Word", "machine.Word"], vec!["machine.Word"],
|
vec![], vec!["machine.Word"], vec!["machine.Word"],
|
||||||
);
|
);
|
||||||
symbols.write().unwrap().declare_proc_parse(
|
symbols.write().unwrap().declare_proc_parse(
|
||||||
"bit-and",
|
"bit-and",
|
||||||
|
@ -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());
|
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(
|
symbols.write().unwrap().declare_static_parse(
|
||||||
"data-frame-ptr",
|
"data-frame-ptr",
|
||||||
"<MutRef <Seq machine.Word>>~machine.Address~machine.Word",
|
"<MutRef <Seq machine.Word>>~machine.Address~machine.Word",
|
||||||
);
|
);
|
||||||
linker.add_static("data-frame-ptr", vec![0x1000]);
|
|
||||||
|
|
||||||
symbols.write().unwrap().declare_proc_parse(
|
symbols.write().unwrap().declare_proc_parse(
|
||||||
"data-frame-set",
|
"data-frame-set",
|
||||||
|
|
|
@ -324,7 +324,6 @@ impl Scope {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn declare_static(&mut self, name: String, typ: laddertypes::TypeTerm, export: bool) {
|
pub fn declare_static(&mut self, name: String, typ: laddertypes::TypeTerm, export: bool) {
|
||||||
eprintln!("add {} export {}", name, export);
|
|
||||||
self.symbols.insert(
|
self.symbols.insert(
|
||||||
name,
|
name,
|
||||||
SymbolDef::StaticRef {
|
SymbolDef::StaticRef {
|
||||||
|
|
|
@ -355,7 +355,7 @@ impl Statement {
|
||||||
Statement::Expr(expr) => {
|
Statement::Expr(expr) => {
|
||||||
let t = expr.infer_type(scope)?;
|
let t = expr.infer_type(scope)?;
|
||||||
|
|
||||||
let symb = expr.export_symbols();
|
// let symb = expr.export_symbols();
|
||||||
// eprintln!("expr statement: import symbols from expr {:?}", symb);
|
// eprintln!("expr statement: import symbols from expr {:?}", symb);
|
||||||
// scope.write().unwrap().import( symb );
|
// scope.write().unwrap().import( symb );
|
||||||
|
|
||||||
|
@ -384,4 +384,3 @@ impl Statement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
export {
|
export {
|
||||||
|
/*
|
||||||
let angle-normalize =
|
let angle-normalize =
|
||||||
λ a : Angle
|
λ a : Angle
|
||||||
~ Degree
|
~ Degree
|
||||||
|
@ -16,4 +17,5 @@ export {
|
||||||
~ ℝ
|
~ ℝ
|
||||||
~ machine.Float64
|
~ machine.Float64
|
||||||
↦ f/ a 360 ;
|
↦ f/ a 360 ;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
31
lt-stdlib/bool.lt
Normal file
31
lt-stdlib/bool.lt
Normal 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;
|
||||||
|
}
|
|
@ -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)
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
export {
|
|
||||||
let complex-magnitude = λ{
|
|
||||||
{ re: ℝ, im: ℝ }
|
|
||||||
: ℂ
|
|
||||||
~ Cartesian
|
|
||||||
~ <Vec2 ℝ ~ machine.Float64>
|
|
||||||
} -> ℝ ↦ {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,25 +3,27 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
import "int.lt";
|
||||||
|
|
||||||
/* Euclidean Algorithm to calculate greatest common divisor
|
/* Euclidean Algorithm to calculate greatest common divisor
|
||||||
*/
|
*/
|
||||||
let gcd = λ{
|
let gcd = λ{
|
||||||
a : ℤ ~ machine.Int64;
|
a : machine.Int64 ~ machine.Word;
|
||||||
b : ℤ ~ machine.Int64;
|
b : machine.Int64 ~ machine.Word;
|
||||||
} ↦ {
|
} ↦ {
|
||||||
while( b ) {
|
while( int-gt b 0 ) {
|
||||||
let tmp = i% a b;
|
let tmp = i% a b;
|
||||||
! a b;
|
! a b;
|
||||||
! b tmp;
|
! b tmp;
|
||||||
}
|
};
|
||||||
a;
|
a;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* least common multiple
|
/* least common multiple
|
||||||
*/
|
*/
|
||||||
let lcm = λ{
|
let lcm = λ{
|
||||||
a : ℤ ~ machine.Int64;
|
a : machine.Int64 ~ machine.Word;
|
||||||
b : ℤ ~ machine.Int64;
|
b : machine.Int64 ~ machine.Word;
|
||||||
} ↦ i* (int-abs a) (i/ (int-abs b) (gcd a b));
|
} ↦ i* (int-abs a) (i/ (int-abs b) (gcd a b));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -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 ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -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] )
|
|
||||||
|
|
||||||
|
|
||||||
|
|
105
lt-stdlib/int.lt
105
lt-stdlib/int.lt
|
@ -1,18 +1,95 @@
|
||||||
|
|
||||||
|
|
||||||
/* Two's complement Signed Integers
|
/* Two's complement Signed Integers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export {
|
export {
|
||||||
let int-sign = λx:ℤ~machine.Int64 ↦ bit-and (bit-shr x 63) 1;
|
import "./lt-stdlib/bool.lt";
|
||||||
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; };
|
|
||||||
};
|
|
||||||
|
|
||||||
|
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
11
lt-stdlib/makefile
Normal 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)
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,19 +1,30 @@
|
||||||
export {
|
export {
|
||||||
|
import "int.lt";
|
||||||
|
import "euclidean.lt";
|
||||||
|
|
||||||
/* Implementation of Rational Numbers
|
/* 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 = λ{
|
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* q n;
|
||||||
i* p n;
|
i* p n;
|
||||||
};
|
};
|
||||||
|
|
||||||
let ratio-normalize = λ{
|
let ratio-normalize = λ{
|
||||||
p: ℤ~machine.Int64;
|
p: machine.Int64 ~ machine.Word;
|
||||||
q: ℤ~machine.Int64;
|
q: machine.Int64 ~ machine.Word;
|
||||||
} : ℚ ~ <Ratio ℤ~machine.Int64>
|
} : ℚ ~ <Ratio machine.Int64 ~ machine.Word>
|
||||||
↦ {
|
↦ {
|
||||||
let s = gcd p q;
|
let s = gcd p q;
|
||||||
i/ q s;
|
i/ q s;
|
||||||
|
@ -21,8 +32,14 @@ export {
|
||||||
};
|
};
|
||||||
|
|
||||||
let ratio-add = λ{
|
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 l = lcm aq bq;
|
||||||
let a = i/ l aq;
|
let a = i/ l aq;
|
||||||
|
@ -33,13 +50,20 @@ export {
|
||||||
};
|
};
|
||||||
|
|
||||||
let ratio-mul = λ{
|
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);
|
} ↦ ratio-normalize (i* ap bp) (i* aq bq);
|
||||||
|
|
||||||
|
/*
|
||||||
let fmt-ratio = λ{ p:ℤ; q:ℤ; }: ℚ~<Ratio ℤ> ↦ {
|
let fmt-ratio = λ{ p:ℤ; q:ℤ; }: ℚ~<Ratio ℤ> ↦ {
|
||||||
fmt-int q;':';fmt-int p;
|
fmt-int q;':';fmt-int p;
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
export {
|
export {
|
||||||
|
|
||||||
/* output nullterminated string directly from datastack
|
/* output nullterminated string directly from datastack
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
let print-nullterm =
|
let print-nullterm =
|
||||||
λ{} : < Seq Char~Ascii~machine.Word >
|
λ{} : < Seq Char~Ascii~machine.Word >
|
||||||
~ < NullTerminatedArray machine.Word >
|
~ < NullTerminatedArray machine.Word >
|
||||||
|
@ -8,5 +10,6 @@ export {
|
||||||
while(dup) { emit; }
|
while(dup) { emit; }
|
||||||
drop;
|
drop;
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
|
@ -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'
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
|
@ -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'; '{';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ fn main() {
|
||||||
println!("{}\n{}", source_path.bold().yellow(), "------------".green());
|
println!("{}\n{}", source_path.bold().yellow(), "------------".green());
|
||||||
println!("{}", "Symbols".bold().white());
|
println!("{}", "Symbols".bold().white());
|
||||||
|
|
||||||
|
obj_file.symbols.sort_by(|(n0,a0), (n1,a1)| a0.cmp(a1));
|
||||||
for (name, addr) in obj_file.symbols.iter() {
|
for (name, addr) in obj_file.symbols.iter() {
|
||||||
println!("{} @ {}", name.bold().yellow(), format!("{:#010x}", addr).blue());
|
println!("{} @ {}", name.bold().yellow(), format!("{:#010x}", addr).blue());
|
||||||
}
|
}
|
||||||
|
@ -47,4 +48,3 @@ fn main() {
|
||||||
println!("{}\n", "============".green());
|
println!("{}\n", "============".green());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue