diff --git a/testTs/instype/recordexport.ts b/testTs/instype/recordexport.ts index 5328134355b26623feed8a8e7b24c58730b8ca72..105a82b844d54b63748db35a91e7b43f17b8d237 100644 --- a/testTs/instype/recordexport.ts +++ b/testTs/instype/recordexport.ts @@ -1,4 +1,4 @@ -export default function hello(str: string) { +export default function hello(str: string): string { return str; } @@ -9,11 +9,11 @@ export let d: string = "world"; export class Calculator{} -export function add(x: number, y: number) { +export function add(x: number, y: number): number { return x + y; } -export function minus(x: number, y: number) { +export function minus(x: number, y: number): number { return x - y; } diff --git a/testTs/instype/recordthis.ts b/testTs/instype/recordthis.ts index c032ae27be269f1d72cf5815cd4651fce77f79ff..7ddec1decf85b472a0b2010196e8eefd3b476fdd 100644 --- a/testTs/instype/recordthis.ts +++ b/testTs/instype/recordthis.ts @@ -19,7 +19,7 @@ class A { get getName(): string { return this.name; } - get getId() { + get getId(): number { return this.id; } set setName(name: string) { @@ -37,13 +37,13 @@ class A { } static a: number = 1; a: number = 2; - static stest() { + static stest(): void { console.log(this.a); } - test() { + test(): void { console.log(this.a); } - testwiththis(this: A) { + testwiththis(this: A): void { console.log(this.a); } } diff --git a/ts2panda/src/addVariable2Scope.ts b/ts2panda/src/addVariable2Scope.ts index 0f64f618bd98e704a544007959ff3287c266fc62..b35414a1895cc8d8e7e2db094a86b63cb812fe64 100644 --- a/ts2panda/src/addVariable2Scope.ts +++ b/ts2panda/src/addVariable2Scope.ts @@ -42,7 +42,7 @@ import { Variable } from "./variable"; -function setVariableOrParameterType(node: ts.Node, v: Variable | undefined) { +function setVariableOrParameterType(node: ts.Node, v: Variable | undefined): void { if (v) { let typeIndex = TypeRecorder.getInstance().tryGetVariable2Type(ts.getOriginalNode(node)); if (typeIndex === PrimitiveType.ANY) { @@ -52,14 +52,14 @@ function setVariableOrParameterType(node: ts.Node, v: Variable | undefined) { } } -function setClassOrFunctionType(node: ts.Node, v: Variable | undefined) { +function setClassOrFunctionType(node: ts.Node, v: Variable | undefined): void { if (v) { let typeIndex = TypeRecorder.getInstance().tryGetTypeIndex(ts.getOriginalNode(node)); v.setTypeIndex(typeIndex); } } -function setTypeIndex(node: ts.Node, v: Variable | undefined, isClassOrFunction: boolean) { +function setTypeIndex(node: ts.Node, v: Variable | undefined, isClassOrFunction: boolean): void { if (isClassOrFunction) { setClassOrFunctionType(node, v); } else { @@ -72,7 +72,7 @@ function addInnerArgs(node: ts.Node, scope: VariableScope, enableTypeRecord: boo scope.addParameter(MandatoryFuncObj, VarDeclarationKind.CONST, -1); // the second argument for newTarget - if (node.kind == ts.SyntaxKind.ArrowFunction) { + if (node.kind === ts.SyntaxKind.ArrowFunction) { scope.addParameter("0newTarget", VarDeclarationKind.CONST, -1); scope.addParameter("0this", VarDeclarationKind.CONST, 0); } else { @@ -107,7 +107,7 @@ function addInnerArgs(node: ts.Node, scope: VariableScope, enableTypeRecord: boo } } -export function addVariableToScope(recorder: Recorder, enableTypeRecord: boolean) { +export function addVariableToScope(recorder: Recorder, enableTypeRecord: boolean): void { let scopeMap = recorder.getScopeMap(); let hoistMap = recorder.getHoistMap(); @@ -210,7 +210,7 @@ function addParameters(node: ts.FunctionLikeDeclaration, scope: VariableScope, e } } -function addPatternParamterElements(pattern: ts.BindingPattern, scope: VariableScope) { +function addPatternParamterElements(pattern: ts.BindingPattern, scope: VariableScope): void { let name: string = ''; pattern.elements.forEach(bindingElement => { if (ts.isOmittedExpression(bindingElement)) { diff --git a/ts2panda/src/assemblyDumper.ts b/ts2panda/src/assemblyDumper.ts index 6b2fc9d7932499c3f87709cea21d47a4de824f3f..88ad92d34a51b4f1a754b5e783fd89cd1203a97e 100644 --- a/ts2panda/src/assemblyDumper.ts +++ b/ts2panda/src/assemblyDumper.ts @@ -41,7 +41,7 @@ export class IntrinsicInfo { } export class AssemblyDumper { - private labels: Map // Label.id : Label string name + private labels: Map; // Label.id : Label string name private labelId: number; private pg: PandaGen; readonly labelPrefix = "LABEL_"; @@ -62,7 +62,7 @@ export class AssemblyDumper { writeFunctionHeader(): void { let parametersCount = this.pg.getParametersCount(); - this.output += ".function any " + this.pg.internalName + "(" + this.output += ".function any " + this.pg.internalName + "("; for (let i = 0; i < parametersCount; ++i) { this.output += "any a" + i.toString(); if (i !== parametersCount - 1) { @@ -96,31 +96,31 @@ export class AssemblyDumper { continue; } - this.output += "\t" + this.output += "\t"; this.output += node.getMnemonic() + " "; let operands = node.operands; let formats = node.getFormats(); - var outputRangeVregNum = getRangeExplicitVregNums(node); + let outputRangeVregNum = getRangeExplicitVregNums(node); for (let j = 0; j < operands.length; ++j) { - if (outputRangeVregNum == 0) { + if (outputRangeVregNum === 0) { break; } let format = formats[0]; let kind = format[j][0]; let op = operands[j]; - if (kind == OperandKind.Imm) { + if (kind === OperandKind.Imm) { let imm = op; this.output += imm.value.toString(); - } else if (kind == OperandKind.Id) { + } else if (kind === OperandKind.Id) { this.output += op; - } else if (kind == OperandKind.StringId) { + } else if (kind === OperandKind.StringId) { let escapedOp = op.toString().replace(/\\/g, "\\\\").replace(/\t/g, "\\t") .replace(/\n/g, "\\n").replace(/\"/g, "\\\"") this.output += "\"" + escapedOp + "\""; - } else if (kind == OperandKind.DstVReg - || kind == OperandKind.SrcDstVReg - || kind == OperandKind.SrcVReg) { + } else if (kind === OperandKind.DstVReg || + kind === OperandKind.SrcDstVReg || + kind === OperandKind.SrcVReg) { let v = op; if (v.num < 0) { throw Error("invalid register, please check your insn!\n"); @@ -131,7 +131,7 @@ export class AssemblyDumper { outputRangeVregNum--; continue; } - } else if (kind == OperandKind.Label) { + } else if (kind === OperandKind.Label) { this.output += this.getLabelName(