Compare commits
No commits in common. "7762fa4b128ad1e685e356a0de275842f0d43676" and "8d637a6f325a0c42d7303a487457f65f4fca121c" have entirely different histories.
7762fa4b12
...
8d637a6f32
2 changed files with 28 additions and 29 deletions
|
@ -32,6 +32,28 @@ use {
|
|||
std::sync::{Arc, RwLock},
|
||||
};
|
||||
|
||||
fn setup_hex_master(ctx: &Arc<RwLock<Context>>, rt_int: &Arc<RwLock<ReprTree>>) {
|
||||
rt_int.write().unwrap().detach( ctx );
|
||||
ctx.read().unwrap().apply_morphism(
|
||||
rt_int,
|
||||
&laddertypes::MorphismType {
|
||||
src_type: Context::parse(&ctx, "ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char> ~ EditTree"),
|
||||
dst_type: Context::parse(&ctx, "ℕ ~ <PosInt 10 BigEndian> ~ <Seq <Digit 10>> ~ <List <Digit 10> ~ Char> ~ EditTree")
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
fn setup_dec_master(ctx: &Arc<RwLock<Context>>, rt_int: &Arc<RwLock<ReprTree>>) {
|
||||
rt_int.write().unwrap().detach( ctx );
|
||||
ctx.read().unwrap().apply_morphism(
|
||||
rt_int,
|
||||
&laddertypes::MorphismType {
|
||||
src_type: Context::parse(&ctx, "ℕ ~ <PosInt 10 BigEndian> ~ <Seq <Digit 10>> ~ <List <Digit 10> ~ Char> ~ EditTree"),
|
||||
dst_type: Context::parse(&ctx, "ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char> ~ EditTree")
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[async_std::main]
|
||||
async fn main() {
|
||||
/* setup context
|
||||
|
@ -70,16 +92,7 @@ async fn main() {
|
|||
dst_type: Context::parse(&ctx, "ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char> ~ EditTree")
|
||||
});
|
||||
|
||||
/* set Hex-editor to be master
|
||||
*/
|
||||
rt_int.write().unwrap().detach( &ctx );
|
||||
ctx.read().unwrap().apply_morphism(
|
||||
&rt_int,
|
||||
&laddertypes::MorphismType {
|
||||
src_type: Context::parse(&ctx, "ℕ ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char> ~ EditTree"),
|
||||
dst_type: Context::parse(&ctx, "ℕ ~ <PosInt 10 BigEndian> ~ <Seq <Digit 10>> ~ <List <Digit 10> ~ Char> ~ EditTree")
|
||||
}
|
||||
);
|
||||
setup_hex_master(&ctx, &rt_int);
|
||||
|
||||
let edittree_hex_be_list = ctx.read().unwrap()
|
||||
.setup_edittree(
|
||||
|
@ -161,24 +174,14 @@ async fn main() {
|
|||
0 => {
|
||||
let mut li = last_idx.write().unwrap();
|
||||
if *li != 0 {
|
||||
rt_int.write().unwrap().detach( &ctx );
|
||||
ctx.read().unwrap().apply_morphism(&rt_int, &laddertypes::MorphismType {
|
||||
src_type: Context::parse(&ctx, "ℕ ~ <PosInt 16 BigEndian> ~ <Seq~List <Digit 16> ~ Char> ~ EditTree"),
|
||||
dst_type: Context::parse(&ctx, "ℕ ~ <PosInt 10 BigEndian> ~ <Seq~List <Digit 10> ~ Char> ~ EditTree")
|
||||
});
|
||||
|
||||
setup_hex_master(&ctx, &rt_int);
|
||||
*li = 0;
|
||||
}
|
||||
}
|
||||
1 => {
|
||||
let mut li = last_idx.write().unwrap();
|
||||
if *li != 1 {
|
||||
rt_int.write().unwrap().detach( &ctx );
|
||||
ctx.read().unwrap().apply_morphism(&rt_int, &laddertypes::MorphismType {
|
||||
src_type: Context::parse(&ctx, "ℕ ~ <PosInt 10 BigEndian> ~ <Seq~List <Digit 10> ~ Char> ~ EditTree"),
|
||||
dst_type: Context::parse(&ctx, "ℕ ~ <PosInt 16 BigEndian> ~ <Seq~List <Digit 16> ~ Char> ~ EditTree")
|
||||
});
|
||||
|
||||
setup_dec_master(&ctx, &rt_int);
|
||||
*li = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,15 +113,11 @@ impl RadixProjection {
|
|||
|
||||
if let Some(src) = self.src.as_ref() {
|
||||
let mut val = src.get_value();
|
||||
if val == 0 {
|
||||
self.dst_digits.push(0);
|
||||
} else {
|
||||
while val > 0 {
|
||||
self.dst_digits.push(val % self.dst_radix);
|
||||
val /= self.dst_radix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let new_len = self.dst_digits.len();
|
||||
for i in 0 .. usize::max(old_len, new_len) {
|
||||
|
|
Loading…
Reference in a new issue