From b6c8c496615af547e366eff6c31b1d764adbbd30 Mon Sep 17 00:00:00 2001 From: Christian Schmitz Date: Mon, 19 Aug 2024 09:51:53 -0600 Subject: [PATCH] - compiler-utils lib upgrade - Cip68 tag parsing in parseDataFields bug fix --- package-lock.json | 18 +++++++++--------- package.json | 4 ++-- src/parse/parseDataFields.js | 6 +++++- src/program/multi.test.js | 23 +++++++++++++++++++++++ src/program/version.js | 2 +- src/statements/DataDefinition.js | 10 +++++----- 6 files changed, 45 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index e831b82b..be2c9ccf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "@helios-lang/compiler", - "version": "0.17.0-43", + "version": "0.17.0-44", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@helios-lang/compiler", - "version": "0.17.0-43", + "version": "0.17.0-44", "license": "BSD-3-Clause", "dependencies": { "@helios-lang/codec-utils": "^0.1.32", - "@helios-lang/compiler-utils": "^0.1.53", + "@helios-lang/compiler-utils": "^0.1.54", "@helios-lang/ir": "^0.1.26", "@helios-lang/type-utils": "^0.1.21", "@helios-lang/uplc": "^0.1.35" @@ -36,9 +36,9 @@ "integrity": "sha512-aheriFzYcWSn8B9AndryOeeiBftVKI+RgmkB2J1n12LpB2ePqtIvvJuau72VEPyZGZVuXjxuBaKbbhdDRbWhxg==" }, "node_modules/@helios-lang/compiler-utils": { - "version": "0.1.53", - "resolved": "https://registry.npmjs.org/@helios-lang/compiler-utils/-/compiler-utils-0.1.53.tgz", - "integrity": "sha512-aBEjwpKcGvYjRVZs6sYOiY84CfuLRbdFkGqDl8/KANyTrWaxEvWR1ltxmuFcLLZg88KT/CWstXEBahAJjz/x2g==", + "version": "0.1.54", + "resolved": "https://registry.npmjs.org/@helios-lang/compiler-utils/-/compiler-utils-0.1.54.tgz", + "integrity": "sha512-Yco1TszlczuEfrDuaFRbjSYcNglROJ8vaWI0/LPlUSOM7jdh9/5fRT/jmXGXClCsdUKM7uissb1qHNk/EB2vww==", "dependencies": { "@helios-lang/codec-utils": "^0.1.30", "@helios-lang/type-utils": "^0.1.18" @@ -140,9 +140,9 @@ "integrity": "sha512-aheriFzYcWSn8B9AndryOeeiBftVKI+RgmkB2J1n12LpB2ePqtIvvJuau72VEPyZGZVuXjxuBaKbbhdDRbWhxg==" }, "@helios-lang/compiler-utils": { - "version": "0.1.53", - "resolved": "https://registry.npmjs.org/@helios-lang/compiler-utils/-/compiler-utils-0.1.53.tgz", - "integrity": "sha512-aBEjwpKcGvYjRVZs6sYOiY84CfuLRbdFkGqDl8/KANyTrWaxEvWR1ltxmuFcLLZg88KT/CWstXEBahAJjz/x2g==", + "version": "0.1.54", + "resolved": "https://registry.npmjs.org/@helios-lang/compiler-utils/-/compiler-utils-0.1.54.tgz", + "integrity": "sha512-Yco1TszlczuEfrDuaFRbjSYcNglROJ8vaWI0/LPlUSOM7jdh9/5fRT/jmXGXClCsdUKM7uissb1qHNk/EB2vww==", "requires": { "@helios-lang/codec-utils": "^0.1.30", "@helios-lang/type-utils": "^0.1.18" diff --git a/package.json b/package.json index a4d78665..cfea2ed8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@helios-lang/compiler", - "version": "0.17.0-44", + "version": "0.17.0-45", "description": "Helios is a Domain Specific Language that compiles to Plutus-Core (i.e. Cardano on-chain validator scripts). Helios is a non-Haskell alternative to Plutus. With this library you can compile Helios scripts and build Cardano transactions, all you need to build 100% client-side dApps for Cardano.", "main": "src/index.js", "types": "types/index.d.ts", @@ -52,7 +52,7 @@ }, "dependencies": { "@helios-lang/codec-utils": "^0.1.32", - "@helios-lang/compiler-utils": "^0.1.53", + "@helios-lang/compiler-utils": "^0.1.54", "@helios-lang/ir": "^0.1.26", "@helios-lang/type-utils": "^0.1.21", "@helios-lang/uplc": "^0.1.35" diff --git a/src/parse/parseDataFields.js b/src/parse/parseDataFields.js index 7b1da660..ec475f65 100644 --- a/src/parse/parseDataFields.js +++ b/src/parse/parseDataFields.js @@ -1,5 +1,6 @@ import { StringLiteral, + TokenReader, Word, strlit, symbol @@ -89,6 +90,9 @@ export function parseDataFields(ctx, allowTags = false) { let typeReader = r.readUntil(anyName, symbol(":")) if ((m = typeReader.findLastMatch(strlit()))) { + /** + * @satisfies {[TokenReader, StringLiteral]} + */ const [before, tag] = m typeReader.end() typeReader = before @@ -99,7 +103,7 @@ export function parseDataFields(ctx, allowTags = false) { assertUniqueTag(tag.site, tag.value) } - tags.set(name.value, tag.value) + tags.set(name.value, tag) } else { r.endMatch(false) diff --git a/src/program/multi.test.js b/src/program/multi.test.js index 408b41d9..88ec7290 100644 --- a/src/program/multi.test.js +++ b/src/program/multi.test.js @@ -111,4 +111,27 @@ describe(analyzeMulti.name, () => { true ) }) + + it("detects module function", () => { + const src1 = `spending s + import { ok } from utils + func main(_, _) -> Bool { + ok() + }` + + const src2 = `minting m + func main(_) -> Bool { + true + }` + + const mod = `module utils + + func ok() -> Bool { + true + }` + + const analysis = analyzeMulti([src1, src2], [mod]) + + console.log(analysis.modules) + }) }) diff --git a/src/program/version.js b/src/program/version.js index 24de71bd..132ed4e3 100644 --- a/src/program/version.js +++ b/src/program/version.js @@ -1 +1 @@ -export const VERSION = "0.17.0-44" +export const VERSION = "0.17.0-45" diff --git a/src/statements/DataDefinition.js b/src/statements/DataDefinition.js index 3fddd74d..df1b1a93 100644 --- a/src/statements/DataDefinition.js +++ b/src/statements/DataDefinition.js @@ -232,12 +232,12 @@ export class DataDefinition { fieldsToSchema(parents) { const fieldSchemas = [] - this.fieldNames.forEach((fn, i) => { - const externalName = this.hasTags() ? this.#fields[i].tag : fn - const ts = expectSome(this.getFieldType(i).toSchema(parents)) + this.#fields.forEach((f) => { + const externalName = this.hasTags() ? f.tag : f.name.value + const ts = expectSome(f.type.toSchema(parents)) fieldSchemas.push({ - type: ts, - name: externalName + name: externalName, + type: ts }) })