From: @zhangbuxue Reviewed-by: @ginfung,@zh_qh Signed-off-by: @zh_qhtags/v1.2.0-rc1
| @@ -66,6 +66,7 @@ AST_SUB_TYPE_NAME = 5 # ast.Name | |||||
| AST_SUB_TYPE_TUPLE = 6 # ast.Tuple | AST_SUB_TYPE_TUPLE = 6 # ast.Tuple | ||||
| AST_SUB_TYPE_SUBSCRIPT = 7 # ast.Subscript | AST_SUB_TYPE_SUBSCRIPT = 7 # ast.Subscript | ||||
| AST_SUB_TYPE_STARRED = 8 # ast.Starred | AST_SUB_TYPE_STARRED = 8 # ast.Starred | ||||
| AST_SUB_TYPE_ATTRIBUTE = 9 # ast.Attribute | |||||
| AST_SUB_TYPE_UNKNOWN = 0xFF # unknown | AST_SUB_TYPE_UNKNOWN = 0xFF # unknown | ||||
| # Process expr statement white list | # Process expr statement white list | ||||
| @@ -456,6 +457,8 @@ class Parser: | |||||
| ast_type = AST_SUB_TYPE_SUBSCRIPT | ast_type = AST_SUB_TYPE_SUBSCRIPT | ||||
| elif isinstance(node, ast.Starred): | elif isinstance(node, ast.Starred): | ||||
| ast_type = AST_SUB_TYPE_STARRED | ast_type = AST_SUB_TYPE_STARRED | ||||
| elif isinstance(node, ast.Attribute): | |||||
| ast_type = AST_SUB_TYPE_ATTRIBUTE | |||||
| else: | else: | ||||
| ast_type = AST_SUB_TYPE_UNKNOWN | ast_type = AST_SUB_TYPE_UNKNOWN | ||||
| return ast_type | return ast_type | ||||
| @@ -1588,6 +1588,9 @@ void Parser::WriteAssignVars(const FunctionBlockPtr &block, const py::object &ta | |||||
| HandleAssignSubscript(block, targ, value_node); | HandleAssignSubscript(block, targ, value_node); | ||||
| } else if (ast_->IsClassMember(targ)) { | } else if (ast_->IsClassMember(targ)) { | ||||
| HandleAssignClassMember(block, targ, value_node); | HandleAssignClassMember(block, targ, value_node); | ||||
| } else if (ast_type == AST_SUB_TYPE_ATTRIBUTE) { | |||||
| MS_LOG(EXCEPTION) << "The subnet attributes cannot be changed in the network" | |||||
| << " NodeInfo: " << trace::GetDebugInfo(value_node->debug_info()); | |||||
| } else { | } else { | ||||
| MS_LOG(EXCEPTION) << "Not supported assign type: " << ast_type | MS_LOG(EXCEPTION) << "Not supported assign type: " << ast_type | ||||
| << " NodeInfo: " << trace::GetDebugInfo(value_node->debug_info()); | << " NodeInfo: " << trace::GetDebugInfo(value_node->debug_info()); | ||||
| @@ -42,6 +42,7 @@ enum AstSubType : int64_t { | |||||
| AST_SUB_TYPE_TUPLE = 6, // ast.Tuple | AST_SUB_TYPE_TUPLE = 6, // ast.Tuple | ||||
| AST_SUB_TYPE_SUBSCRIPT = 7, // ast.Subscript | AST_SUB_TYPE_SUBSCRIPT = 7, // ast.Subscript | ||||
| AST_SUB_TYPE_STARRED = 8, // ast.Starred | AST_SUB_TYPE_STARRED = 8, // ast.Starred | ||||
| AST_SUB_TYPE_ATTRIBUTE = 9, // ast.Attribute | |||||
| AST_SUB_TYPE_UNKNOWN = 0xFF // Error | AST_SUB_TYPE_UNKNOWN = 0xFF // Error | ||||
| }; | }; | ||||
| @@ -147,7 +148,7 @@ const char RESOLVE_NAMESPACE_NAME_MODULE[] = "Module"; // fro Module | |||||
| // define Resolve type | // define Resolve type | ||||
| enum ResolveTypeDef : int64_t { | enum ResolveTypeDef : int64_t { | ||||
| RESOLVE_TYPE_NONE = 0, // resolve None | RESOLVE_TYPE_NONE = 0, // resolve None | ||||
| RESOLVE_TYPE_FUNCTION = 1, // reslove function | |||||
| RESOLVE_TYPE_FUNCTION = 1, // resolve function | |||||
| RESOLVE_TYPE_METHOD = 2, // resolve class method | RESOLVE_TYPE_METHOD = 2, // resolve class method | ||||
| RESOLVE_TYPE_CLASS_TYPE = 3, // resolve class type | RESOLVE_TYPE_CLASS_TYPE = 3, // resolve class type | ||||
| RESOLVE_TYPE_CLASS_INSTANCE = 4, // resolve the class instance of common class | RESOLVE_TYPE_CLASS_INSTANCE = 4, // resolve the class instance of common class | ||||