Add Array support to functions

This commit is contained in:
K35
2022-01-02 20:51:45 +00:00
parent a8f49d117d
commit db21c1c42e
7 changed files with 143 additions and 40 deletions

View File

@ -44,8 +44,8 @@ export type ServiceFunctionDecorators = {
export interface ServiceFunctionParamsDefinition {
name: string;
inputs: { type: string; name: string }[];
return: string | undefined;
inputs: { type: string; name: string, array: boolean }[];
return: { type: string, array: boolean } | undefined;
decorators: ServiceFunctionDecorators
}
export type ServiceFunctionDefinition = ServiceFunctionParamsDefinition;
@ -191,11 +191,11 @@ export default function get_ir(parsed: Parsed): IR {
);
alreadyFoundFunctions.add(fnc.name);
if (fnc.return_type) {
if (defined.indexOf(fnc.return_type) >= 0) {
if (!depends.some((a) => a === fnc.return_type))
depends.push(fnc.return_type);
if (defined.indexOf(fnc.return_type.type) >= 0) {
if (!depends.some((a) => a === fnc.return_type.type))
depends.push(fnc.return_type.type);
} else {
if (fnc.return_type !== "void" && builtin.indexOf(fnc.return_type) < 0) {
if (fnc.return_type.type !== "void" && builtin.indexOf(fnc.return_type.type) < 0) {
throw new IRError(
fnc,
`Type ${fnc.return_type} is not defined`