Skip to content

달빛약속 / core/mod / FunctionInvoke

Class: FunctionInvoke

선언된 함수(약속)를 호출하는 AST 노드입니다.

Example

약속, 더하기 (A) (B)
    A + B 반환하기

(더하기 1 2) 보여주기 // FunctionInvoke 노드가 생성되는 부분

Extends

Indexable

[key: string]: unknown

Constructors

new FunctionInvoke()

new FunctionInvoke(props, tokens): FunctionInvoke

Parameters

props
name

string

params

Record<string, Evaluable<ValueType>>

tokens

Token[]

Returns

FunctionInvoke

Overrides

Evaluable.constructor

Defined in

core/node/function.ts:111

Properties

name

name: string

Defined in

core/node/function.ts:108


params

params: Record<string, Evaluable<ValueType>>

Defined in

core/node/function.ts:109


tokens

tokens: Token[]

Inherited from

Evaluable.tokens

Defined in

core/node/function.ts:113


friendlyName

static friendlyName: string = '약속 사용하기'

Overrides

Evaluable.friendlyName

Defined in

core/node/function.ts:106

Accessors

value

Get Signature

get value(): string

Returns

string

Defined in

core/node/function.ts:166

Methods

execute()

execute(scope, args?): Promise<ValueType>

스코프에서 함수를 찾아 실행하고, 그 결과값을 반환합니다.

Parameters

scope

Scope

함수가 호출되는 현재의 스코프입니다.

args?

FunctionInvokingParams

함수에 전달될 인자입니다. (선택 사항)

Returns

Promise<ValueType>

함수의 실행 결과값 (ValueType)을 반환합니다.

Description

  1. scope.getFunctionObject를 통해 현재 또는 상위 스코프에서 호출할 함수 객체를 찾습니다.
  2. functionObject.run을 호출하여 함수를 실행합니다. 이 때 FunctionObject는 자신이 기억하고 있던 선언 시점의 스코프를 부모로 하는 새로운 실행 스코프를 생성하여 함수 본문을 실행합니다.

Overrides

Evaluable.execute

Defined in

core/node/function.ts:133


toJSON()

toJSON(): object

Returns

object

Inherited from

Evaluable.toJSON

Defined in

core/node/base.ts:20


toPrint()

toPrint(): string

Returns

string

Inherited from

Evaluable.toPrint

Defined in

core/node/base.ts:39


validate()

validate(scope): YaksokError<unknown>[]

Parameters

scope

Scope

Returns

YaksokError<unknown>[]

Overrides

Evaluable.validate

Defined in

core/node/function.ts:170