37 lines
848 B
Plaintext
37 lines
848 B
Plaintext
|
///createBlock(inputTypes, outputTypes)
|
||
|
/**
|
||
|
* createBlock :: List Type -> List Type -> Instance
|
||
|
*
|
||
|
* Creates a block with the given types and returns the id of the block.
|
||
|
*
|
||
|
* @param inputTypes a list of input types
|
||
|
* @param outputTypes a list of output types
|
||
|
* @returns the id of the block instance
|
||
|
*/
|
||
|
|
||
|
var inputTypes = argument0;
|
||
|
var outputTypes = argument1;
|
||
|
var block = new(Block);
|
||
|
|
||
|
for (var i = 0; i < ds_list_size(inputTypes); i++) {
|
||
|
var anchor = new(InputAnchor);
|
||
|
anchor.freshType = new(TypeConLink);
|
||
|
addLink(anchor.freshType, inputTypes[|i]);
|
||
|
|
||
|
addChild(block, anchor);
|
||
|
}
|
||
|
|
||
|
for (var i = 0; i < ds_list_size(outputTypes); i++) {
|
||
|
var anchor = new(OutputAnchor);
|
||
|
anchor.freshType = new(TypeConLink);
|
||
|
addLink(anchor.freshType, outputTypes[|i]);
|
||
|
|
||
|
addChild(block, anchor);
|
||
|
}
|
||
|
|
||
|
freshTypes(block);
|
||
|
layout(block);
|
||
|
|
||
|
return block;
|
||
|
|