Skip to content

달빛약속 / core/mod / CodeFile

Class: CodeFile

달빛 약속 소스코드 파일 하나를 나타내는 클래스입니다. 파일 단위의 처리 과정(토크나이징, 파싱, 실행)을 담당합니다.

Description

이 클래스의 인스턴스는 YaksokSession에 의해 관리됩니다.

Constructors

new CodeFile()

new CodeFile(text, fileName): CodeFile

Parameters

text

string

fileName

string | symbol

Returns

CodeFile

Defined in

core/type/code-file.ts:33

Properties

fileName

fileName: string | symbol

Defined in

core/type/code-file.ts:33


ranScope

ranScope: Scope = null

Defined in

core/type/code-file.ts:30


session

session: YaksokSession = null

Defined in

core/type/code-file.ts:31


text

text: string

Defined in

core/type/code-file.ts:33

Accessors

ast

Get Signature

get ast(): Block

토큰화된 코드를 파싱하여 생성된 추상 구문 트리(AST)를 반환합니다.

Description

지연 평가 및 캐싱: 이 getter에 처음 접근할 때만 파싱을 수행하고, 그 결과를 내부 속성에 캐싱합니다.

Returns

Block

AST의 루트 노드인 Block 객체를 반환합니다.

Defined in

core/type/code-file.ts:95


exportedRules

Get Signature

get exportedRules(): Rule[]

이 파일에서 다른 파일로 내보내는 파싱 규칙을 반환합니다.

Returns

Rule[]

Defined in

core/type/code-file.ts:121


functionDeclareRanges

Get Signature

get functionDeclareRanges(): FunctionDeclareRangesByType

코드 내의 함수 선언 범위를 반환합니다.

Returns

FunctionDeclareRangesByType

Defined in

core/type/code-file.ts:106


mounted

Get Signature

get mounted(): boolean

CodeFile이 세션에 마운트되었는지 여부를 반환합니다.

Returns

boolean

Defined in

core/type/code-file.ts:47


tokens

Get Signature

get tokens(): Token[]

소스코드를 토큰화한 결과를 반환합니다.

Description

지연 평가 및 캐싱: 이 getter에 처음 접근할 때만 토크나이징을 수행하고, 그 결과를 내부 속성에 캐싱합니다. 이후의 접근에서는 캐시된 값을 즉시 반환합니다.

Returns

Token[]

Token 객체의 배열을 반환합니다.

Defined in

core/type/code-file.ts:61

Methods

mount()

mount(session): void

CodeFileYaksokSession에 마운트합니다. 이 과정을 통해 CodeFile은 상위 세션의 상태와 설정에 접근할 수 있게 됩니다.

Parameters

session

YaksokSession

CodeFile을 소유하는 YaksokSession 인스턴스입니다.

Returns

void

Defined in

core/type/code-file.ts:40


run()

run(): Promise<Scope>

파싱된 AST를 실행합니다.

Returns

Promise<Scope>

실행이 완료된 후의 최종 스코프(Scope) 객체를 반환합니다.

Description

실행 결과 캐싱: 이 메서드는 실행이 완료된 후 최종 스코프를 ranScope에 캐싱합니다. 만약 이미 실행된 파일에 대해 run이 다시 호출되면, 실제 코드를 재실행하지 않고 캐시된 스코프를 즉시 반환합니다. 이는 모듈이 여러 번 참조되어도 단 한 번만 실행되도록 보장합니다.

Defined in

core/type/code-file.ts:185


validate()

validate(): object

코드를 정적으로 분석하여 유효성을 검사하고 잠재적인 오류를 찾습니다.

Returns

object

검사 과정에서 발견된 오류(YaksokError) 배열과, 검사에 사용된 스코프를 반환합니다.

errors

errors: YaksokError<unknown>[]

validatingScope

validatingScope: Scope

Defined in

core/type/code-file.ts:151