Exemplo n.º 1
0
 //перевод глобальной переменной (переменной модуля и основной программы)
 private void ConvertGlobalVariable(ICommonNamespaceVariableNode var)
 {
     //Console.WriteLine(is_in_unit);
     //if (is_in_unit && helper.IsUsed(var)==false) return;
     TypeInfo ti = helper.GetTypeReference(var.type);
     FieldBuilder fb = cur_type.DefineField(var.name, ti.tp, FieldAttributes.Public | FieldAttributes.Static);
     helper.AddGlobalVariable(var, fb);
     add_possible_type_attribute(fb, var.type);
     
     //если переменная имеет тип - массив, то создаем его
     if (ti.is_arr)
     {
         if (var.inital_value == null || var.inital_value is IArrayConstantNode)
             CreateArrayGlobalVariable(il, fb, ti, var.inital_value as IArrayConstantNode, var.type);
         else if (var.inital_value is IArrayInitializer)
             CreateArrayGlobalVariable(il, fb, ti, var.inital_value as IArrayInitializer, var.type);
     }
     else if (var.inital_value is IArrayConstantNode)
         CreateArrayGlobalVariable(il, fb, ti, var.inital_value as IArrayConstantNode, var.type);
     else if (var.inital_value is IArrayInitializer)
         CreateArrayGlobalVariable(il, fb, ti, var.inital_value as IArrayInitializer, var.type);
     else
         if (var.type.is_value_type || var.inital_value is IConstantNode && !(var.inital_value is INullConstantNode))
             AddInitCall(il, fb, ti.init_meth, var.inital_value as IConstantNode);
     if (ti.is_set && var.type.type_special_kind == type_special_kind.set_type && var.inital_value == null)
     {
         il.Emit(OpCodes.Ldnull);
         il.Emit(OpCodes.Ldnull);
         il.Emit(OpCodes.Newobj, ti.def_cnstr);
         il.Emit(OpCodes.Stsfld, fb);
     }
     in_var_init = true;
     GenerateInitCode(var, il);
     in_var_init = false;
 }
 public virtual void visit(ICommonNamespaceVariableNode value)
 {
 }
Exemplo n.º 3
0
        public void visit(ICommonNamespaceVariableNode value)
        {
            string s = value.GetType().Name + ".";
            prepare_string_node(value.name, s + "name");            

            prepare_up_link_node(value.comprehensive_namespace.namespace_name.ToString(), s + "comprehensive_namespace", value.comprehensive_namespace);

            myTreeNode from = treeView.SelectedNode.Nodes[treeView.SelectedNode.Nodes.Count - 1] as myTreeNode;
            myTreeNode to = table_subnodes[value.comprehensive_namespace] as myTreeNode;
            table_for_up_links.Add(from, to);

            prepare_node(value.inital_value, s + "initial_value");
            prepare_string_node(value.node_location_kind.ToString(), s + "node_location_kind");
            prepare_node(value.type, s + "type");               
        }
Exemplo n.º 4
0
 private void ConvertGlobalVariables(ICommonNamespaceVariableNode[] vars)
 {
     for (int i = 0; i < vars.Length; i++)
         ConvertGlobalVariable(vars[i]);
 }
Exemplo n.º 5
0
		public virtual void visit(ICommonNamespaceVariableNode value)
		{
		}
Exemplo n.º 6
0
 public void visit(ICommonNamespaceVariableNode value)
 {
     ISemanticNodeConverter.SourceTextBuilder.AddNodeInToStack(ISemanticNodeConverter.ConvertPABCNETNodeNamespaceVariable("namespace_var", value));
 }
Exemplo n.º 7
0
		public static string get_var_header(ICommonNamespaceVariableNode v)
		{
			StringBuilder sb = new StringBuilder();
			sb.Append("<div>");
			sb.Append(get_span_for_keyword("var")+" "+get_span_for_identifier(v.name)+": "+get_type_html_text(v.type));
			sb.Append("</div>");
			return sb.ToString();
		}
Exemplo n.º 8
0
		public static string get_var_name(ICommonNamespaceVariableNode v)
		{
			return v.comprehensive_namespace.namespace_name + "." + v.name;
		}
Exemplo n.º 9
0
		public static bool can_write(ICommonNamespaceVariableNode t)
		{
			return !(string.IsNullOrEmpty(t.Documentation) && !builder.options.ShowNoCommentedElements || t.name.Contains("$")
			        || user_doc_disabled(t.Documentation));
		}