From fca8e214559d5be9fbf7272e3435dda23c54711a Mon Sep 17 00:00:00 2001 From: laibo102 Date: Thu, 16 Jun 2022 14:41:50 +0800 Subject: [PATCH 1/5] bugfix: fixed resource type support Signed-off-by: laibo102 Change-Id: I1d0fcc9d54a9f82af70aa45f755812a15ddcdae7 --- compiler/src/pre_define.ts | 3 ++- compiler/src/process_ui_syntax.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index 5a665b9..9dc8b93 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -175,7 +175,8 @@ export const RESOURCE_TYPE = { pattern: 10008, strarray: 10009, media: 20000, - rawfile: 30000 + rawfile: 30000, + graphic: 40000 }; export const WORKERS_DIR: string = 'workers'; diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index e1c7684..2b968ca 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -298,6 +298,13 @@ function processResourceData(node: ts.CallExpression): ts.Node { const resourceData: string[] = node.arguments[0].text.trim().split('.'); if (validateResourceData(resourceData, resources, node.arguments[0].getStart())) { const resourceType: number = RESOURCE_TYPE[resourceData[1]]; + if (resourceType === undefined) { + transformLog.errors.push({ + type: LogType.ERROR, + message: `The resource type ${resourceData[1]} is not supported.`, + pos: node.getStart() + }) + } const resourceValue: number = resources[resourceData[0]][resourceData[1]][resourceData[2]]; return createResourceParam(resourceValue, resourceType, Array.from(node.arguments).slice(1)); From 298fe728f2e64395bd2964d0ccbca30f0b0a83cb Mon Sep 17 00:00:00 2001 From: laibo102 Date: Thu, 16 Jun 2022 17:02:17 +0800 Subject: [PATCH 2/5] bugfix: fixed resource type support Signed-off-by: laibo102 Change-Id: I9c8daa6db88d79c5f663f164481c3cd603acf858 --- compiler/src/process_ui_syntax.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 2b968ca..7559ac2 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -304,6 +304,7 @@ function processResourceData(node: ts.CallExpression): ts.Node { message: `The resource type ${resourceData[1]} is not supported.`, pos: node.getStart() }) + return ; } const resourceValue: number = resources[resourceData[0]][resourceData[1]][resourceData[2]]; return createResourceParam(resourceValue, resourceType, From 7196b767ed386ba946b0b22740300e1e8609e100 Mon Sep 17 00:00:00 2001 From: laibo102 Date: Thu, 16 Jun 2022 17:07:31 +0800 Subject: [PATCH 3/5] bugfix: fixed resource type support Signed-off-by: laibo102 Change-Id: Iad85ac37326151f97fab23c90803c0160da0f6f6 --- compiler/src/process_ui_syntax.ts | 36 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 7559ac2..9493ca3 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -294,27 +294,31 @@ function processResourceData(node: ts.CallExpression): ts.Node { if (node.expression.getText() === RESOURCE_RAWFILE) { return createResourceParam(0, RESOURCE_TYPE.rawfile, [node.arguments[0]]); } else { - // @ts-ignore - const resourceData: string[] = node.arguments[0].text.trim().split('.'); - if (validateResourceData(resourceData, resources, node.arguments[0].getStart())) { - const resourceType: number = RESOURCE_TYPE[resourceData[1]]; - if (resourceType === undefined) { - transformLog.errors.push({ - type: LogType.ERROR, - message: `The resource type ${resourceData[1]} is not supported.`, - pos: node.getStart() - }) - return ; - } - const resourceValue: number = resources[resourceData[0]][resourceData[1]][resourceData[2]]; - return createResourceParam(resourceValue, resourceType, - Array.from(node.arguments).slice(1)); - } + return getResourceDataNode(node); } } return node; } +function getResourceDataNode(node: ts.CallExpression): ts.Node { + const resourceData: string[] = (node.arguments[0] as ts.StringLiteral).text.trim().split('.'); + if (validateResourceData(resourceData, resources, node.arguments[0].getStart())) { + const resourceType: number = RESOURCE_TYPE[resourceData[1]]; + if (resourceType === undefined) { + transformLog.errors.push({ + type: LogType.ERROR, + message: `The resource type ${resourceData[1]} is not supported.`, + pos: node.getStart() + }) + return ; + } + const resourceValue: number = resources[resourceData[0]][resourceData[1]][resourceData[2]]; + return createResourceParam(resourceValue, resourceType, + Array.from(node.arguments).slice(1)); + } + return node; +} + function createResourceParam(resourceValue: number, resourceType: number, argsArr: ts.Expression[]): ts.ObjectLiteralExpression { const propertyArray: Array[ts.PropertyAssignment] = [ From 82070d7665d961904783d2e9d6fdf0777ee4a947 Mon Sep 17 00:00:00 2001 From: laibo102 Date: Thu, 16 Jun 2022 17:10:47 +0800 Subject: [PATCH 4/5] bugfix: fixed resource type support Signed-off-by: laibo102 Change-Id: I9bfea2cc7244fc74c5f8a6786f0dea61c014d94d --- compiler/src/process_ui_syntax.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 9493ca3..0b0e244 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -309,8 +309,8 @@ function getResourceDataNode(node: ts.CallExpression): ts.Node { type: LogType.ERROR, message: `The resource type ${resourceData[1]} is not supported.`, pos: node.getStart() - }) - return ; + }); + return; } const resourceValue: number = resources[resourceData[0]][resourceData[1]][resourceData[2]]; return createResourceParam(resourceValue, resourceType, From d7cd4a13aba83232ded963fec73bd8a9b442137e Mon Sep 17 00:00:00 2001 From: laibo102 Date: Fri, 17 Jun 2022 10:56:50 +0800 Subject: [PATCH 5/5] bugfix: fixed resource type support Signed-off-by: laibo102 Change-Id: I0168b45ea9b177fe4fce6451be770cfce5a23f63 --- compiler/src/process_ui_syntax.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 0b0e244..ebba07a 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -310,7 +310,7 @@ function getResourceDataNode(node: ts.CallExpression): ts.Node { message: `The resource type ${resourceData[1]} is not supported.`, pos: node.getStart() }); - return; + return node; } const resourceValue: number = resources[resourceData[0]][resourceData[1]][resourceData[2]]; return createResourceParam(resourceValue, resourceType,