Skip to content

달빛약속 / core/mod / DeclareFunction

Class: DeclareFunction

약속 키워드를 통해 함수(약속)를 선언하는 AST 노드입니다.

Description

이 노드는 실행될 때 실제로 함수 코드를 실행하는 것이 아니라, 실행 가능한 FunctionObject를 생성하여 현재 스코프에 등록하는 역할을 합니다. 이때 FunctionObject는 함수가 선언된 시점의 스코프를 기억하며, 이는 클로저(Closure)를 구현하는 핵심입니다.

Extends

Indexable

[key: string]: unknown

Constructors

new DeclareFunction()

new DeclareFunction(props, tokens): DeclareFunction

Parameters

props
body

Block

name

string

tokens

Token[]

Returns

DeclareFunction

Overrides

Executable.constructor

Defined in

core/node/function.ts:30

Properties

body

body: Block

Defined in

core/node/function.ts:28


name

name: string

Defined in

core/node/function.ts:27


tokens

tokens: Token[]

Inherited from

Executable.tokens

Defined in

core/node/function.ts:32


friendlyName

static friendlyName: string = '새 약속 만들기'

Overrides

Executable.friendlyName

Defined in

core/node/function.ts:25

Methods

execute()

execute(scope): Promise<void>

함수를 나타내는 FunctionObject를 생성하고 현재 스코프에 추가합니다.

Parameters

scope

Scope

함수가 선언되는 현재의 스코프입니다.

Returns

Promise<void>

Overrides

Executable.execute

Defined in

core/node/function.ts:44


toJSON()

toJSON(): object

Returns

object

Inherited from

Executable.toJSON

Defined in

core/node/base.ts:20


toPrint()

toPrint(): string

Returns

string

Inherited from

Executable.toPrint

Defined in

core/node/base.ts:39


validate()

validate(scope): YaksokError<unknown>[]

Parameters

scope

Scope

Returns

YaksokError<unknown>[]

Overrides

Executable.validate

Defined in

core/node/function.ts:61