Replies: 2 comments 7 replies
-
语法解析
|
Beta Was this translation helpful? Give feedback.
-
语义节点 local x = 1
print(x) 这里的2个
业务层只需要访问此语义节点,就可以完成查询定义、类型推断等功能。 这个功能可以解决大部分问题,但是有几个地方却比较难用:
---@alias MyType string|number
---@type MyType
local x 这里的局部变量
---@overload fun(x: number, y: number): point
---@class point
Point = {}
local p = Point(x, y) 这里的全局变量
---@class table<K, V>: { [K]: V }
---@type table<number, string>
local t1
---@type table<number, string>
local t2
t1 = t2 最下面的赋值操作会进行一次类型检查,局部变量 ---@class map<K>
---@field [K]: true
---@type map<number>
local t1
---@type map<string>
local t2
t1 = t2 由于对比时会无视
---@alias ManyInts 1 | 2 | 3 | 4 ... | 255 在这种情况下,展开所有的语义来源后,语义节点的长度会变成两百多,每次拷贝、派生新的语义节点时都要全部复制过去,浪费性能
---@alias JValue boolean | number | integer | JArray | JObject
---@alias JArray JValue[]
---@alias JObject { [string]: JValue } 在这种类型递归的情况下,需要在很多地方加判断方式递归过深。
---@class A
---@class B: A
---@class C
---@operator add(B): 'B'
---@operator add(A): 'A'
---@type C
local c
---@type b
local b
local s = c + b 由于 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
目前的核心分为3个主要部分:
Beta Was this translation helpful? Give feedback.
All reactions