-
Notifications
You must be signed in to change notification settings - Fork 0
/
basegl-loader.js
38 lines (32 loc) · 930 Bytes
/
basegl-loader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
jsnext = require('@luna-lang/jsnext')
var math = 'basegl.Math'
var operatorMap = {
'==' : `${math}.eq`,
'===' : `${math}.eq`,
'!=' : `${math}.neq`,
'!==' : `${math}.neq`,
'<' : `${math}.lt`,
'<=' : `${math}.lte`,
'>' : `${math}.gt`,
'>=' : `${math}.gte`,
'<<' : `${math}.lshift`,
'>>' : `${math}.rshift`,
'>>>' : `${math}.rshift2`,
'+' : `${math}.add`,
'-' : `${math}.sub`,
'*' : `${math}.mul`,
'/' : `${math}.div`,
'%' : `${math}.mod`,
'||' : `${math}.or`,
'&&' : `${math}.and`
}
var jsnextRules = {
'basegl.math': [ jsnext.overloadOperators((n) => operatorMap[n])
, jsnext.replaceQualifiedAccessors('Math', math)
]
}
module.exports = function(source) {
this.value = source;
out = jsnext.preprocessModule('unknown.js', jsnextRules, source, {library: 'basegl', call: 'expr', defaultExts: ['basegl.math']});
return out;
}