From 66311f48bfcefd36d9d61bc2db8981d5e38eda01 Mon Sep 17 00:00:00 2001 From: nthnn Date: Thu, 17 Aug 2023 20:44:52 +0800 Subject: [PATCH] Code reviews and fixes. --- src/ast.ts | 12 ++++--- src/ast_expr.ts | 50 ++++++++++++++++++++------- src/ast_stmt.ts | 41 ++++++++++++++++++---- src/data_type.ts | 47 +++++++++++++------------ src/llvm_context.ts | 3 +- src/token.ts | 8 +++-- src/token_defs.ts | 13 +++++-- src/token_types.ts | 6 ++-- src/tokenizer.ts | 79 ++++++++++++++++++++++++++++--------------- src/tokenizer_util.ts | 54 ++++++++++++++++------------- src/util.ts | 19 +++++++---- src/yttria.ts | 67 +++++++++++++++++++++++------------- src/yttria_runtime.ts | 25 +++++++++----- 13 files changed, 282 insertions(+), 142 deletions(-) diff --git a/src/ast.ts b/src/ast.ts index cb90471..d9172d3 100644 --- a/src/ast.ts +++ b/src/ast.ts @@ -1,5 +1,4 @@ import { - BasicBlock, Constant, IRBuilder, Module @@ -14,14 +13,18 @@ interface ASTResolveResults { } abstract class ASTNode { - public abstract resolve(results: ASTResolveResults): void; + public abstract resolve( + results: ASTResolveResults + ): void; + public abstract marker(): Token; } abstract class ExpressionAST extends ASTNode { public abstract visit( builder: IRBuilder, - module: Module): Constant; + module: Module + ): Constant; public abstract type(): DataType; } @@ -29,7 +32,8 @@ abstract class ExpressionAST extends ASTNode { abstract class StatementAST extends ASTNode { public abstract visit( builder: IRBuilder, - module: Module): void; + module: Module + ): void; } export { diff --git a/src/ast_expr.ts b/src/ast_expr.ts index 211583e..de586ba 100644 --- a/src/ast_expr.ts +++ b/src/ast_expr.ts @@ -1,5 +1,4 @@ import { - BasicBlock, Constant, ConstantFP, ConstantInt, @@ -21,7 +20,10 @@ class ExprASTBool implements ExpressionAST { private value: boolean; public mark: Token; - public constructor(mark: Token, value: boolean) { + public constructor( + mark: Token, + value: boolean + ) { this.mark = mark; this.value = value; } @@ -30,6 +32,7 @@ class ExprASTBool implements ExpressionAST { builder: IRBuilder, module: Module ): Constant { + return ConstantInt.get( Type.getIntNTy(LLVMGlobalContext, 1), this.value ? 1 : 0, @@ -41,7 +44,9 @@ class ExprASTBool implements ExpressionAST { return DataType.BOOL; } - public resolve(results: ASTResolveResults): void { } + public resolve( + results: ASTResolveResults + ): void { } public marker(): Token { return this.mark; @@ -52,7 +57,10 @@ class ExprASTString implements ExpressionAST { private value: string; private mark: Token; - public constructor(mark: Token, value: string) { + public constructor( + mark: Token, + value: string + ) { this.mark = mark; this.value = value; } @@ -61,11 +69,11 @@ class ExprASTString implements ExpressionAST { builder: IRBuilder, module: Module ): Constant { + return builder.CreateGlobalStringPtr( this.value, YttriaUtil.generateHash(this.value), - 0, - module + 0, module ); } @@ -73,7 +81,9 @@ class ExprASTString implements ExpressionAST { return DataType.STRING; } - public resolve(results: ASTResolveResults): void { } + public resolve( + results: ASTResolveResults + ): void { } public marker(): Token { return this.mark; @@ -85,7 +95,11 @@ class ExprASTInt implements ExpressionAST { private bit: number; private mark: Token; - public constructor(mark: Token, value: BigInt, bit: number) { + public constructor( + mark: Token, + value: BigInt, + bit: number + ) { this.mark = mark; this.value = value; this.bit = bit; @@ -95,6 +109,7 @@ class ExprASTInt implements ExpressionAST { builder: IRBuilder, module: Module ): Constant { + return ConstantInt.get( LLVMDataType.getIntType(this.bit), Number(this.value), @@ -112,15 +127,18 @@ class ExprASTInt implements ExpressionAST { type: string, results: ASTResolveResults ): void { + if(this.value < min) results.errors.set( this.marker(), - 'Underflow value for ' + type + ' type: ' + this.value.toString() + 'Underflow value for ' + type + + ' type: ' + this.value.toString() ); else if(this.value > max) results.errors.set( this.marker(), - 'Overflow value for ' + type + ' type: ' + this.value.toString() + 'Overflow value for ' + type + + ' type: ' + this.value.toString() ); } @@ -179,7 +197,11 @@ class ExprASTFloat implements ExpressionAST { private bit: number; private mark: Token; - public constructor(mark: Token, value: number, bit: number) { + public constructor( + mark: Token, + value: number, + bit: number + ) { this.mark = mark; this.value = value; this.bit = bit; @@ -189,6 +211,7 @@ class ExprASTFloat implements ExpressionAST { builder: IRBuilder, module: Module ): Constant { + return ConstantFP.get( this.type().getLLVMType(), this.value @@ -214,8 +237,8 @@ class ExprASTUnary implements ExpressionAST { public constructor( mark: Token, operator: - string, expr: ExpressionAST) { - + string, expr: ExpressionAST + ) { this.mark = mark; this.operator = operator; this.expr = expr; @@ -225,6 +248,7 @@ class ExprASTUnary implements ExpressionAST { builder: IRBuilder, module: Module ): Constant { + const visited: Constant = this.expr.visit(builder, module); diff --git a/src/ast_stmt.ts b/src/ast_stmt.ts index ad8fd44..ccf514f 100644 --- a/src/ast_stmt.ts +++ b/src/ast_stmt.ts @@ -1,5 +1,19 @@ -import { IRBuilder, Function, Module, BasicBlock, Constant, FunctionType, ConstantInt } from "llvm-bindings"; -import { ASTResolveResults, ExpressionAST, StatementAST } from "./ast"; +import { + IRBuilder, + Function, + Module, + BasicBlock, + Constant, + FunctionType, + ConstantInt +} from "llvm-bindings"; + +import { + ASTResolveResults, + ExpressionAST, + StatementAST +} from "./ast"; + import { Token } from "./token"; import { DataType } from "./data_type"; import { ExprASTString } from "./ast_expr"; @@ -11,7 +25,10 @@ class StmtASTMain implements StatementAST { private mark: Token; private body: StatementAST; - public constructor(mark: Token, body: StatementAST) { + public constructor( + mark: Token, + body: StatementAST + ) { this.mark = mark; this.body = body; } @@ -20,6 +37,7 @@ class StmtASTMain implements StatementAST { builder: IRBuilder, module: Module ): void { + const main: BasicBlock = BasicBlock.Create( LLVMGlobalContext, 'entry', @@ -43,8 +61,9 @@ class StmtASTMain implements StatementAST { ); } - public resolve(results: ASTResolveResults): void { - } + public resolve( + results: ASTResolveResults + ): void { } public marker(): Token { return this.mark; @@ -55,7 +74,10 @@ class StmtASTRender implements StatementAST { private mark: Token; private expr: ExpressionAST; - public constructor(mark: Token, expr: ExpressionAST) { + public constructor( + mark: Token, + expr: ExpressionAST + ) { this.mark = mark; this.expr = expr; } @@ -66,10 +88,12 @@ class StmtASTRender implements StatementAST { ): void { let formatter: string = ""; let formatted: Constant = this.expr.visit(builder, module); + const dataType: DataType = this.expr.type(); if(DataType.isOfIntType(dataType) || dataType == DataType.BOOL) { + if(dataType == DataType.I64) formatter = '%llu'; else formatter = '%d'; @@ -98,4 +122,7 @@ class StmtASTRender implements StatementAST { } } -export { StmtASTMain, StmtASTRender }; \ No newline at end of file +export { + StmtASTMain, + StmtASTRender +}; \ No newline at end of file diff --git a/src/data_type.ts b/src/data_type.ts index fafa103..febdecb 100644 --- a/src/data_type.ts +++ b/src/data_type.ts @@ -6,7 +6,11 @@ class DataType { private bit: number; private llvmType: Type; - public constructor(name: string, bit: number, llvmType: Type | undefined) { + public constructor( + name: string, + bit: number, + llvmType: Type | undefined + ) { this.name = name; this.bit = bit; this.llvmType = llvmType as Type; @@ -47,7 +51,9 @@ class DataType { public static F64: DataType = new DataType("f64", 64, Type.getDoubleTy(LLVMGlobalContext)); - public static isOfIntType(type: DataType): boolean { + public static isOfIntType( + type: DataType + ): boolean { switch(type) { case DataType.I4: case DataType.I8: @@ -60,14 +66,11 @@ class DataType { return false; } - public static isOfFloatType(type: DataType): boolean { - switch(type) { - case DataType.F32: - case DataType.F64: - return true; - } - - return false; + public static isOfFloatType( + type: DataType + ): boolean { + return type == DataType.F32 || + type == DataType.F64; } } @@ -87,22 +90,21 @@ class LLVMDataType { [64, [Type.getInt64Ty(LLVMGlobalContext),DataType.I64]], ]); - public static getFloatType(bit: number): Type { + public static getFloatType( + bit: number + ): Type { if(LLVMDataType.floatTypeMap.has(bit)) return LLVMDataType.floatTypeMap.get(bit)![0]; return Type.getFloatTy(LLVMGlobalContext); } - public static getFloatDataType(bit: number): DataType { - switch(bit) { - case 32: - return DataType.F32; - case 64: - return DataType.F64; - } + public static getFloatDataType( + bit: number + ): DataType { - return DataType.UNKNOWN; + return bit == 32 ? + DataType.F32 : DataType.F64; } public static getIntType(bit: number): Type { @@ -126,8 +128,11 @@ class LLVMDataType { return DataType.I64; } - return DataType.UNKNOWN + return DataType.UNKNOWN; } } -export { DataType, LLVMDataType }; \ No newline at end of file +export { + DataType, + LLVMDataType +}; \ No newline at end of file diff --git a/src/llvm_context.ts b/src/llvm_context.ts index 5ca546d..6d1da33 100644 --- a/src/llvm_context.ts +++ b/src/llvm_context.ts @@ -1,5 +1,6 @@ import { LLVMContext } from "llvm-bindings" -const LLVMGlobalContext: LLVMContext = new LLVMContext(); +const LLVMGlobalContext: LLVMContext = + new LLVMContext(); export default LLVMGlobalContext; \ No newline at end of file diff --git a/src/token.ts b/src/token.ts index 6de737c..7f3e036 100644 --- a/src/token.ts +++ b/src/token.ts @@ -1,4 +1,4 @@ -import TokenType from "./token_types"; +import { TokenType } from "./token_types"; interface Token { image: string; @@ -16,6 +16,7 @@ class TokenUtil { line: number, type: TokenType ): Token { + return { filename: filename, image: image, @@ -33,4 +34,7 @@ class TokenUtil { } } -export { Token, TokenUtil }; \ No newline at end of file +export { + Token, + TokenUtil +}; \ No newline at end of file diff --git a/src/token_defs.ts b/src/token_defs.ts index 1f19b46..a980af9 100644 --- a/src/token_defs.ts +++ b/src/token_defs.ts @@ -1,6 +1,10 @@ const TokenImages: Array = [ - 'true', 'false', 'nil', - 'sub', 'main', 'return' + 'i4', 'i8', 'i16', 'i32', 'i64', + 'f32', 'f64', 'bool', 'string', + + 'true', 'false', 'nil', 'nan', + 'sub', 'main', 'render', + 'return' ]; const TokenOperators: Array = [ @@ -11,4 +15,7 @@ const TokenOperators: Array = [ '<=', '>', '>=', '>>', '?', ';' ]; -export { TokenImages, TokenOperators }; \ No newline at end of file +export { + TokenImages, + TokenOperators +}; \ No newline at end of file diff --git a/src/token_types.ts b/src/token_types.ts index 66acbc4..b47b1ec 100644 --- a/src/token_types.ts +++ b/src/token_types.ts @@ -1,9 +1,7 @@ -enum TokenType { +export enum TokenType { TOKEN_IDENTIFIER, TOKEN_KEYWORD, TOKEN_DIGIT, TOKEN_STRING, TOKEN_OPERATOR -} - -export default TokenType; \ No newline at end of file +} \ No newline at end of file diff --git a/src/tokenizer.ts b/src/tokenizer.ts index b58b31c..7253fa6 100644 --- a/src/tokenizer.ts +++ b/src/tokenizer.ts @@ -1,6 +1,9 @@ -import { Token, TokenUtil } from './token'; +import { + Token, + TokenUtil +} from './token'; +import { TokenType } from './token_types'; -import TokenType from './token_types'; import TokenizerUtil from './tokenizer_util'; interface TokenizerError { @@ -27,15 +30,19 @@ class Tokenizer { tokens: [] }; - public constructor(_filename: string, _source: string) { - this.filename = _filename; - this.source = _source; + public constructor( + filename: string, + source: string + ) { + this.filename = filename; + this.source = source; console.log(`Initialized tokenizer for ${this.filename}`); } private current(): string { - return this.source.charAt(this.pos); + return this.source + .charAt(this.pos); } private advance(): void { @@ -43,7 +50,8 @@ class Tokenizer { } private consume(): string { - let char: string = this.current(); + let char: string = + this.current(); this.advance(); this.column++; @@ -55,7 +63,11 @@ class Tokenizer { return this.pos == this.source.length; } - private pushToken(image: string, type: TokenType): void { + private pushToken( + image: string, + type: TokenType + ): void { + this.results.tokens.push( TokenUtil.newToken( this.filename, @@ -80,12 +92,15 @@ class Tokenizer { private consumeByValidator( validator: (_: string)=> boolean, validatorName: string, - callback: ()=> void): void { + callback: ()=> void + ): void { while(!this.isAtEnd()) if(validator(this.current())) callback(); - else if(TokenizerUtil.isWhitespace(this.current())) + else if(TokenizerUtil.isWhitespace( + this.current() + )) break; else { if(validator == TokenizerUtil.isDigit && @@ -160,7 +175,8 @@ class Tokenizer { } private consumeNumber(): void { - var image: string = this.consume(); + var image: string = + this.consume(); if(image == '0') { if(this.current() == 'b') @@ -173,7 +189,10 @@ class Tokenizer { } else image += this.consumeDigit(); - this.pushToken(image, TokenType.TOKEN_DIGIT); + this.pushToken( + image, + TokenType.TOKEN_DIGIT + ); } private consumeComment(): void { @@ -183,16 +202,18 @@ class Tokenizer { } private consumeIdentifier(): void { - var image: string = this.consume(); + var image: string = + this.consume(); while(!this.isAtEnd() && (TokenizerUtil.isIdentifier(this.current()) || TokenizerUtil.isDigit(this.current()))) image += this.consume(); - this.pushToken(image, TokenizerUtil.isKeyword(image) ? - TokenType.TOKEN_KEYWORD : - TokenType.TOKEN_IDENTIFIER + this.pushToken(image, + TokenizerUtil.isKeyword(image) ? + TokenType.TOKEN_KEYWORD : + TokenType.TOKEN_IDENTIFIER ); } @@ -209,7 +230,8 @@ class Tokenizer { this.results.errors.push({ message: "Unclosed literal encountered.", line: this.line, - column: (this.column - stringContent.length) - 1 + column: (this.column - + stringContent.length) - 1 }); this.consume(); @@ -221,7 +243,8 @@ class Tokenizer { this.results.errors.push({ message: "Expecting escape character" + "sequence, encountered EOF.", - column: (this.column - stringContent.length) - 1, + column: (this.column - + stringContent.length) - 1, line: this.line }); break; @@ -238,7 +261,8 @@ class Tokenizer { this.results.errors.push({ message: "Invalid character escape sequence: " + this.consume(), - column: (this.column - stringContent.length) - 1, + column: (this.column - + stringContent.length) - 1, line: this.line }); break; @@ -249,11 +273,9 @@ class Tokenizer { this.results.tokens.push( TokenUtil.newToken( - this.filename, - stringContent, + this.filename, stringContent, (this.column - stringContent.length) - 2, - this.line, - TokenType.TOKEN_STRING + this.line, TokenType.TOKEN_STRING ) ); } @@ -267,8 +289,7 @@ class Tokenizer { this.results.tokens.push( TokenUtil.newToken( - this.filename, - image, + this.filename, image, this.column - image.length, this.line, TokenType.TOKEN_OPERATOR @@ -295,7 +316,8 @@ class Tokenizer { else if(TokenizerUtil.isIdentifier(this.current())) this.consumeIdentifier(); else this.results.errors.push({ - message: `Unidentified '${this.consume()}' character encountered.`, + message: 'Unidentified ' + this.consume() + + ' character encountered.', column: this.column, line: this.line }); @@ -305,4 +327,7 @@ class Tokenizer { } } -export { Tokenizer, TokenizerResult }; \ No newline at end of file +export { + Tokenizer, + TokenizerResult +}; \ No newline at end of file diff --git a/src/tokenizer_util.ts b/src/tokenizer_util.ts index 2d60367..0f64dfa 100644 --- a/src/tokenizer_util.ts +++ b/src/tokenizer_util.ts @@ -1,45 +1,53 @@ import { TokenImages, TokenOperators } from "./token_defs"; -class TokenizerUtil { - public static isWhitespace(char: string): boolean { - switch(char) { - case ' ': - case '\n': - case '\r': - case '\t': - return true; - } - - return false; - } - - public static isDigit(char: string): boolean { +export default class TokenizerUtil { + public static isWhitespace( + char: string + ): boolean { + return [ + ' ', '\n', '\r', '\t' + ].includes(char); + } + + public static isDigit( + char: string + ): boolean { return /^[0-9]+$/.test(char); } - public static isBinary(char: string): boolean { + public static isBinary( + char: string + ): boolean { return char == '0' || char == '1'; } - public static isOctadecimal(char: string): boolean { + public static isOctadecimal( + char: string + ): boolean { return /^[0-7]+$/.test(char); } - public static isHexadecimal(char: string): boolean { + public static isHexadecimal( + char: string + ): boolean { return /^[0-9A-Fa-f]+$/.test(char); } - public static isIdentifier(char: string): boolean { + public static isIdentifier( + char: string + ): boolean { return /^[a-zA-Z]+$/.test(char); } - public static isKeyword(image: string): boolean { + public static isKeyword( + image: string + ): boolean { return TokenImages.indexOf(image) != -1; } - public static isOperator(image: string): boolean { + public static isOperator( + image: string + ): boolean { return TokenOperators.indexOf(image) != -1; } -} - -export default TokenizerUtil; \ No newline at end of file +} \ No newline at end of file diff --git a/src/util.ts b/src/util.ts index 28524af..8810eea 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,15 +1,22 @@ -import { createHash, randomUUID } from "crypto"; +import { + createHash, + randomUUID +} from "crypto"; export default class YttriaUtil { public static generateRandomHash(): string { return '__' + randomUUID() - .replace('-', '').substring(0, 12); + .replace('-', '') + .substring(0, 12); } - public static generateHash(base: string): string { + public static generateHash( + base: string + ): string { + return '__' + createHash('md5') - .update(base) - .digest('hex') - .substring(0, 10); + .update(base) + .digest('hex') + .substring(0, 10); } } \ No newline at end of file diff --git a/src/yttria.ts b/src/yttria.ts index 36499fa..2782335 100644 --- a/src/yttria.ts +++ b/src/yttria.ts @@ -1,22 +1,38 @@ import { - BasicBlock, IRBuilder, Module, verifyModule } from 'llvm-bindings'; -import { Token, TokenUtil } from './token'; -import { Tokenizer, TokenizerResult } from './tokenizer'; -import { ExprASTBool, ExprASTFloat, ExprASTInt, ExprASTString, ExprASTUnary } from './ast_expr'; +import { + Token, + TokenUtil +} from './token'; + +import { + Tokenizer, + TokenizerResult +} from './tokenizer'; + +import { + ExprASTBool, + ExprASTFloat, + ExprASTInt, + ExprASTString, + ExprASTUnary +} from './ast_expr'; + +import { + StmtASTMain, + StmtASTRender +} from './ast_stmt'; + import { hideBin } from 'yargs/helpers'; import colors from 'colors'; import LLVMGlobalContext from './llvm_context'; -import YttriaRuntime from './yttria_runtime'; import yargs from 'yargs'; import YttriaUtil from './util'; -import { ASTNode, ExpressionAST } from './ast'; -import { StmtASTMain, StmtASTRender } from './ast_stmt'; function tokenizerTest() { var tokenizer = new Tokenizer( @@ -68,24 +84,27 @@ function printBanner(args: any) { console.log('│ │'); // Here comes the wizardry. - console.log('│' + ' ▀▀▌' + '───────'.gray + '▐▀▀' + ' │'); - console.log('│' + ' ▄▀' + '░'.blue + '◌'.bold + '░░░░░░░'.blue + '▀▄' + ' ┓┏ •'.cyan.bold + ' │'); - console.log('│' + ' ▐' + '░░'.blue + '◌'.bold + '░'.blue + '▄▀██▄█' + '░░░'.blue + '▌' + ' ┗┫ ╋ ╋ ┏┓ ┓ ┏┓'.cyan.bold + ' │'); - console.log('│' + ' ▐' + '░░░'.blue + '▀████▀▄' + '░░░'.blue + '▌' + ' ┗┛ ┗ ┗ ┛ ┗ ┗┻'.cyan.bold + ' │'); - console.log('│' + ' ▐' + '░░░░░░░░░░░░░'.blue + '▌ ' + 'Programming Language'.bgRed + ' │'); - console.log('│' + ' ▀▄▄▄▄▄▄▄▄▄▄▄▀' + ' v0.0.1'.yellow.bold + ' │'); - console.log('│ │'); + console.log( + '│' + ' ▀▀▌' + '───────'.gray + '▐▀▀' + ' │\n' + + '│' + ' ▄▀' + '░'.blue + '◌'.bold + '░░░░░░░'.blue + '▀▄' + ' ┓┏ •'.cyan.bold + ' │\n' + + '│' + ' ▐' + '░░'.blue + '◌'.bold + '░'.blue + '▄▀██▄█' + '░░░'.blue + '▌' + ' ┗┫ ╋ ╋ ┏┓ ┓ ┏┓'.cyan.bold + ' │\n' + + '│' + ' ▐' + '░░░'.blue + '▀████▀▄' + '░░░'.blue + '▌' + ' ┗┛ ┗ ┗ ┛ ┗ ┗┻'.cyan.bold + ' │\n' + + '│' + ' ▐' + '░░░░░░░░░░░░░'.blue + '▌ ' + 'Programming Language'.bgRed + ' │\n' + + '│' + ' ▀▄▄▄▄▄▄▄▄▄▄▄▀' + ' v0.0.1'.yellow.bold + ' │\n' + + '│ │' + ); if(args.help || args.h || args._.length == 0) { - console.log('├──────────────────────────────────────┤'); - console.log('│ Use ' + '-h'.italic + ' to print help screen. │'); - console.log('│ │'); - console.log('│ For more details, visit: │'); - console.log('│ ' + 'https://nthnn.github.io/yttria-lang'.underline + ' │'); - console.log('└──────────────────────────────────────┘'); - console.log(); + console.log( + '├──────────────────────────────────────┤\n' + + '│ Use ' + '-h'.italic + ' to print help screen. │\n' + + '│ │\n' + + '│ For more details, visit: │\n' + + '│ ' + 'https://nthnn.github.io/yttria-lang'.underline + ' │\n' + + '└──────────────────────────────────────┘\n' + ); } else console.log('└──────────────────────────────────────┘\n'); } @@ -101,8 +120,10 @@ function main(): void { .argv; colors.enable(); - //printBanner(args); - llvmTest(); + printBanner(args); + + //llvmTest(); + //tokenizerTest(); } main(); \ No newline at end of file diff --git a/src/yttria_runtime.ts b/src/yttria_runtime.ts index 784bfb4..41d80d2 100644 --- a/src/yttria_runtime.ts +++ b/src/yttria_runtime.ts @@ -1,9 +1,7 @@ import { - BasicBlock, Function, FunctionType, GlobalValue, - IRBuilder, Module, Type } from "llvm-bindings"; @@ -12,7 +10,9 @@ import { DataType } from "./data_type"; import LLVMGlobalContext from "./llvm_context"; export default class YttriaRuntime { - public static render(module: Module): Function { + public static render( + module: Module + ): Function { return Function.Create( FunctionType.get( Type.getInt32Ty(LLVMGlobalContext), @@ -25,7 +25,10 @@ export default class YttriaRuntime { ); } - public static iabs(module: Module, type: Type): Function { + public static iabs( + module: Module, + type: Type + ): Function { return Function.Create( FunctionType.get(type, [type], false), GlobalValue.LinkageTypes.ExternalLinkage, @@ -34,14 +37,20 @@ export default class YttriaRuntime { ); } - public static fpabs(module: Module, type: DataType): Function { + public static fpabs( + module: Module, + type: DataType + ): Function { const llvmType: Type = type.getLLVMType(); return Function.Create( - FunctionType.get(llvmType, [llvmType], false), + FunctionType.get( + llvmType, + [llvmType], + false + ), GlobalValue.LinkageTypes.ExternalLinkage, - 'fabs', - module + 'fabs', module ); } } \ No newline at end of file