types.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package mk2rbc
  15. // Starlark expression types we use
  16. type starlarkType int
  17. const (
  18. // Variable types. Initially we only know the types of the product
  19. // configuration variables that are lists, and the types of some
  20. // hardwired variables. The remaining variables are first entered as
  21. // having an unknown type and treated as strings, but sometimes we
  22. // can infer variable's type from the value assigned to it.
  23. starlarkTypeUnknown starlarkType = iota
  24. starlarkTypeList starlarkType = iota
  25. starlarkTypeString starlarkType = iota
  26. starlarkTypeInt starlarkType = iota
  27. starlarkTypeBool starlarkType = iota
  28. starlarkTypeVoid starlarkType = iota
  29. )
  30. type varClass int
  31. const (
  32. VarClassConfig varClass = iota
  33. VarClassSoong varClass = iota
  34. VarClassLocal varClass = iota
  35. )
  36. type variableRegistrar interface {
  37. NewVariable(name string, varClass varClass, valueType starlarkType)
  38. }
  39. // ScopeBase is a dummy implementation of the mkparser.Scope.
  40. // All our scopes are read-only and resolve only simple variables.
  41. type ScopeBase struct{}
  42. func (s ScopeBase) Set(_, _ string) {
  43. panic("implement me")
  44. }
  45. func (s ScopeBase) Call(_ string, _ []string) []string {
  46. panic("implement me")
  47. }
  48. func (s ScopeBase) SetFunc(_ string, _ func([]string) []string) {
  49. panic("implement me")
  50. }
  51. // Used to find all makefiles in the source tree
  52. type MakefileFinder interface {
  53. Find(root string) []string
  54. }