-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate.go
37 lines (33 loc) · 1.2 KB
/
state.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
package main
type State struct {
hashesToFeature map[hash]featureName
hashesToDeclaration map[hash]declaration
core prologCore
artifacts map[artifactName]Artifact
variables map[artifactName]map[featureName]map[attributeName]attributeValue
globals globalContext
features map[featureName]Feature
possibleProviders map[declaration]set[featureName]
activeFeatures set[featureName]
deadFeatures set[featureName]
}
func newState()(state State){
state.reset()
return state
}
func (state *State) reset(){
state.hashesToFeature = make(map[hash]featureName)
state.hashesToDeclaration = make(map[hash]declaration)
state.core = setupProlog()
state.artifacts = make(map[artifactName]Artifact)
state.variables = make(map[artifactName]map[featureName]map[attributeName]attributeValue)
state.globals = newGlobalContext()
state.features = map[featureName]Feature{ROOT:newAbstractFeature(ROOT, "root")}
state.possibleProviders = make(map[declaration]set[featureName])
state.activeFeatures = make(set[featureName])
state.deadFeatures = make(set[featureName])
}
func (state *State) isActive (feature featureName)bool{
_, active := state.activeFeatures[feature]
return active
}