allow functions to call other functions #53
This commit is contained in:
21
tests/unit/stubs/SharedFunctionCollectionStub.ts
Normal file
21
tests/unit/stubs/SharedFunctionCollectionStub.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { ISharedFunction } from '@/application/Parser/Script/Compiler/Function/ISharedFunction';
|
||||
import { ISharedFunctionCollection } from '@/application/Parser/Script/Compiler/Function/ISharedFunctionCollection';
|
||||
|
||||
export class SharedFunctionCollectionStub implements ISharedFunctionCollection {
|
||||
private readonly functions = new Map<string, ISharedFunction>();
|
||||
public withFunction(func: ISharedFunction) {
|
||||
this.functions.set(func.name, func);
|
||||
return this;
|
||||
}
|
||||
public getFunctionByName(name: string): ISharedFunction {
|
||||
if (this.functions.has(name)) {
|
||||
return this.functions.get(name);
|
||||
}
|
||||
return {
|
||||
name,
|
||||
parameters: [],
|
||||
code: 'code by SharedFunctionCollectionStub',
|
||||
revertCode: 'revert-code by SharedFunctionCollectionStub',
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user