提交 74913264 编写于 作者: fxy060608's avatar fxy060608

wip(uts): compiler

上级 b246555c
......@@ -22,7 +22,7 @@ export default function getBatteryInfo(options: GetBatteryInfoOptions) {
}
}
export function test1(callback: () => void) {
export function test1(callback: () => void): string {
console.log('test1')
//#ifdef APP-ANDROID
console.log('def android')
......@@ -42,6 +42,7 @@ export function test1(callback: () => void) {
//#ifdef MP-WEIXIN
console.log('def weixin')
//#endif
return 'test1'
}
class Test1 {}
......
......@@ -10,11 +10,11 @@ class GetBatteryInfoOptions : UTSJSONObject {
public var complete: UTSCallback?;
}
func getBatteryInfo(_ options: GetBatteryInfoOptions) {
var res = [
var res = UTSJSONObject([
"errMsg": "getBatteryInfo:ok",
"level": UIDevice.current.batteryLevel * 100,
"isCharging": UIDevice.current.batteryState == UIDevice.BatteryState.charging
] as [String: Any];
]);
if (options.success != nil) {
options.success!(res);
}
......@@ -22,11 +22,12 @@ func getBatteryInfo(_ options: GetBatteryInfoOptions) {
options.complete!(res);
}
}
func test1(_ callback: UTSCallback) {
func test1(_ callback: UTSCallback) -> String {
console.log("test1", " at uni_modules/test-uniplugin/app-ios/index.uts:26");
console.log("def ios", " at uni_modules/test-uniplugin/app-ios/index.uts:31");
console.log("ndef android", " at uni_modules/test-uniplugin/app-ios/index.uts:34");
console.log("def android || def ios", " at uni_modules/test-uniplugin/app-ios/index.uts:40");
return "test1";
}
class Test1 : NSObject {
}
......@@ -46,7 +47,7 @@ class IndexSwift : NSObject {
public static func s_getBatteryInfo(_ options: GetBatteryInfoOptions) {
return getBatteryInfo(options);
}
public static func s_test1(_ callback: UTSCallback) {
public static func s_test1(_ callback: UTSCallback) -> String {
return test1(callback);
}
}
{"version":3,"sources":["/Users/fxy/Projects/GitHub/uni-app/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/app-ios/index.uts"],"sourcesContent":["import { UIDevice } from 'UIKit'\n\ntype GetBatteryInfoOptions = {\n name: string\n pwd: number\n success?: (res: UTSJSONObject) => void\n fail?: (res: UTSJSONObject) => void\n complete?: (res: UTSJSONObject) => void\n}\n\nexport default function getBatteryInfo(options: GetBatteryInfoOptions) {\n const res = {\n errMsg: 'getBatteryInfo:ok',\n level: UIDevice.current.batteryLevel * 100,\n isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,\n }\n if (options.success != null) {\n options.success!(res)\n }\n if (options.complete != null) {\n options.complete!(res)\n }\n}\n\nexport function test1(callback: () => void) {\n console.log('test1')\n\n\n\n\n console.log('def ios')\n\n\n console.log('ndef android')\n\n\n\n\n\n console.log('def android || def ios')\n\n\n\n\n}\n\nclass Test1 {}\nexport class Test {\n constructor() {\n new Test1()\n }\n test(): string | null {\n return null\n }\n}\n"],"names":[],"mappings":";AAAA;AAE6B;;MAAxB,qBAAqB;IACxB,WAAA,IAAI,EAAE,MAAM,EAAA;IACZ,WAAA,GAAG,EAAE,QAAM,EAAA;IACX,WAAA,OAAO,EAAC,WAA8B,EAAA;IACtC,WAAA,IAAI,EAAC,WAA8B,EAAA;IACnC,WAAA,QAAQ,EAAC,WAA8B,EAAA;CACxC;AAEc,KAAS,cAAc,CAAC,EAAA,OAA8B,EAArB,qBAAqB,EAAE;IACrE,IAAM,GAAG,GAAG;QACV,CAAA,MAAM,GAAE,mBAAmB;QAC3B,CAAA,KAAK,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,GAAG,GAAG;QAC1C,CAAA,UAAU,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,IAAI,QAAQ,CAAC,YAAY,CAAC,QAAQ;sBAC5E;IACD,IAAI,OAAO,CAAC,OAAO,IAAI,GAAI;QACzB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;;IAEvB,IAAI,OAAO,CAAC,QAAQ,IAAI,GAAI;QAC1B,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;;AAE1B;AAEO,KAAS,KAAK,CAAC,EAAA,QAAoB,aAAA,EAAE;IAC1C,OAAO,CAAC,GAAG,CAAC,OAAO,wDAAC;IAKpB,OAAO,CAAC,GAAG,CAAC,SAAS,wDAAC;IAGtB,OAAO,CAAC,GAAG,CAAC,cAAc,wDAAC;IAM3B,OAAO,CAAC,GAAG,CAAC,wBAAwB,wDAAC;AAKvC;AAEA,MAAM,KAAK;CAAG;AACP;;MAAM,IAAI;IACf,aAAc;QACZ,AAAI,KAAK,EAAE;IACb;gBACA,IAAI,MAAI,MAAM,EAAQ;QACpB,OAAO,GAAI,CAAA;IACb;CACD;;;;wCA5CsC,EAAA,OAA8B,EAArB,qBAAqB;eAA7C,cAAc,CAAC,OAA8B;;+BAc/C,EAAA,QAAoB,aAAA;eAA1B,KAAK,CAAC,QAAoB"}
\ No newline at end of file
{"version":3,"sources":["/Users/fxy/Projects/GitHub/uni-app/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/app-ios/index.uts"],"sourcesContent":["import { UIDevice } from 'UIKit'\n\ntype GetBatteryInfoOptions = {\n name: string\n pwd: number\n success?: (res: UTSJSONObject) => void\n fail?: (res: UTSJSONObject) => void\n complete?: (res: UTSJSONObject) => void\n}\n\nexport default function getBatteryInfo(options: GetBatteryInfoOptions) {\n const res = {\n errMsg: 'getBatteryInfo:ok',\n level: UIDevice.current.batteryLevel * 100,\n isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,\n }\n if (options.success != null) {\n options.success!(res)\n }\n if (options.complete != null) {\n options.complete!(res)\n }\n}\n\nexport function test1(callback: () => void): string {\n console.log('test1')\n\n\n\n\n console.log('def ios')\n\n\n console.log('ndef android')\n\n\n\n\n\n console.log('def android || def ios')\n\n\n\n\n return 'test1'\n}\n\nclass Test1 {}\nexport class Test {\n constructor() {\n new Test1()\n }\n test(): string | null {\n return null\n }\n}\n"],"names":[],"mappings":";AAAA;AAE6B;;MAAxB,qBAAqB;IACxB,WAAA,IAAI,EAAE,MAAM,EAAA;IACZ,WAAA,GAAG,EAAE,QAAM,EAAA;IACX,WAAA,OAAO,EAAC,WAA8B,EAAA;IACtC,WAAA,IAAI,EAAC,WAA8B,EAAA;IACnC,WAAA,QAAQ,EAAC,WAA8B,EAAA;CACxC;AAEc,KAAS,cAAc,CAAC,EAAA,OAA8B,EAArB,qBAAqB,EAAE;IACrE,IAAM,GAAG,GAAG;QACV,CAAA,MAAM,GAAE,mBAAmB;QAC3B,CAAA,KAAK,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,GAAG,GAAG;QAC1C,CAAA,UAAU,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,IAAI,QAAQ,CAAC,YAAY,CAAC,QAAQ;MAC5E;IACD,IAAI,OAAO,CAAC,OAAO,IAAI,GAAI;QACzB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;;IAEvB,IAAI,OAAO,CAAC,QAAQ,IAAI,GAAI;QAC1B,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;;AAE1B;AAEO,KAAS,KAAK,CAAC,EAAA,QAAoB,aAAA,KAAG,MAAM,CAAC;IAClD,OAAO,CAAC,GAAG,CAAC,OAAO,wDAAC;IAKpB,OAAO,CAAC,GAAG,CAAC,SAAS,wDAAC;IAGtB,OAAO,CAAC,GAAG,CAAC,cAAc,wDAAC;IAM3B,OAAO,CAAC,GAAG,CAAC,wBAAwB,wDAAC;IAKrC,OAAO,OAAO,CAAA;AAChB;AAEA,MAAM,KAAK;CAAG;AACP;;MAAM,IAAI;IACf,aAAc;QACZ,AAAI,KAAK,EAAE;IACb;gBACA,IAAI,MAAI,MAAM,EAAQ;QACpB,OAAO,GAAI,CAAA;IACb;CACD;;;;wCA7CsC,EAAA,OAA8B,EAArB,qBAAqB;eAA7C,cAAc,CAAC,OAA8B;;+BAc/C,EAAA,QAAoB,aAAA,KAAG,MAAM;eAAnC,KAAK,CAAC,QAAoB"}
\ No newline at end of file
......@@ -143,6 +143,29 @@ function mergeDecls(from: ProxyDecl[], to: ProxyDecl[]) {
) {
to.push(item)
}
} else if (
item.type === 'VariableDeclaration' &&
item.declarations.length === 1
) {
if (
!to.find((toItem) => {
if (
toItem.type === 'VariableDeclaration' &&
toItem.declarations.length === 1
) {
const toDecl = toItem.declarations[0].id
const decl = item.declarations[0].id
return (
toDecl.type === 'Identifier' &&
decl.type === 'Identifier' &&
toDecl.value === decl.value
)
}
return false
})
) {
to.push(item)
}
}
})
return to
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册