Beispiel #1
0
 private void VisitRecordInitializer(record_initializer en)
 {
 	foreach (expression_node expr in en.field_values)
 		VisitExpression(expr);
 }
		private void VisitRecordInitializer(record_initializer expr)
		{
			bw.Write(expr.field_values.Count);
			foreach (expression_node en in expr.field_values)
				VisitExpression(en);
			WriteTypeReference(expr.type);
		}
 private record_initializer ConvertRecordInitializer(common_type_node ctn, record_initializer constant)
 {
 	location loc = constant.location;
     if (!ctn.is_value_type)
         AddError(loc, "RECORD_CONST_NOT_ALLOWED_{0}", ctn.name);
     if (ctn.fields.Count != constant.record_const_definition_list.Count)
         AddError(loc, "INVALID_RECORD_CONST_FIELD_COUNT");
     constant.type = ctn;
     constant.field_values.Clear();
     for (int i = 0; i < ctn.fields.Count; i++)
     {
         class_field cf = ctn.fields[i];
         if (cf.name.ToLower() != constant.record_const_definition_list[i].name.name.ToLower())
             AddError(get_location(constant.record_const_definition_list[i].name), "FIELD_NAME_SHOULD_BE_EQUAL_RECORD_FIELD_NAME", cf.name);
         expression_node en = convert_strong_to_constant_or_function_call_for_varinit(convert_strong(constant.record_const_definition_list[i].val),cf.type);
         en.type = cf.type;
         constant.field_values.Add(en);
     }
     return constant;
 }
 public override void visit(SyntaxTree.record_const node)
 {
 	if (is_typed_const_def)
 	{
 		record_constant rc = new record_constant(node.rec_consts, get_location(node));
     	rc.SetType(new RecordConstType(rc.location));
     	return_value(rc);
 	}
 	else
 	{
 		record_initializer ri = new record_initializer(node.rec_consts, get_location(node));
 		ri.type = new RecordConstType(ri.location);
 		return_value(ri);
 	}
 }
 private record_initializer CreateRecordInitializer()
 {
 	List<expression_node> element_values = new List<expression_node>();
     int count = br.ReadInt32();
     for (int i = 0; i < count; i++)
         element_values.Add(CreateExpression());
     record_initializer rec = new record_initializer(element_values, null);
     rec.type = GetTypeReference();
     return rec;
 }