本文整理匯總了C#中PascalABCCompiler.SyntaxTree.formal_parameters.Add方法的典型用法代碼示例。如果您正苦於以下問題:C# formal_parameters.Add方法的具體用法?C# formal_parameters.Add怎麽用?C# formal_parameters.Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PascalABCCompiler.SyntaxTree.formal_parameters
的用法示例。
在下文中一共展示了formal_parameters.Add方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: BuildFormalParameters
public static formal_parameters BuildFormalParameters(List<ident> names, List<type_definition> types)
{
var fp = new formal_parameters();
for (int i = 0; i < names.Count; i++)
fp.Add(new typed_parameters(names[i], types[i]));
return fp;
}
示例2: InferTypesFromVarStmt
/// <summary>
/// Вывод типа параметров лямбд и типа возвращаемого значения при присваивании лямбды переменной
/// </summary>
public static void InferTypesFromVarStmt(type_node leftType, function_lambda_definition lambdaDef, syntax_tree_visitor visitor)
{
if (lambdaDef == null)
return;
if (leftType != null)
{
delegate_internal_interface dii_left =
(delegate_internal_interface)leftType.get_internal_interface(internal_interface_kind.delegate_interface);
if (dii_left == null)
visitor.AddError(visitor.get_location(lambdaDef), "ILLEGAL_LAMBDA_VARIABLE_TYPE");
int leftTypeParamsNumber = dii_left.parameters.Count;
int lambdaDefParamsCount = 0;
if (lambdaDef.formal_parameters != null && lambdaDef.formal_parameters.params_list.Count != 0)
{
for (int i = 0; i < lambdaDef.formal_parameters.params_list.Count; i++)
lambdaDefParamsCount += lambdaDef.formal_parameters.params_list[i].idents.idents.Count;
if (lambdaDefParamsCount != leftTypeParamsNumber)
visitor.AddError(visitor.get_location(lambdaDef), "ILLEGAL_LAMBDA_PARAMETERS_NUMBER");
bool flag = true;
SyntaxTree.formal_parameters lambdaDefParamsTypes = new formal_parameters();
for (int i = 0; i < lambdaDef.formal_parameters.params_list.Count; i++)
for (int j = 0; j < lambdaDef.formal_parameters.params_list[i].idents.idents.Count; j++)
{
var param = new SyntaxTree.typed_parameters();
param.idents = new ident_list();
param.idents.Add(lambdaDef.formal_parameters.params_list[i].idents.idents[j]);
param.vars_type = lambdaDef.formal_parameters.params_list[i].vars_type;
lambdaDefParamsTypes.Add(param);
}
for (int i = 0; i < leftTypeParamsNumber && flag; i++)
{
if (lambdaDefParamsTypes.params_list[i].vars_type is SyntaxTree.lambda_inferred_type)
{
if ((lambdaDefParamsTypes.params_list[i].vars_type as SyntaxTree.lambda_inferred_type).real_type is lambda_any_type_node)
{
var curLeftParType = dii_left.parameters[i].type;
lambdaDefParamsTypes.params_list[i].vars_type = new SyntaxTree.lambda_inferred_type();
(lambdaDefParamsTypes.params_list[i].vars_type as SyntaxTree.lambda_inferred_type).real_type = curLeftParType;
continue;
}
}
var lambdaPar = visitor.convert_strong(lambdaDefParamsTypes.params_list[i].vars_type);
if (!convertion_data_and_alghoritms.eq_type_nodes(dii_left.parameters[i].type, lambdaPar))
{
visitor.AddError(visitor.get_location(lambdaDef), "ILLEGAL_LAMBDA_VARIABLE_TYPE");
}
}
lambdaDef.formal_parameters = lambdaDefParamsTypes;
}
if (lambdaDef.return_type != null && lambdaDef.return_type is lambda_inferred_type)
{
if (dii_left.return_value_type != null)
(lambdaDef.return_type as lambda_inferred_type).real_type = dii_left.return_value_type;
else // SSM 23/07/16 - попытка бороться с var p: Shape->() := a->a.Print()
{
var b = TryConvertFuncLambdaBodyWithMethodCallToProcLambdaBody(lambdaDef);
if (!b)
throw new SimpleSemanticError(visitor.get_location(lambdaDef), "UNABLE_TO_CONVERT_FUNCTIONAL_TYPE_TO_PROCEDURAL_TYPE");
}
}
}
else
{
if (lambdaDef.formal_parameters != null)
for (int i = 0; i < lambdaDef.formal_parameters.params_list.Count; i++)
if (lambdaDef.formal_parameters.params_list[i].vars_type is lambda_inferred_type)
visitor.AddError(visitor.get_location(lambdaDef), "IMPOSSIBLE_TO_INFER_TYPES_IN_LAMBDA");
}
}