in generation of main function, fix case that input/output buffer is a nullterm string
This commit is contained in:
parent
1116457bcc
commit
a58ac1a69c
2 changed files with 20 additions and 12 deletions
src
|
@ -21,18 +21,23 @@ pub fn generate_lib(
|
||||||
uint8_t bufIn[4096];
|
uint8_t bufIn[4096];
|
||||||
uint8_t bufOut[4096];"#));
|
uint8_t bufOut[4096];"#));
|
||||||
|
|
||||||
let (src_top, src_floor) = inst.ty.src_type.get_floor_type();
|
if let Ok(_) = laddertypes::subtype_unify(
|
||||||
if src_floor == dict.parse_desugared("<Seq~<ValueTerminated 0> native.UInt8>").expect("").sugar(dict) {
|
&inst.ty.src_type,
|
||||||
|
&dict.parse("<Seq~<ValueTerminated 0> Char~Ascii~native.UInt8>").expect("")
|
||||||
|
) {
|
||||||
c_source.push_str("scanf(\"%s\", bufIn);");
|
c_source.push_str("scanf(\"%s\", bufIn);");
|
||||||
} else {
|
} else {
|
||||||
c_source.push_str("read(0, bufIn, sizeof(bufIn));");
|
c_source.push_str("read(0, bufIn, sizeof(bufIn));");
|
||||||
}
|
}
|
||||||
|
|
||||||
c_source.push_str(&format!(r#"FUSE( {}, (void const*)bufIn, (void*)bufOut );"#, inst.instantiated_symbol_name(dict, &HashMap::new())));
|
c_source.push_str(
|
||||||
|
&format!(r#"FUSE( {}, (void const*)bufIn, (void*)bufOut );"#,
|
||||||
|
inst.instantiated_symbol_name(dict, &HashMap::new()))
|
||||||
|
);
|
||||||
|
|
||||||
if let Ok(ψ) = laddertypes::constraint_system::subtype_unify(
|
if let Ok(ψ) = laddertypes::subtype_unify(
|
||||||
&inst.ty.src_type,
|
&inst.ty.dst_type,
|
||||||
&dict.parse_desugared("<Seq~<ValueTerminated 0> native.UInt8>").expect("").sugar(dict)
|
&dict.parse("<Seq~<ValueTerminated 0> native.UInt8>").expect("")
|
||||||
) {
|
) {
|
||||||
c_source.push_str("printf(\"%s\\n\", bufOut);");
|
c_source.push_str("printf(\"%s\\n\", bufOut);");
|
||||||
} else {
|
} else {
|
||||||
|
|
15
src/main.rs
15
src/main.rs
|
@ -9,12 +9,15 @@ use {
|
||||||
crate::{
|
crate::{
|
||||||
morphism::LdmcPrimMorph,
|
morphism::LdmcPrimMorph,
|
||||||
parser::morphism_base_parser,
|
parser::morphism_base_parser,
|
||||||
}, ariadne::{Color, Label, Report, ReportKind, Source}, chumsky::prelude::*, clap::{Parser, Subcommand}, laddertypes::{
|
},
|
||||||
morphism::MorphismType,
|
laddertypes::{
|
||||||
parser::ParseLadderType, BimapTypeDict
|
morphism::MorphismType, BimapTypeDict
|
||||||
}, parser::morphism_type_parser, std::{path::PathBuf,
|
}, parser::morphism_type_parser,
|
||||||
sync::{Arc, RwLock}}, tiny_ansi::TinyAnsi,
|
ariadne::{Color, Label, Report, ReportKind, Source},
|
||||||
walkdir::WalkDir
|
clap::Parser,
|
||||||
|
walkdir::WalkDir,
|
||||||
|
tiny_ansi::TinyAnsi,
|
||||||
|
std::{path::PathBuf, sync::{Arc, RwLock}},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue