@sdeverywhere/compile 0.7.14 → 0.7.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdeverywhere/compile",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.16",
|
|
4
4
|
"description": "The core Vensim to C compiler for the SDEverywhere tool suite.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"js-yaml": "^3.13.1",
|
|
15
15
|
"ramda": "^0.27.0",
|
|
16
16
|
"split-string": "^6.0.0",
|
|
17
|
-
"xlsx": "
|
|
17
|
+
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz"
|
|
18
18
|
},
|
|
19
19
|
"author": "Climate Interactive",
|
|
20
20
|
"license": "MIT",
|
package/src/_shared/helpers.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as fs from 'node:fs'
|
|
1
2
|
import util from 'util'
|
|
2
3
|
import B from 'bufx'
|
|
3
4
|
import { parse as parseCsv } from 'csv-parse/sync'
|
|
@@ -23,6 +24,10 @@ let nextAuxVarSeq = 1
|
|
|
23
24
|
// parsed csv data cache
|
|
24
25
|
let csvData = new Map()
|
|
25
26
|
|
|
27
|
+
// Newer versions of the xlsx package require manually setting the `fs` instance
|
|
28
|
+
// before using the `XLSX.readFile` function
|
|
29
|
+
XLSX.set_fs(fs)
|
|
30
|
+
|
|
26
31
|
// XXX: This is needed for tests due to sequence numbers being in module-level storage
|
|
27
32
|
export function resetHelperState() {
|
|
28
33
|
nextTmpVarSeq = 1
|
|
@@ -67,12 +67,12 @@ function generateSmoothLevel(v, context, argInput, argDelay, argInit, levelNumbe
|
|
|
67
67
|
// `equation-reader.js` and modified to work with the AST instead of directly depending
|
|
68
68
|
// on antlr4-vensim constructs. This logic is pretty complex so we should try to refactor
|
|
69
69
|
// or at least add some more fine-grained unit tests for it.
|
|
70
|
-
let subs = context.extractSubscriptsFromVarNames(argInput, argDelay, argInit)
|
|
71
70
|
|
|
72
|
-
//
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
// Preserve the original subscript/dimension names that were passed in. In the case of
|
|
72
|
+
// separated variables, the `subs` array will be replaced to include the separated subscript
|
|
73
|
+
// names, but we still need the original subscript/dimension names.
|
|
74
|
+
const origSubs = context.extractSubscriptsFromVarNames(argInput, argDelay, argInit)
|
|
75
|
+
let subs = origSubs
|
|
76
76
|
|
|
77
77
|
let levelVarBaseName
|
|
78
78
|
let levelLHS
|
|
@@ -129,5 +129,8 @@ function generateSmoothLevel(v, context, argInput, argDelay, argInit, levelNumbe
|
|
|
129
129
|
context.defineVariable(levelEqn)
|
|
130
130
|
context.addVarReference(levelVarRefId)
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
// The name of the level variable returned here includes the original subscript/dimension names
|
|
133
|
+
// (not the separated subscript names) so that the `argInput` is correct for the 2nd and 3rd levels
|
|
134
|
+
const levelVarFullName = `${levelVarBaseName}${origSubs}`
|
|
135
|
+
return [levelVarRefId, levelVarFullName]
|
|
133
136
|
}
|
|
@@ -148,7 +148,7 @@ class Context {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
if (result.size > 1) {
|
|
151
|
-
|
|
151
|
+
throw new Error(`Subscripts do not agree in extractSubscriptsFromVarNames: ${[...varNames]}`)
|
|
152
152
|
}
|
|
153
153
|
return [...result][0] || ''
|
|
154
154
|
}
|