1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 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 #ifndef USCRIPT_PARAM_H 16 #define USCRIPT_PARAM_H 17 18 #include <cstdint> 19 #include <string> 20 #include <vector> 21 #include "script_context.h" 22 23 namespace Uscript { 24 /** 25 * 定义函数的参数,使用vector保存函数参数 26 * 在定义函数时,实参,对应标识符表达式 27 * 函数调用时,可能是标识符,也可能是字符串、整数、浮点数或者函数调用 28 */ 29 class UScriptExpression; 30 31 class ScriptParams { 32 public: 33 friend class ScriptFunction; 34 static const int32_t g_maxParamNumber = 5; 35 ScriptParams()36 ScriptParams() {} 37 ~ScriptParams(); 38 void AddParams(UScriptExpression *expression); GetParams()39 const std::vector<UScriptExpression*> GetParams() const 40 { 41 return expressionList_; 42 } 43 44 static ScriptParams* CreateParams(UScriptExpression *expression); 45 static ScriptParams* AddParams(ScriptParams *params, UScriptExpression *expression); 46 47 private: 48 std::vector<UScriptExpression*> expressionList_ {}; 49 }; 50 } // namespace Uscript 51 #endif // HS_PARAM_H 52