import { Import } from "../Languages/Imports/Import" ; import { NativeCallScope , NativeCallSyntax } from "../Languages/Properties/Syntax/NativeCallSyntax" ; import { LineResults } from "../LineResults" ; import { RenderContext } from "../RenderContext" ; import { Command } from "./Command" ; import { NativeArrayRenderer } from "./NativeCallRendering/NativeArrayRenderer" ; import { NativeCallRenderer } from "./NativeCallRendering/NativeCallRenderer" ; import { NativeMemberRenderer } from "./NativeCallRendering/NativeMemberRenderer" ; import { NativeOperatorRenderer } from "./NativeCallRendering/NativeOperatorRenderer" ; import { NativeStaticRenderer } from "./NativeCallRendering/NativeStaticRenderer" ; /**
 * A command for performing a native call, such as Array::push.
 */ export abstract class NativeCallCommand extends Command { /**
     * Metadata on how to perform the native call.
     */ protected nativeCallSyntax : NativeCallSyntax ; /**
     * Renderers for each allowed scope.
     */ private scopeRenderers : { [ i ] : NativeCallRenderer ; } ; param context public constructor ( context ) { super ( context ) ; this . nativeCallSyntax = this . retrieveNativeCallSyntax ( ) ; this . scopeRenderers = { [ NativeCallScope . Array ] : new NativeArrayRenderer ( this . nativeCallSyntax ) , [ NativeCallScope . Member ] : new NativeMemberRenderer ( this . nativeCallSyntax ) , [ NativeCallScope . Operator ] : new NativeOperatorRenderer ( this . nativeCallSyntax ) , [ NativeCallScope . Static ] : new NativeStaticRenderer ( this . nativeCallSyntax ) , } ; } param parameters returns public render ( parameters ) { const scope = this . nativeCallSyntax . scope ; const results = this . scopeRenderers [ scope ] . render ( parameters ) ; results . withImports ( this . retrieveImports ( ) ) ; return results ; } returns protected retrieveImports ( ) { return this . nativeCallSyntax . imports ; } returns protected abstract retrieveNativeCallSyntax ( ) ; }