Files
@ 162c3306c4af
Branch filter:
Location: CSY/reowolf/src/protocol/library.rs - annotation
162c3306c4af
3.1 KiB
application/rls-services+xml
laying the groundwork for introducing udp endpoints alongside the existing reowolf-net (over tcp) endpoints
06f259bf8031 06f259bf8031 06f259bf8031 d23010006486 d23010006486 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 06f259bf8031 | use crate::protocol::ast::*;
use crate::protocol::inputsource::*;
// TABBED OUT FOR NOW
pub fn get_declarations(h: &mut Heap, i: ImportId) -> Result<Vec<DeclarationId>, ParseError> {
if h[i].value == b"std.reo" {
let mut vec = Vec::new();
vec.push(cd(h, i, b"sync", &[Type::INPUT, Type::OUTPUT]));
vec.push(cd(h, i, b"syncdrain", &[Type::INPUT, Type::INPUT]));
vec.push(cd(h, i, b"syncspout", &[Type::OUTPUT, Type::OUTPUT]));
vec.push(cd(h, i, b"asyncdrain", &[Type::INPUT, Type::INPUT]));
vec.push(cd(h, i, b"asyncspout", &[Type::OUTPUT, Type::OUTPUT]));
vec.push(cd(h, i, b"merger", &[Type::INPUT_ARRAY, Type::OUTPUT]));
vec.push(cd(h, i, b"router", &[Type::INPUT, Type::OUTPUT_ARRAY]));
vec.push(cd(h, i, b"consensus", &[Type::INPUT_ARRAY, Type::OUTPUT]));
vec.push(cd(h, i, b"replicator", &[Type::INPUT, Type::OUTPUT_ARRAY]));
vec.push(cd(h, i, b"alternator", &[Type::INPUT_ARRAY, Type::OUTPUT]));
vec.push(cd(h, i, b"roundrobin", &[Type::INPUT, Type::OUTPUT_ARRAY]));
vec.push(cd(h, i, b"node", &[Type::INPUT_ARRAY, Type::OUTPUT_ARRAY]));
vec.push(cd(h, i, b"fifo", &[Type::INPUT, Type::OUTPUT]));
vec.push(cd(h, i, b"xfifo", &[Type::INPUT, Type::OUTPUT, Type::MESSAGE]));
vec.push(cd(h, i, b"nfifo", &[Type::INPUT, Type::OUTPUT, Type::INT]));
vec.push(cd(h, i, b"ufifo", &[Type::INPUT, Type::OUTPUT]));
Ok(vec)
} else if h[i].value == b"std.buf" {
let mut vec = Vec::new();
vec.push(fd(h, i, b"writeByte", Type::BYTE, &[Type::MESSAGE, Type::INT, Type::BYTE]));
vec.push(fd(h, i, b"writeShort", Type::SHORT, &[Type::MESSAGE, Type::INT, Type::SHORT]));
vec.push(fd(h, i, b"writeInt", Type::INT, &[Type::MESSAGE, Type::INT, Type::INT]));
vec.push(fd(h, i, b"writeLong", Type::LONG, &[Type::MESSAGE, Type::INT, Type::LONG]));
vec.push(fd(h, i, b"readByte", Type::BYTE, &[Type::MESSAGE, Type::INT]));
vec.push(fd(h, i, b"readShort", Type::SHORT, &[Type::MESSAGE, Type::INT]));
vec.push(fd(h, i, b"readInt", Type::INT, &[Type::MESSAGE, Type::INT]));
vec.push(fd(h, i, b"readLong", Type::LONG, &[Type::MESSAGE, Type::INT]));
Ok(vec)
} else {
Err(ParseError::new(h[i].position, "Unknown import"))
}
}
fn cd(h: &mut Heap, import: ImportId, ident: &[u8], sig: &[Type]) -> DeclarationId {
let identifier = h.get_external_identifier(ident).upcast();
h.alloc_imported_declaration(|this| ImportedDeclaration {
this,
import,
signature: Signature::Component(ComponentSignature { identifier, arity: sig.to_vec() }),
})
.upcast()
}
fn fd(h: &mut Heap, import: ImportId, ident: &[u8], ret: Type, sig: &[Type]) -> DeclarationId {
let identifier = h.get_external_identifier(ident).upcast();
h.alloc_imported_declaration(|this| ImportedDeclaration {
this,
import,
signature: Signature::Function(FunctionSignature {
return_type: ret,
identifier,
arity: sig.to_vec(),
}),
})
.upcast()
}
|