diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/texec/libtnsl.go | 1 | ||||
-rw-r--r-- | src/texec/world.go | 1 | ||||
-rw-r--r-- | src/texec/worldbuilder.go | 23 |
3 files changed, 25 insertions, 0 deletions
diff --git a/src/texec/libtnsl.go b/src/texec/libtnsl.go index a5d4589..c0580c7 100644 --- a/src/texec/libtnsl.go +++ b/src/texec/libtnsl.go @@ -54,6 +54,7 @@ var ( // used only in module definintion tEnum = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name: "enum"}, Post: ""} + tStruct = TType{Pre: []string{}, T: TArtifact{Path: []string{}, Name: "struct"}, Post: ""} ) // tells if the stub supports a function diff --git a/src/texec/world.go b/src/texec/world.go index d0435a0..d88eae2 100644 --- a/src/texec/world.go +++ b/src/texec/world.go @@ -38,6 +38,7 @@ type TVariable struct { } type VarMap map[string]TVariable +type TypeMap map[string]TType // TContext represents a single call context. type TContext struct { diff --git a/src/texec/worldbuilder.go b/src/texec/worldbuilder.go index 5fc5683..141d1aa 100644 --- a/src/texec/worldbuilder.go +++ b/src/texec/worldbuilder.go @@ -74,6 +74,28 @@ func modDefVars(n tparse.Node, t TType) ([]string, []TVariable) { return s, v } +func modDefStruct(n tparse.Node, m *TModule) { + var name string + tmap := make(TypeMap) + + for i := 0; i < len(n.Sub); i++ { + if n.Sub[i].Data.Type == tparse.DEFWORD { + name = n.Sub[i].Data.Data + } else if n.Sub[i].Data.Data == "plist" && n.Sub[i].Data.Type == 10 { + var t TType + for j := 0; j < len(n.Sub[i].Sub); j++ { + if n.Sub[i].Sub[j].Data.Type == 10 && n.Sub[i].Sub[j].Data.Data == "type" { + t = getType(n.Sub[i].Sub[j]) + } else if n.Sub[i].Sub[j].Data.Type == tparse.DEFWORD { + tmap[n.Sub[i].Sub[j].Data.Data] = t + } + } + } + } + + m.Defs[name] = TVariable{tStruct, tmap} +} + func modDefEnum(n tparse.Node, m *TModule) { name := n.Sub[0].Data.Data t := getType(n.Sub[1].Sub[0]) @@ -108,6 +130,7 @@ func importFile(f string, m *TModule) { } else if froot.Sub[n].Data.Data == "enum"{ modDefEnum(froot.Sub[n], m) }else if froot.Sub[n].Data.Data == "struct" || froot.Sub[n].Data.Data == "raw"{ + modDefStruct(froot.Sub[n], m) } else { m.Artifacts = append(m.Artifacts, froot.Sub[n]) } |