1# Copyright 2017 The TensorFlow Authors. All Rights Reserved. 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# ============================================================================== 15"""Annotations used by the static analyzer.""" 16 17from __future__ import absolute_import 18from __future__ import division 19from __future__ import print_function 20 21from enum import Enum 22 23 24# TODO(mdan): Remove. 25 26 27class NoValue(Enum): 28 29 def __repr__(self): 30 return self.name 31 32 33class NodeAnno(NoValue): 34 """Additional annotations used by the static analyzer. 35 36 These are in addition to the basic annotations declared in anno.py. 37 """ 38 39 # Symbols 40 # These flags are boolean. 41 IS_LOCAL = 'Symbol is local to the function scope being analyzed.' 42 IS_PARAM = 'Symbol is a parameter to the function being analyzed.' 43 IS_MODIFIED_SINCE_ENTRY = ( 44 'Symbol has been explicitly replaced in the current function scope.') 45 46 # Scopes 47 # Scopes are represented by objects of type activity.Scope. 48 ARGS_SCOPE = 'The scope for the argument list of a function call.' 49 COND_SCOPE = 'The scope for the test node of a conditional statement.' 50 ITERATE_SCOPE = 'The scope for the iterate assignment of a for loop.' 51 ARGS_AND_BODY_SCOPE = ( 52 'The scope for the main body of a function or lambda, including its' 53 ' arguments.') 54 BODY_SCOPE = ( 55 'The scope for the main body of a statement (True branch for if ' 56 'statements, main body for loops).') 57 ORELSE_SCOPE = ( 58 'The scope for the orelse body of a statement (False branch for if ' 59 'statements, orelse body for loops).') 60