aboutsummaryrefslogtreecommitdiffstats
path: root/prog/prog.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-07-07 20:07:30 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-07-08 22:52:24 +0200
commit306ca0571c5d906ce76df97bd1ea54f4e0e50240 (patch)
treea579718e096c53dc5386f4af2fbabb3318eaf1ed /prog/prog.go
parent93213ec0d3c4522c8844a51b718eb56ce62f395b (diff)
prog, pkg/compiler: support fmt type
fmt type allows to convert intergers and resources to string representation.
Diffstat (limited to 'prog/prog.go')
-rw-r--r--prog/prog.go37
1 files changed, 9 insertions, 28 deletions
diff --git a/prog/prog.go b/prog/prog.go
index 3474950b9..19db1893d 100644
--- a/prog/prog.go
+++ b/prog/prog.go
@@ -47,50 +47,31 @@ func (arg *ConstArg) Size() uint64 {
}
// Value returns value, pid stride and endianness.
-func (arg *ConstArg) Value() (uint64, uint64, bool) {
+func (arg *ConstArg) Value() (uint64, uint64) {
switch typ := (*arg).Type().(type) {
case *IntType:
- return arg.Val, 0, typ.BigEndian
+ return arg.Val, 0
case *ConstType:
- return arg.Val, 0, typ.BigEndian
+ return arg.Val, 0
case *FlagsType:
- return arg.Val, 0, typ.BigEndian
+ return arg.Val, 0
case *LenType:
- return arg.Val, 0, typ.BigEndian
+ return arg.Val, 0
case *CsumType:
// Checksums are computed dynamically in executor.
- return 0, 0, false
+ return 0, 0
case *ResourceType:
- t := typ.Desc.Type.(*IntType)
- return arg.Val, 0, t.BigEndian
+ return arg.Val, 0
case *ProcType:
if arg.Val == typ.Default() {
- return 0, 0, false
+ return 0, 0
}
- return typ.ValuesStart + arg.Val, typ.ValuesPerProc, typ.BigEndian
+ return typ.ValuesStart + arg.Val, typ.ValuesPerProc
default:
panic(fmt.Sprintf("unknown ConstArg type %#v", typ))
}
}
-func (arg *ConstArg) ValueForProc(pid uint64) uint64 {
- v, stride, be := arg.Value()
- v += stride * pid
- if be {
- switch arg.Size() {
- case 2:
- v = uint64(swap16(uint16(v)))
- case 4:
- v = uint64(swap32(uint32(v)))
- case 8:
- v = swap64(v)
- default:
- panic(fmt.Sprintf("bad const size %v", arg.Size()))
- }
- }
- return v
-}
-
// Used for PtrType and VmaType.
type PointerArg struct {
ArgCommon