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 15package mk2rbc 16 17// Starlark expression types we use 18type starlarkType int 19 20const ( 21 // Variable types. Initially we only know the types of the product 22 // configuration variables that are lists, and the types of some 23 // hardwired variables. The remaining variables are first entered as 24 // having an unknown type and treated as strings, but sometimes we 25 // can infer variable's type from the value assigned to it. 26 starlarkTypeUnknown starlarkType = iota 27 starlarkTypeList starlarkType = iota 28 starlarkTypeString starlarkType = iota 29 starlarkTypeInt starlarkType = iota 30 starlarkTypeBool starlarkType = iota 31 starlarkTypeVoid starlarkType = iota 32) 33 34type hiddenArgType int 35 36const ( 37 // Some functions have an implicitly emitted first argument, which may be 38 // a global ('g') or configuration ('cfg') variable. 39 hiddenArgNone hiddenArgType = iota 40 hiddenArgGlobal hiddenArgType = iota 41 hiddenArgConfig hiddenArgType = iota 42) 43 44type varClass int 45 46const ( 47 VarClassConfig varClass = iota 48 VarClassSoong varClass = iota 49 VarClassLocal varClass = iota 50) 51 52type variableRegistrar interface { 53 NewVariable(name string, varClass varClass, valueType starlarkType) 54} 55 56// ScopeBase is a placeholder implementation of the mkparser.Scope. 57// All our scopes are read-only and resolve only simple variables. 58type ScopeBase struct{} 59 60func (s ScopeBase) Set(_, _ string) { 61 panic("implement me") 62} 63 64func (s ScopeBase) Call(_ string, _ []string) []string { 65 panic("implement me") 66} 67 68func (s ScopeBase) SetFunc(_ string, _ func([]string) []string) { 69 panic("implement me") 70} 71 72// Used to find all makefiles in the source tree 73type MakefileFinder interface { 74 Find(root string) []string 75} 76