本文整理汇总了C#中expressions_list类的典型用法代码示例。如果您正苦于以下问题:C# expressions_list类的具体用法?C# expressions_list怎么用?C# expressions_list使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
expressions_list类属于命名空间,在下文中一共展示了expressions_list类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: convert_function_call_expressions
private void convert_function_call_expressions(function_node fn,expressions_list exprs,
possible_type_convertions_list ptcal)
{
/*if (SystemLibrary.SystemLibrary.syn_visitor.SystemUnitAssigned && fn.name != compiler_string_consts.assign_name && !SystemLibrary.SystemLibrary.syn_visitor.one_way_operation(fn.name) && SystemLibrary.SystemLibrary.syn_visitor.in_check_range_region())
{
for (int i=0; i<exprs.Count; i++)
{
if (exprs[i] is statements_expression_node)
break;
expression_node right = exprs[i];
if (fn.parameters.Count <= i)
break;
if (fn.parameters[i].parameter_type == parameter_type.var)
continue;
type_node left_type = fn.parameters[i].type;
if (SystemLibrary.SystemLibrary.syn_visitor.is_range_checkable(left_type) && SystemLibrary.SystemLibrary.syn_visitor.is_range_checkable(exprs[i].type))
{
ordinal_type_interface oti = left_type.get_internal_interface(internal_interface_kind.ordinal_interface) as ordinal_type_interface;
if (left_type != SystemLibrary.SystemLibrary.char_type)
if(!(oti.lower_value is enum_const_node) && !(oti.lower_value is char_const_node))
right = SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.convert_type(SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.create_simple_function_call(SystemLibrary.SystemLibInitializer.CheckRangeFunction.sym_info as common_namespace_function_node, null, SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.convert_type(right,SystemLibrary.SystemLibrary.int64_type),
SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.convert_type(oti.lower_value,SystemLibrary.SystemLibrary.int64_type),SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.convert_type(oti.upper_value,SystemLibrary.SystemLibrary.int64_type)),right.type);
else if (oti.lower_value is enum_const_node)
{
right = SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.explicit_convert_type(SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.create_simple_function_call(SystemLibrary.SystemLibInitializer.CheckRangeFunction.sym_info as common_namespace_function_node, null, SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.explicit_convert_type(right,SystemLibrary.SystemLibrary.int64_type),
SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.explicit_convert_type(oti.lower_value,SystemLibrary.SystemLibrary.int64_type),SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.explicit_convert_type(oti.upper_value,SystemLibrary.SystemLibrary.int64_type)),right.type);
}
else if (oti.lower_value is char_const_node)
right = SystemLibrary.SystemLibrary.syn_visitor.convertion_data_and_alghoritms.create_simple_function_call(SystemLibrary.SystemLibInitializer.CheckCharRangeFunction.sym_info as common_namespace_function_node, null, right, oti.lower_value,oti.upper_value);
}
exprs[i] = right;
}
}*/
for(int i=0;i<exprs.Count;i++)
{
if ((ptcal.snl != null) && (i >= fn.parameters.Count - 1))
{
//statement_list_stack.top().statements.AddRange(ptcal.snl);
statements_expression_node sre = new statements_expression_node(ptcal.snl, ptcal.var_ref, ptcal.var_ref.location);
exprs.remove_range(fn.parameters.Count - 1, exprs.Count - fn.parameters.Count);
//exprs.AddElement(ptcal.var_ref);
//exprs[i] = ptcal.var_ref;
exprs[i] = sre;
break;
}
if ((ptcal[i]==null)||(ptcal[i].first==null)||exprs[i] is null_const_node)
{
continue;
}
expression_node[] temp_arr = new expression_node[1];
temp_arr[0] = exprs[i];
if (ptcal[i].first.convertion_method is compiled_constructor_node)
exprs[i] = create_compiled_construcor_call(ptcal[i].first.convertion_method as compiled_constructor_node, get_location(exprs[i]), temp_arr);
else
exprs[i] = create_simple_function_call(ptcal[i].first.convertion_method, get_location(exprs[i]), temp_arr);
}
//TODO: Можно сделать параметры по умолчанию для откомпилированных функций.
if ((exprs.Count < fn.parameters.Count) && (fn.node_kind == SemanticTree.node_kind.common))
{
if (exprs.Count == 0 && fn.parameters != null && fn.parameters.Count == 1 && fn.parameters[0].is_params ||
exprs.Count == 1 && fn.parameters != null && fn is common_namespace_function_node && (fn as common_namespace_function_node).ConnectedToType != null &&
fn.parameters.Count == 2 && fn.parameters[1].is_params)
{
statements_expression_node sre = new statements_expression_node(ptcal.snl, ptcal.var_ref, ptcal.var_ref.location);
//exprs.remove_range(fn.parameters.Count - 1, exprs.Count - fn.parameters.Count);
//exprs.AddElement(ptcal.var_ref);
//exprs[i] = ptcal.var_ref;
exprs.AddElement(sre);
}
common_function_node cfn = (common_function_node)fn;
for (int j = exprs.Count; j < cfn.parameters.Count; j++)
{
common_parameter cp = (common_parameter)cfn.parameters[j];
if (cp.default_value != null)
exprs.AddElement(cp.default_value);
}
}
else if ((exprs.Count < fn.parameters.Count) && (fn.node_kind == SemanticTree.node_kind.compiled))
{
if (exprs.Count == 0 && fn.parameters != null && fn.parameters.Count == 1 && fn.parameters[0].is_params)
{
statements_expression_node sre = new statements_expression_node(ptcal.snl, ptcal.var_ref, ptcal.var_ref.location);
exprs.AddElement(sre);
}
//compiled_function_node cfn = (compiled_function_node)fn;
for (int j = exprs.Count; j < fn.parameters.Count; j++)
{
compiled_parameter cp = (compiled_parameter)fn.parameters[j];
if (cp.default_value != null)
exprs.AddElement(cp.default_value);
}
}
}
示例2: create_static_method_call_with_params
private base_function_call create_static_method_call_with_params(function_node fn, location loc, type_node tn, bool procedure_allowed, expressions_list parametrs)
{
base_function_call bfc = create_static_method_call(fn, loc, tn, procedure_allowed);
bfc.parameters.AddRange(parametrs);
return bfc;
}
示例3: find_operator
private expression_node find_operator(SyntaxTree.Operators ot, expression_node expr, location loc)
{
string name = name_reflector.get_name(ot);
//#if (DEBUG)
if (name == null)
{
if (ot == PascalABCCompiler.SyntaxTree.Operators.AddressOf)
{
if (expr.is_addressed == false)
{
AddError(expr.location, "CAN_NOT_GET_ADDRESS_FROM_EXPRESSION");
}
expression_node res = new get_addr_node(expr, loc);
return res;
}
if (ot == PascalABCCompiler.SyntaxTree.Operators.Dereference)
{
}
throw new CompilerInternalError("Invalid operator name");
}
//#endif
SymbolInfo si = expr.type.find(name, context.CurrentScope);
if (si == null || si.sym_info is wrapped_definition_node)
{
AddError(new OperatorCanNotBeAppliedToThisType(name, expr));
}
expressions_list pars = new expressions_list();
pars.AddElement(expr);
function_node fn = convertion_data_and_alghoritms.select_function(pars, si, loc);
expr = pars[0];
if (fn == null)
{
AddError(new OperatorCanNotBeAppliedToThisType(name, expr));
}
#if (DEBUG)
convertion_data_and_alghoritms.check_operator(fn);
#endif
expression_node exp_node = convertion_data_and_alghoritms.create_simple_function_call(fn, loc, expr);
return exp_node;
}
示例4: make_pred_call
private expression_node make_pred_call(SymbolInfo si, SyntaxTree.expression_list parameters, location loc)
{
if (parameters == null)
{
AddError(new NoFunctionWithSameParametresNum(loc, false, si.sym_info as function_node));
return null;
}
if (parameters.expressions.Count == 1)
{
expression_node param0 = convert_strong(parameters.expressions[0]);
if (param0 is typed_expression) param0 = convert_typed_expression_to_function_call(param0 as typed_expression);
basic_function_call bfc = null;
int type_flag = 0;
expressions_list el = new expressions_list();
el.AddElement(param0);
function_node fn = null;
try
{
fn = convertion_data_and_alghoritms.select_function(el,si,loc);
}
catch(Exception e)
{
}
if (fn != null)
{
if (fn is common_namespace_function_node)
{
common_namespace_function_call cnfc = new common_namespace_function_call(fn as common_namespace_function_node, loc);
cnfc.parameters.AddElement(param0);
return cnfc;
}
else
{
compiled_static_method_call cnfc = new compiled_static_method_call(fn as compiled_function_node, loc);
cnfc.parameters.AddElement(param0);
return cnfc;
}
}
else if (param0.type.type_special_kind == PascalABCCompiler.SemanticTree.type_special_kind.diap_type || param0.type.IsEnum)
{
el = new expressions_list();
el.AddElement(new int_const_node(1,null));
fn = convertion_data_and_alghoritms.select_function(el,si,loc);
//bfc = new basic_function_call(SystemLibrary.SystemLibrary.int_add as basic_function_node,loc);
//bfc.ret_type = param0.type;
if (fn is common_namespace_function_node)
{
common_namespace_function_call cnfc = new common_namespace_function_call(fn as common_namespace_function_node, loc);
cnfc.parameters.AddElement(param0);
cnfc.type = param0.type;
return cnfc;
}
else
{
compiled_static_method_call cnfc = new compiled_static_method_call(fn as compiled_function_node, loc);
cnfc.parameters.AddElement(param0);
cnfc.type = param0.type;
return cnfc;
}
}
else AddError(new NoFunctionWithSameArguments(loc,false));
bfc.parameters.AddElement(param0);
if (type_flag == 0 || type_flag == 3)
bfc.parameters.AddElement(new int_const_node(1,null));
else if (type_flag == 1)
bfc.parameters.AddElement(new long_const_node(1,null));
else if (type_flag == 2)
bfc.parameters.AddElement(new ulong_const_node(1,null));
return bfc;
}
AddError(new NoFunctionWithSameParametresNum(loc,false,si.sym_info as function_node));
return null;
}
示例5: make_read_call
private expression_node make_read_call(SymbolInfo si, SyntaxTree.expression_list parameters, location loc)
{
// вызов read(a,b,c) разбивается на несколько вызовов, последний возвращается узлом, а остальные добавляются здесь в теле expressions_list exl = new expressions_list();
expression_node last_call = null;
expressions_list exl = new expressions_list();
expression_node file = null;
bool read_from_file = false;
bool read_from_text_file = false;
bool read_from_typed_file = false;
bool read_from_binary_file = false;
bool readln_string_file = false;
if (parameters != null) // если список параметров не пуст
{
if (parameters.expressions.Count >= 1)
{
expression_node param0 = convert_strong(parameters.expressions[0]);
if (param0.type != null)
{
if (SystemLibrary.SystemLibInitializer.TextFileType.Found && param0.type == SystemLibrary.SystemLibInitializer.TextFileType.sym_info)
{
file = param0;
read_from_text_file = true;
}
if (param0.type.type_special_kind == SemanticTree.type_special_kind.typed_file
&& parameters.expressions.Count > 1 //это можно внести во внутрь
)//и побросать приличные исключения
{
if (!SystemLibrary.SystemLibInitializer.read_procedure.FromDll)
{
if (si == SystemLibrary.SystemLibInitializer.read_procedure.SymbolInfo)
{
file = param0;
read_from_typed_file = true;
}
}
else if (SystemLibrary.SystemLibInitializer.read_procedure.Equal(si))
{
file = param0;
read_from_typed_file = true;
}
}
if (param0.type.type_special_kind == SemanticTree.type_special_kind.binary_file
&& parameters.expressions.Count > 1 //это можно внести во внутрь
)//и побросать приличные исключения
{
if (!SystemLibrary.SystemLibInitializer.read_procedure.FromDll)
{
if (si == SystemLibrary.SystemLibInitializer.read_procedure.SymbolInfo)
{
file = param0;
read_from_binary_file = true;
}
}
else if (SystemLibrary.SystemLibInitializer.read_procedure.Equal(si))
{
file = param0;
read_from_binary_file = true;
}
}
}
read_from_file = read_from_text_file || read_from_typed_file || read_from_binary_file;
}
bool first_iteration = true;
foreach (SyntaxTree.expression ex in parameters.expressions)
{
if (first_iteration && read_from_file)
{
first_iteration = false;
continue;
}
if (last_call != null && convertion_data_and_alghoritms.statement_list_stack.size > 0)
convertion_data_and_alghoritms.statement_list_stack.top().statements.AddElement(last_call);
expression_node en = convert_strong(ex);
check_on_loop_variable(en);
//if (en.type == null)
//throw new CanNotRead(en.location);
exl.clear();
if (read_from_file)
exl.AddElement(file);
if (read_from_typed_file)
{
if (SystemLibrary.SystemLibInitializer.TypedFileReadProcedure == null)
AddError(new NotSupportedError(loc));
if (en.type != file.type.element_type)
AddError(new ExpectedExprHaveTypeTypedFile(file.type.element_type, en.type, true, get_location(ex)));
bool is_char_getter = false;
if (!en.is_addressed)
{
if (en is compiled_function_call)
{
compiled_function_call cfc = en as compiled_function_call;
if ((cfc.function_node.return_value_type == SystemLibrary.SystemLibrary.char_type && cfc.function_node.cont_type == SystemLibrary.SystemLibrary.string_type
&& cfc.function_node == cfc.function_node.cont_type.default_property_node.get_function))
{
en = new simple_array_indexing((en as compiled_function_call).obj, (en as compiled_function_call).parameters[0], SystemLibrary.SystemLibrary.char_type, en.location);
is_char_getter = true;
}
//.........这里部分代码省略.........
示例6: visit
public override void visit(SyntaxTree.pascal_set_constant _pascal_set_constant)
{
//throw new NotSupportedError(get_location(_pascal_set_constant));
if (SystemLibrary.SystemLibInitializer.TypedSetType == null || SystemLibrary.SystemLibInitializer.CreateSetProcedure == null)
AddError(new NotSupportedError(get_location(_pascal_set_constant)));
expressions_list consts = new expressions_list();
type_node el_type = null;
type_node_list types = new type_node_list();
if (_pascal_set_constant.values != null && _pascal_set_constant.values != null)
foreach (SyntaxTree.expression e in _pascal_set_constant.values.expressions)
{
if (e is SyntaxTree.nil_const)
ErrorsList.Add(new SimpleSemanticError(get_location(e), "NIL_IN_SET_CONSTRUCTOR_NOT_ALLOWED"));
else
if (e is SyntaxTree.diapason_expr)
{
consts.AddElement(convert_diap_for_set((e as SyntaxTree.diapason_expr), out el_type));
if (el_type.IsPointer)
ErrorsList.Add(new SimpleSemanticError(get_location(e), "POINTERS_IN_SETS_NOT_ALLOWED"));
types.AddElement(el_type);
}
else
{
expression_node en = convert_strong(e);
if (en is typed_expression) en = convert_typed_expression_to_function_call(en as typed_expression);
if (en.type.type_special_kind == SemanticTree.type_special_kind.short_string)
en.type = SystemLibrary.SystemLibrary.string_type;
consts.AddElement(en);
types.AddElement(en.type);
}
}
expressions_list consts_copy = new expressions_list();
consts_copy.AddRange(consts);
type_node ctn = null;
if (consts.Count > 0)
{
el_type = convertion_data_and_alghoritms.select_base_type(types);
ctn = context.create_set_type(el_type, get_location(_pascal_set_constant));
}
else ctn = SystemLibrary.SystemLibInitializer.TypedSetType.sym_info as type_node;
function_node fn = convertion_data_and_alghoritms.select_function(consts, SystemLibrary.SystemLibInitializer.CreateSetProcedure.SymbolInfo, (SystemLibrary.SystemLibInitializer.CreateSetProcedure.sym_info is common_namespace_function_node)?(SystemLibrary.SystemLibInitializer.CreateSetProcedure.sym_info as common_namespace_function_node).loc:null);
if (fn is common_namespace_function_node)
{
common_namespace_function_call cnfc = new common_namespace_function_call(fn as common_namespace_function_node, get_location(_pascal_set_constant));
add_set_initializer(cnfc, consts_copy);
cnfc.ret_type = ctn;
for (int i = 0; i < consts.Count; i++)
cnfc.parameters.AddElement(consts[i]);
return_value(cnfc);
}
else
{
compiled_static_method_call cnfc = new compiled_static_method_call(fn as compiled_function_node, get_location(_pascal_set_constant));
add_set_initializer(cnfc, consts_copy);
cnfc.ret_type = ctn;
for (int i = 0; i < consts.Count; i++)
cnfc.parameters.AddElement(consts[i]);
return_value(cnfc);
}
//return_value(new common_namespace_function_call_as_constant(cnfc,cnfc.location));
}
示例7: ConvertPointersForWriteFromDll
private void ConvertPointersForWriteFromDll(expressions_list exprs)
{
for (int i = 0; i < exprs.Count; ++i)
{
if (exprs[i].type.IsPointer)
{
if (SystemLibrary.SystemLibInitializer.PointerOutputConstructor == null)
{
SymbolInfo si = (SystemLibrary.SystemLibInitializer.PointerOutputType.sym_info as compiled_type_node).find_in_type(compiler_string_consts.default_constructor_name);
compiled_constructor_node cnode = null;
do
{
cnode = si.sym_info as compiled_constructor_node;
if (cnode.parameters.Count != 1)
{
cnode = null;
si = si.Next;
}
}
while (cnode == null);
SystemLibrary.SystemLibInitializer.PointerOutputConstructor = cnode;
}
compiled_constructor_call cnc = new compiled_constructor_call(SystemLibrary.SystemLibInitializer.PointerOutputConstructor as compiled_constructor_node, exprs[i].location);
//common_namespace_function_call cnfc = new common_namespace_function_call(
// SystemLibrary.SystemLibInitializer.PointerToStringFunction.sym_info as common_namespace_function_node,
// exprs[i].location);
cnc.parameters.AddElement(exprs[i]);
exprs[i] = cnc;
}
}
}
示例8: convert_functions_to_calls
private base_function_call_list convert_functions_to_calls(expression_node obj, function_node_list fnl, location loc, bool is_static)
{
base_function_call_list ret = new base_function_call_list();
foreach (function_node fnode in fnl)
{
base_function_call bfc = null;
switch (fnode.semantic_node_type)
{
case semantic_node_type.common_namespace_function_node:
{
common_namespace_function_node cmfn = fnode as common_namespace_function_node;
common_namespace_function_call cnfc = new common_namespace_function_call(cmfn, loc);
if (cmfn.ConnectedToType != null)
cnfc.parameters.AddElement(obj);
if (cmfn.is_generic_function && !cmfn.is_generic_function_instance && cmfn.ConnectedToType != null && cmfn.parameters.Count == 1)
{
expressions_list parameters = new expressions_list();
parameters.AddElement(obj);
function_node inst = null;
try
{
inst = generic_convertions.DeduceFunction(cmfn, parameters, true, loc);
}
catch
{
continue;
}
cnfc = new common_namespace_function_call((common_namespace_function_node)inst, loc);
if (cmfn.ConnectedToType != null)
cnfc.parameters.AddElement(obj);
}
/*if (cmfn.parameters.Count >= 1 && cmfn.parameters[cmfn.parameters.Count - 1].is_params)
{
convertion_data_and_alghoritms.select_function(cnfc.parameters, new SymbolInfo(cmfn), loc);
}*/
bfc = cnfc;
break;
}
case semantic_node_type.basic_function_node:
{
//Может здесь стоит и выругаться, но я не буду пока этого делать.
break;
}
case semantic_node_type.common_in_function_function_node:
{
common_in_function_function_node ciffn = fnode as common_in_function_function_node;
int depth = convertion_data_and_alghoritms.symbol_table.GetRelativeScopeDepth(ciffn.scope,
context.top_function.scope);
common_in_function_function_call ciffc = new common_in_function_function_call(ciffn, depth, loc);
bfc = ciffc;
break;
}
case semantic_node_type.common_method_node:
{
common_method_node cmn = fnode as common_method_node;
//Если cmn конструктор - то плохо, но его не должно сюда попасть.
if (cmn.polymorphic_state != SemanticTree.polymorphic_state.ps_static)
{
if (!is_static)
{
if (obj == null)
obj = GetCurrentObjectReference(cmn.cont_type.Scope, cmn, loc);//new this_node(context.converted_type, loc);
common_method_call cmc = new common_method_call(cmn, obj, loc);
cmc.virtual_call = !inherited_ident_processing;
bfc = cmc;
}
//ssyy!!! Мне сложно понять предназначение данного кода, но, по-видимому,
//следует его переписать так.
else if (cmn.is_constructor)
{
if (cmn.parameters.Count == 0)
{
if (cmn.cont_type.IsAbstract)
AddError(loc, "ABSTRACT_CONSTRUCTOR_{0}_CALL", cmn.cont_type.name);
ret.clear();
ret.AddElement(new common_constructor_call(cmn, loc));
return ret;
}
}
}
else
{
if (is_static)
{
common_static_method_call csmc = new common_static_method_call(cmn, loc);
bfc = csmc;
}
}
break;
}
case semantic_node_type.compiled_function_node:
{
compiled_function_node cfn = fnode as compiled_function_node;
if (cfn.cont_type.Scope == null && cfn is compiled_function_node)
(cfn.cont_type as compiled_type_node).init_scope();
if (cfn.polymorphic_state == SemanticTree.polymorphic_state.ps_static)
{
//ispravleno ibond
//.........这里部分代码省略.........
示例9: inherited_message_value_reciving
private expression_node inherited_message_value_reciving(SyntaxTree.inherited_message _ident)
{
SymbolInfo si = find_in_base(_ident);
bool constr = false;
if (si != null)
if (si.sym_info is common_method_node)
{
if ((si.sym_info as common_method_node).polymorphic_state == SemanticTree.polymorphic_state.ps_virtual_abstract)
AddError(get_location(_ident), "CANNOT_CALL_ABSTRACT_METHOD");
constr = (si.sym_info as common_method_node).is_constructor;
}
else
if (si.sym_info is compiled_function_node)
{
if ((si.sym_info as compiled_function_node).polymorphic_state == SemanticTree.polymorphic_state.ps_virtual_abstract)
AddError(get_location(_ident), "CANNOT_CALL_ABSTRACT_METHOD");
}
else if (si.sym_info is compiled_constructor_node)
{
constr = true;
}
location loc = get_location(_ident);
function_node fn = si.sym_info as function_node;
base_function_call bfc = null;
common_function_node cfn = context.converted_func_stack.first();
int depth = context.converted_func_stack.size-1;
if (!constr)
{
if (fn.polymorphic_state != SemanticTree.polymorphic_state.ps_static)
{
bfc = create_not_static_method_call(fn,new this_node(context.converted_type,loc),loc,true);
if (bfc is common_method_call)
(bfc as common_method_call).virtual_call = false;
else
(bfc as compiled_function_call).virtual_call = false;
}
else if (fn is common_method_node)
bfc = create_static_method_call(fn,loc,(fn as common_method_node).cont_type,true);
else if (fn is compiled_function_node)
bfc = create_static_method_call(fn,loc,(fn as compiled_function_node).cont_type,true);
else
throw new NotSupportedError(loc);
}
else
{
if (!context.allow_inherited_ctor_call)
AddError(loc, "INHERITED_CONSTRUCTOR_CALL_MUST_BE_FIRST");
expressions_list exprs = new expressions_list();
foreach (common_parameter cp in cfn.parameters)
{
exprs.AddElement(new common_parameter_reference(cp,depth,loc));
}
if (fn is common_method_node)
{
common_constructor_call ccc = create_constructor_call((fn as common_method_node).cont_type,exprs,loc) as common_constructor_call;
ccc._new_obj_awaited = false;
return ccc;
}
else if (fn is compiled_constructor_node)
{
compiled_constructor_call ccc = create_constructor_call((fn as compiled_constructor_node).compiled_type,exprs,loc) as compiled_constructor_call;
ccc._new_obj_awaited = false;
return ccc;
}
else
throw new NotSupportedError(loc);
}
foreach (common_parameter cp in cfn.parameters)
{
bfc.parameters.AddElement(new common_parameter_reference(cp,depth,loc));
}
return bfc;
}
示例10: make_attributes_for_declaration
private void make_attributes_for_declaration(SyntaxTree.unit_module un, common_unit_node cun)
{
if (cun.attributes != null)
{
Hashtable ht = new Hashtable();
foreach (SyntaxTree.simple_attribute_list sal in un.attributes.attributes)
for (int j = 0; j < sal.attributes.Count; j++)
{
SyntaxTree.attribute attr = sal.attributes[j];
attribute_converted = true;
type_node tn = convert_strong(attr.type);
bool is_attr = false;
type_node tmp = tn;
while (tmp.base_type != null && !is_attr)
{
is_attr = tmp.base_type == SystemLibrary.SystemLibrary.attribute_type;
tmp = tmp.base_type;
}
if (!is_attr)
AddError(get_location(attr), "CLASS_{0}_NOT_ATTRIBUTE", tn.name);
bool allowMultiple = false;
AttributeTargets targets = get_usage_attrs(tn, out allowMultiple);
if (ht.Contains(tn) && !allowMultiple)
{
AddError(get_location(attr), "DUPLICATE_ATTRIBUTE_{0}_APPLICATION", tn.name);
}
else
ht[tn] = tn;
SemanticTree.attribute_qualifier_kind qualifier = SemanticTree.attribute_qualifier_kind.none_kind;
if (attr.qualifier != null)
if (j == 0)
{
if (string.Compare(attr.qualifier.name, "return", true) == 0)
{
if (context.top_function == null)
AddError(get_location(attr), "ATTRIBUTE_APPLICABLE_ONLY_TO_METHOD");
if (context.top_function.return_value_type == null || context.top_function.return_value_type == SystemLibrary.SystemLibrary.void_type)
AddError(get_location(attr), "EXPECTED_RETURN_VALUE_FOR_ATTRIBUTE");
throw new NotSupportedError(get_location(attr.qualifier));
qualifier = SemanticTree.attribute_qualifier_kind.return_kind;
}
else
throw new NotSupportedError(get_location(attr.qualifier));
}
else
AddError(get_location(attr.qualifier), "ATTRIBUTE_QUALIFIER_MUST_BE_FIRST");
check_for_usage_attribute(cun, targets, tn.name, get_location(attr), qualifier);
attribute_converted = false;
SyntaxTree.expression_list cnstr_args = new SyntaxTree.expression_list();
if (attr.arguments != null)
{
foreach (SyntaxTree.expression e in attr.arguments.expressions)
{
if (e is SyntaxTree.bin_expr && (e as SyntaxTree.bin_expr).operation_type == SyntaxTree.Operators.Equal
&& (e as SyntaxTree.bin_expr).left is SyntaxTree.ident)
{
break;
}
else
{
cnstr_args.expressions.Add(e);
}
}
}
expressions_list args = new expressions_list();
for (int i = 0; i < cnstr_args.expressions.Count; i++)
{
constant_node cn = convert_strong_to_constant_node(cnstr_args.expressions[i]);
check_for_strong_constant(cn, get_location(cnstr_args.expressions[i]));
args.AddElement(cn);
}
base_function_call bfc = create_constructor_call(tn, args, get_location(attr));
attribute_node attr_node = new attribute_node(bfc.simple_function_node, tn, get_location(un));
foreach (expression_node en in bfc.parameters)
{
constant_node cn = convert_strong_to_constant_node(en, en.type);
check_for_strong_constant(cn, en.location);
attr_node.args.Add(cn);
}
if (attr.arguments != null)
{
for (int i = cnstr_args.expressions.Count; i < attr.arguments.expressions.Count; i++)
{
SyntaxTree.expression e = attr.arguments.expressions[i];
if (!(e is SyntaxTree.bin_expr && (e as SyntaxTree.bin_expr).operation_type == SyntaxTree.Operators.Equal
&& (e as SyntaxTree.bin_expr).left is SyntaxTree.ident))
{
AddError(get_location(e), "EXPECTED_ATTRIBUTE_INITIALIZER");
}
else
{
SyntaxTree.ident id = (e as SyntaxTree.bin_expr).left as SyntaxTree.ident;
SymbolInfo si = tn.find(id.name);
definition_node dn = context.check_name_node_type(id.name, si, get_location(id), general_node_type.property_node, general_node_type.variable_node);
type_node mem_tn = null;
if (dn is property_node)
{
property_node pn = dn as property_node;
//.........这里部分代码省略.........
示例11: get_conversions
/// <summary>
/// Возвращает список преобразований типов для вызова метода.
/// </summary>
/// <param name="factparams">Список фактических параметров.</param>
/// <param name="formalparams">Список формальных параметров.</param>
/// <param name="is_alone_method_defined">Для единственного метода у которого типы параметров совпадают, но в качестве var параметра мы передаем константное значение мы можем сгенерировать более подробное сообщение об ошибке.</param>
/// <returns>Список преобразований типов.</returns>
internal possible_type_convertions_list get_conversions(expressions_list factparams,
parameter_list formalparams,bool is_alone_method_defined, location locg)
{
//TODO:Явно указывать capacity при создании.
possible_type_convertions_list tc = new possible_type_convertions_list();
possible_type_convertions ptc;
if (factparams.Count>formalparams.Count)
{
if ( (formalparams.Count==0) || (!(formalparams[formalparams.Count-1].is_params)) )
{
return null;
}
}
type_node for_par_type = null;
array_internal_interface aii=null;
if (formalparams.Count > 0)
{
parameter pr=formalparams[formalparams.Count - 1];
if (pr.is_params &&
//это для возможности вызова сразу с массивом[], типа просто не обращаем внимаение на params
!(factparams.Count == formalparams.Count && factparams[factparams.Count - 1].type == formalparams[formalparams.Count - 1].type))
{
//TODO: Добавить проверку на правильность.
aii = (array_internal_interface)
pr.type.get_internal_interface(internal_interface_kind.unsized_array_interface);
for_par_type = aii.element_type;
tc.snl = new statement_node_list();
location loc=null;
if (factparams.Count > 0) loc = factparams[factparams.Count-1].location;
//var_definition_node vdn=syntax_tree_visitor.context.add_var_definition_in_entry_scope(get_temp_arr_name(),loc);
var_definition_node vdn = null;
if (syntax_tree_visitor.context.converted_func_stack.size > 0)
{
common_function_node cfn = syntax_tree_visitor.context.converted_func_stack.first();
if (cfn.is_generic_function)
{
vdn = syntax_tree_visitor.context.add_var_definition(get_temp_arr_name(), loc);
}
else
vdn = syntax_tree_visitor.context.add_var_definition_in_entry_scope(get_temp_arr_name(), loc);
}
else if (syntax_tree_visitor.context.converted_type != null)
vdn = syntax_tree_visitor.context.add_field(get_temp_arr_name(), loc, pr.type, polymorphic_state.ps_static);
else
vdn = syntax_tree_visitor.context.add_var_definition_in_entry_scope(get_temp_arr_name(), loc);
syntax_tree_visitor.context.close_var_definition_list(pr.type,null);
expression_node fst=null;
/*switch (syntax_tree_visitor.context.converting_block())
{
case block_type.function_block:
{
fst=new local_variable_reference((local_variable)vdn,0,loc);
break;
}
case block_type.namespace_block:
{
fst=new namespace_variable_reference((namespace_variable)vdn,loc);
break;
}
}*/
switch (vdn.semantic_node_type)
{
case semantic_node_type.local_variable:
{
fst = new local_variable_reference((local_variable)vdn, 0, loc);
break;
}
case semantic_node_type.namespace_variable:
{
fst = new namespace_variable_reference((namespace_variable)vdn, loc);
break;
}
case semantic_node_type.local_block_variable:
{
fst = new local_block_variable_reference((local_block_variable)vdn, loc);
break;
}
case semantic_node_type.class_field:
{
class_field cf = vdn as class_field;
cf.polymorphic_state = polymorphic_state.ps_static;
fst = new static_class_field_reference(cf, loc);
break;
}
default:
throw new CompilerInternalError("Invalid node type");
//.........这里部分代码省略.........
示例12: create_full_function_call
/// <summary>
/// Этот метод вызывается если мы встречаем простой вызов функии, например f(1).
/// Он определяет является ли эта функция методом класса, вложенной функцией и т.д. и создает соответствующее обращение.
/// Например, для метода класса он добавляет this, а для вложенной функции вычисляет статическую глубину.
/// </summary>
/// <param name="exprs">Список параметров.</param>
/// <param name="si">Список методов.</param>
/// <param name="loc">Расположение вызова.</param>
/// <param name="converted_type">Тип в котором мы находимся. null, если мы вне типа.</param>
/// <param name="top_function">Функция в которой мы находимся.</param>
/// <param name="allow_procedure">Может ли это быть вызов процедуры. false если вызов стоит в выражении или правой части опреатора присваивания.</param>
/// <returns>Возвращает узел вызова метода.</returns>
public expression_node create_full_function_call(expressions_list exprs,SymbolInfo si,location loc,
common_type_node converted_type,common_function_node top_function,bool allow_procedure)
{
function_node fn=select_function(exprs,si,loc);
/*
if (fn.compile_time_executor != null)
{
expression_node ex = fn.compile_time_executor(loc, exprs.ToArray());
if (ex != null)
{
return ex;
}
}
*/
//allow_procedure = true;
if ((!allow_procedure)&&(fn.return_value_type==null))
{
throw new SimpleSemanticError(loc, "FUNCTION_EXPECTED_PROCEDURE_{0}_MEET", fn.name);
}
expression_node expr_node=null;
switch (fn.semantic_node_type)
{
case semantic_node_type.basic_function_node:
case semantic_node_type.common_namespace_function_node:
{
expr_node=create_simple_function_call(fn,loc,exprs.ToArray());
break;
}
case semantic_node_type.common_method_node:
case semantic_node_type.compiled_function_node:
{
SemanticTree.IClassMemberNode icmn=(SemanticTree.IClassMemberNode)fn;
if (icmn.polymorphic_state==SemanticTree.polymorphic_state.ps_static)
{
expr_node=create_simple_function_call(fn,loc,exprs.ToArray());
break;
}
//expression_node tn = new this_node(converted_type,loc);
base_function_call cmc=null;
switch (fn.semantic_node_type)
{
case semantic_node_type.common_method_node:
{
//ssyy добавил
if (((common_method_node)fn).is_constructor)
{
common_constructor_call ccc = new common_constructor_call((common_method_node)fn, loc);
//(ssyy) По-видимому, здесь всегда можно присваивать false, так как при создании нового объекта мы сюда не заходим...
ccc._new_obj_awaited = false;
if (!syntax_tree_visitor.context.allow_inherited_ctor_call)
{
throw new SimpleSemanticError(loc, "INHERITED_CONSTRUCTOR_CALL_MUST_BE_FIRST");
}
cmc = ccc;
}
else
//\ssyy
{
cmc = new common_method_call((common_method_node)fn, syntax_tree_visitor.GetCurrentObjectReference(((common_method_node)fn).cont_type.Scope, fn, loc), loc);
(cmc as common_method_call).virtual_call = !syntax_tree_visitor.inherited_ident_processing;
}
break;
}
case semantic_node_type.compiled_function_node:
{
cmc = new compiled_function_call((compiled_function_node)fn, syntax_tree_visitor.GetCurrentObjectReference(((compiled_function_node)fn).cont_type.Scope, fn, loc), loc);
(cmc as compiled_function_call).virtual_call = !syntax_tree_visitor.inherited_ident_processing;
break;
}
}
cmc.parameters.AddRange(exprs);
expr_node=cmc;
break;
}
case semantic_node_type.common_in_function_function_node:
{
common_in_function_function_node cffn=(common_in_function_function_node)fn;
common_in_function_function_call cffc=new common_in_function_function_call(cffn,
symtab.GetRelativeScopeDepth(cffn.function.scope,top_function.scope),loc);
cffc.parameters.AddRange(exprs);
expr_node=cffc;
break;
}
//ssyy добавил
case semantic_node_type.compiled_constructor_node:
{
//.........这里部分代码省略.........
示例13: select_function
//Первый параметр - выходной. Он содержит выражения с необходимыми преобразованиями типов.
public function_node select_function(expressions_list parameters, SymbolInfo functions, location loc, List<SyntaxTree.expression> syntax_nodes_parameters = null)
{
if (functions==null)
{
AddError(new NoFunctionWithThisName(loc));
}
function_node_list set_of_possible_functions = new function_node_list();
bool is_alone_method_defined = (functions.Next == null);
function_node first_function = functions.sym_info as function_node;
bool _is_assigment = first_function.name == compiler_string_consts.assign_name;
basic_function_node _tmp_bfn = functions.sym_info as basic_function_node;
List<function_node> indefinits = new List<function_node>();
while(functions!=null)
{
#if (DEBUG)
if (functions.sym_info.general_node_type!=general_node_type.function_node && functions.sym_info.general_node_type != general_node_type.property_node)
{
throw new CompilerInternalError("Function name is used to define another kind of object.");
}
#endif
function_node fn = null;
if (functions.sym_info.general_node_type == general_node_type.property_node)
{
fn = (functions.sym_info as property_node).get_function;
}
else
fn=(function_node)functions.sym_info;
if (fn.node_kind == node_kind.indefinite)
{
indefinits.Add(fn);
}
else if (fn.node_kind==SemanticTree.node_kind.common)
{
common_function_node cfn=(common_function_node)fn;
if ((parameters.Count>=cfn.parameters.Count-cfn.num_of_default_variables)&&
(parameters.Count<=cfn.parameters.Count) || parameters.Count == 0 && cfn.parameters.Count == 1 && cfn.parameters[0].is_params)
{
if (is_exist_eq_method_in_list(fn,set_of_possible_functions) != null)
{
//!!!!!!!!!!!!!
//DS TODO
//Это нужно чтобы была возможность создавать операторы = := ..., т.к. всегда они добавляюся автоматом
//Надо сначало просматривать заголовки и добавлять такие операторы только если нужно.
if (set_of_possible_functions.Count > 0)
if (set_of_possible_functions[0] is basic_function_node)
{
set_of_possible_functions.remove(set_of_possible_functions[0]);
set_of_possible_functions.AddElement(fn);
}
//!!!!!!!!!!!!!
functions=functions.Next;
continue;
}
set_of_possible_functions.AddElement(fn);
}
}
else
{
//TODO: Здесь нужно поправить, если создавать возможность вызова метода с параметрами по умолчанию из откомпилированной dll.
if (parameters.Count==fn.parameters.Count)
{
function_node func = null;
if ((func=is_exist_eq_method_in_list(fn,set_of_possible_functions)) != null)
{
if (!eq_type_nodes(fn.return_value_type, func.return_value_type))
{
set_of_possible_functions[set_of_possible_functions.IndexOf(func)] = fn;
}
functions = functions.Next;
continue;
}
set_of_possible_functions.AddElement(fn);
}
}
if (parameters.Count > fn.parameters.Count)
{
if (fn.parameters.Count > 0)
{
if ((fn.parameters[fn.parameters.Count - 1]).is_params)
{
//+DS ms0105
if (is_exist_eq_method_in_list(fn, set_of_possible_functions) != null)
{
functions = functions.Next;
continue;
}
//-DS
set_of_possible_functions.AddElement(fn);
}
}
}
else if ((parameters.Count == 0 && fn.parameters.Count == 1) && fn.parameters[0].is_params && !set_of_possible_functions.Contains(fn))
//.........这里部分代码省略.........
示例14: add_set_initializer
private void add_set_initializer(expression_node cnfc, expressions_list exprs)
{
set_intls[cnfc] = exprs;
}
示例15: create_constructor_call
private base_function_call create_constructor_call(type_node tn, expressions_list exprs, location loc, Tuple<bool, List<SyntaxTree.expression>> lambdas_info = null)
{
if (tn.IsInterface)
{
AddError(loc, "INTERFACE_{0}_CONSTRUCTOR_CALL", tn.name);
}
if (tn.IsAbstract)
{
AddError(loc, "ABSTRACT_CONSTRUCTOR_{0}_CALL", tn.name);
}
SymbolInfo si = tn.find_in_type(TreeConverter.compiler_string_consts.default_constructor_name, context.CurrentScope); //tn.Scope);
delete_inherited_constructors(ref si, tn);
if (si == null)
AddError(loc, "CONSTRUCTOR_NOT_FOUND");
function_node fnn = null;
try
{
#region Если встретились лямбды в фактических параметрах, то выбираем нужную функцию из перегруженных, выводим типы, отмечаем флаг в лямбдах, говорящий о том, что мы их реально обходим
//lroman//
if (lambdas_info != null && lambdas_info.Item1)
{
LambdaHelper.processingLambdaParametersForTypeInference++;
var syntax_nodes_parameters = lambdas_info.Item2;
// SSM 21.05.14 - попытка обработать перегруженные функции с параметрами-лямбдами с различными возвращаемыми значениями
function_node_list spf = null;
try
{
function_node fn = convertion_data_and_alghoritms.select_function(exprs, si, loc,
syntax_nodes_parameters);
int exprCounter = 0;
foreach (SyntaxTree.expression en in syntax_nodes_parameters)
{
if (!(en is SyntaxTree.function_lambda_definition))
{
exprCounter++;
continue;
}
else
{
var enLambda = (SyntaxTree.function_lambda_definition)en;
LambdaHelper.InferTypesFromVarStmt(fn.parameters[exprCounter].type, enLambda, this);
enLambda.lambda_visit_mode = LambdaVisitMode.VisitForAdvancedMethodCallProcessing;
exprs[exprCounter] = convert_strong(en);
enLambda.lambda_visit_mode = LambdaVisitMode.VisitForInitialMethodCallProcessing;
exprCounter++;
}
}
}
catch (SeveralFunctionsCanBeCalled sf)
{
spf = sf.set_of_possible_functions;
// Возможны несколько перегруженных версий - надо выводить дальше в надежде что какие-то уйдут и останется одна
}
Exception lastmultex = null;
if (spf != null) // пытаемся инстанцировать одну за другой и ошибки гасим try
{
// exprs - глобальная, поэтому надо копировать
int spfnum = -1; // spfnum - первый номер правильно инстанцированной. Пока -1. Если потом встретился второй, то тоже ошибка
int GoodVersionsCount = 0;
int GoodVersionsCountWithSameResType = 0;
for (int i = 0; i < spf.Count; i++)
{
function_node fn = spf[i];
try
{
int exprCounter = 0;
expressions_list exprs1 = new expressions_list();
exprs1.AddRange(exprs); // сделали копию
foreach (SyntaxTree.expression en in syntax_nodes_parameters)
{
if (!(en is SyntaxTree.function_lambda_definition))
{
exprCounter++;
continue;
}
else
{
var fld = en as SyntaxTree.function_lambda_definition;
var lambdaName = fld.lambda_name; //lroman Сохранять имя необходимо
var fl = fld.lambda_visit_mode;
// запомнили типы параметров лямбды - SSM
object[] realparamstype = new object[fld.formal_parameters.params_list.Count];
// здесь хранятся выведенные типы лямбд или null если типы явно заданы
for (var k = 0; k < fld.formal_parameters.params_list.Count; k++)
{
var laminftypeK =
fld.formal_parameters.params_list[k].vars_type as
SyntaxTree.lambda_inferred_type;
if (laminftypeK == null)
realparamstype[k] = null;
else realparamstype[k] = laminftypeK.real_type;
}
// запоминаем реальный тип возвращаемого значения если он не указан явно (это должен быть any_type или null если он указан явно) - он может измениться при следующем вызове, поэтому мы его восстановим
var restype = fld.return_type as SyntaxTree.lambda_inferred_type;
//.........这里部分代码省略.........