-
Notifications
You must be signed in to change notification settings - Fork 0
/
signed_decimal.go
49 lines (37 loc) · 1.07 KB
/
signed_decimal.go
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
39
40
41
42
43
44
45
46
47
48
49
package main
import (
_ "embed"
"fmt"
)
//go:embed signed_decimal.move.template
var signed_decimal_template string
type signedDecimalInfo struct {
BaseWidth uint
Address string
DoTest bool
Args string
Version string
Precision uint
}
type signedDecimalGenerated struct {
signedDecimalInfo
ModuleName string
TypeName string
BaseTypeName string
SignedIntType string
SignedIntModule string
DoubleWidthModule string
}
func newSignedDecimalGenerated(s *signedDecimalInfo) *signedDecimalGenerated {
r := &signedDecimalGenerated{signedDecimalInfo: *s}
r.ModuleName = fmt.Sprintf("signed_decimal%d_p%d", r.BaseWidth, r.Precision)
r.TypeName = fmt.Sprintf("SDecimal%d", r.BaseWidth)
r.BaseTypeName = fmt.Sprintf("u%d", r.BaseWidth)
r.SignedIntType = getSignedIntType(r.BaseWidth)
r.SignedIntModule = getSignedIntModuleName(r.BaseWidth)
r.DoubleWidthModule = getDoubleWidthModuleName(r.BaseWidth * 2)
return r
}
func (d *signedDecimalGenerated) GenText() (string, error) {
return GenText(d.ModuleName, signed_decimal_template, d)
}