UNPKG

roblox-ts

Version:

<div align="center"><img width=25% src="https://i.imgur.com/yCjHmng.png"></div> <h1 align="center"><a href="https://roblox-ts.github.io/">roblox-ts</a></h1> <div align="center">A TypeScript-to-Lua Compiler for Roblox</div> <br> <div align="center"> <a hr

46 lines 1.45 kB
"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const ts = __importStar(require("ts-morph")); const _1 = require("."); function compileBooleanLiteral(state, node) { return node.getLiteralValue() === true ? "true" : "false"; } exports.compileBooleanLiteral = compileBooleanLiteral; const SPECIAL_NUMBER_PREFIXES = [ "b", "o", "x", ]; function isSpecialNumberPrefix(numText) { for (const prefix of SPECIAL_NUMBER_PREFIXES) { if (numText.startsWith(`0${prefix}`)) { return true; } } return false; } function compileNumericLiteral(state, node) { const text = node.getText(); if (isSpecialNumberPrefix(text)) { return node.getLiteralText(); } return text.replace(/_/g, ""); } exports.compileNumericLiteral = compileNumericLiteral; function compileStringLiteral(state, node) { if (ts.TypeGuards.isNoSubstitutionTemplateLiteral(node)) { return '"' + _1.sanitizeTemplate(node.getText().slice(1, -1)) + '"'; } else { return node.getText(); } } exports.compileStringLiteral = compileStringLiteral; //# sourceMappingURL=literal.js.map