MCPcopy Create free account
hub / github.com/google/gapid / ConstStruct

Method ConstStruct

core/codegen/module.go:469–480  ·  view source on GitHub ↗

ConstStruct returns a constant struct with the value v.

(ty *Struct, fields map[string]interface{})

Source from the content-addressed store, hash-verified

467
468// ConstStruct returns a constant struct with the value v.
469func (m *Module) ConstStruct(ty *Struct, fields map[string]interface{}) Const {
470 vals := make([]llvm.Value, len(ty.Fields()))
471 for i, f := range ty.Fields() {
472 if v := fields[f.Name]; v == nil {
473 vals[i] = llvm.ConstNull(f.Type.llvmTy())
474 } else {
475 vals[i] = m.ScalarOfType(v, f.Type).llvm
476 }
477 }
478 val := llvm.ConstNamedStruct(ty.llvm, vals)
479 return Const{ty, val}
480}
481
482// Zero returns a constant zero value of type ty.
483func (m *Module) Zero(ty Type) Const {

Callers 4

CtorMethod · 0.80
rttiMethod · 0.80
buildModuleMethod · 0.80
compileMethod · 0.80

Calls 3

ScalarOfTypeMethod · 0.95
FieldsMethod · 0.80
llvmTyMethod · 0.65

Tested by

no test coverage detected