Compare commits

..

No commits in common. "7762fa4b128ad1e685e356a0de275842f0d43676" and "8d637a6f325a0c42d7303a487457f65f4fca121c" have entirely different histories.

2 changed files with 28 additions and 29 deletions

View file

@ -32,6 +32,28 @@ use {
std::sync::{Arc, RwLock}, 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_std::main]
async fn main() { async fn main() {
/* setup context /* 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") dst_type: Context::parse(&ctx, " ~ <PosInt 16 BigEndian> ~ <Seq <Digit 16>> ~ <List <Digit 16> ~ Char> ~ EditTree")
}); });
/* set Hex-editor to be master setup_hex_master(&ctx, &rt_int);
*/
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")
}
);
let edittree_hex_be_list = ctx.read().unwrap() let edittree_hex_be_list = ctx.read().unwrap()
.setup_edittree( .setup_edittree(
@ -161,24 +174,14 @@ async fn main() {
0 => { 0 => {
let mut li = last_idx.write().unwrap(); let mut li = last_idx.write().unwrap();
if *li != 0 { if *li != 0 {
rt_int.write().unwrap().detach( &ctx ); setup_hex_master(&ctx, &rt_int);
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")
});
*li = 0; *li = 0;
} }
} }
1 => { 1 => {
let mut li = last_idx.write().unwrap(); let mut li = last_idx.write().unwrap();
if *li != 1 { if *li != 1 {
rt_int.write().unwrap().detach( &ctx ); setup_dec_master(&ctx, &rt_int);
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")
});
*li = 1; *li = 1;
} }
} }

View file

@ -113,15 +113,11 @@ impl RadixProjection {
if let Some(src) = self.src.as_ref() { if let Some(src) = self.src.as_ref() {
let mut val = src.get_value(); let mut val = src.get_value();
if val == 0 {
self.dst_digits.push(0);
} else {
while val > 0 { while val > 0 {
self.dst_digits.push(val % self.dst_radix); self.dst_digits.push(val % self.dst_radix);
val /= self.dst_radix; val /= self.dst_radix;
} }
} }
}
let new_len = self.dst_digits.len(); let new_len = self.dst_digits.len();
for i in 0 .. usize::max(old_len, new_len) { for i in 0 .. usize::max(old_len, new_len) {