This commit fixes compiler bug where it fails when optional values are compiled into absent values in nested calls. - Throw exception with more context for easier future debugging. - Add better validation of argument values for nested calls. - Refactor `FunctionCallCompiler` for better clarity and modularize it to make it more maintainable and testable. - Refactor related interface to not have `I` prefix, and function/variable names for better clarity. Context: Discovered this issue while attempting to call `RunInlineCodeAsTrustedInstaller` which in turn invokes `RunPowerShell` for issue #246. This led to the realization that despite parameters flagged as optional, the nested argument compilation didn't support them.
28 lines
1.3 KiB
TypeScript
28 lines
1.3 KiB
TypeScript
import { FunctionCallCompilationContext } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/FunctionCallCompilationContext';
|
|
import { SingleCallCompiler } from '@/application/Parser/Script/Compiler/Function/Call/Compiler/SingleCall/SingleCallCompiler';
|
|
import { FunctionCall } from '@/application/Parser/Script/Compiler/Function/Call/FunctionCall';
|
|
import { ISharedFunctionCollection } from '@/application/Parser/Script/Compiler/Function/ISharedFunctionCollection';
|
|
import { SingleCallCompilerStub } from './SingleCallCompilerStub';
|
|
import { FunctionCallStub } from './FunctionCallStub';
|
|
import { SharedFunctionCollectionStub } from './SharedFunctionCollectionStub';
|
|
|
|
export class FunctionCallCompilationContextStub implements FunctionCallCompilationContext {
|
|
public allFunctions: ISharedFunctionCollection = new SharedFunctionCollectionStub();
|
|
|
|
public rootCallSequence: readonly FunctionCall[] = [
|
|
new FunctionCallStub(), new FunctionCallStub(),
|
|
];
|
|
|
|
public singleCallCompiler: SingleCallCompiler = new SingleCallCompilerStub();
|
|
|
|
public withSingleCallCompiler(singleCallCompiler: SingleCallCompiler): this {
|
|
this.singleCallCompiler = singleCallCompiler;
|
|
return this;
|
|
}
|
|
|
|
public withAllFunctions(allFunctions: ISharedFunctionCollection): this {
|
|
this.allFunctions = allFunctions;
|
|
return this;
|
|
}
|
|
}
|