Exemplo n.º 1
0
        //добавление локальной переменной
        public VarInfo AddVariable(IVAriableDefinitionNode var, LocalBuilder lb)
        {
            VarInfo vi = new VarInfo(lb);

            defs[var] = vi;
            return(vi);
        }
Exemplo n.º 2
0
        //добавление нелок. переменной
        public VarInfo AddNonLocalVariable(IVAriableDefinitionNode var, FieldBuilder fb)
        {
            VarInfo vi = new VarInfo();

            defs[var] = vi;
            vi.fb     = fb;
            vi.kind   = VarKind.vkNonLocal;
            return(vi);
        }
Exemplo n.º 3
0
        //\ssyy

        //получение локальной переменной
        public VarInfo GetVariable(IVAriableDefinitionNode var)
        {
            return((VarInfo)defs[var]);
        }
 public virtual void visit(IVAriableDefinitionNode value)
 {
 }
Exemplo n.º 5
0
        //\ssyy
		
        //получение локальной переменной
		public VarInfo GetVariable(IVAriableDefinitionNode var)
		{
			return (VarInfo)defs[var];
		}
Exemplo n.º 6
0
        //добавление нелок. переменной
		public VarInfo AddNonLocalVariable(IVAriableDefinitionNode var, FieldBuilder fb)
		{
			VarInfo vi = new VarInfo();
			defs[var] = vi;
			vi.fb = fb;
			vi.kind = VarKind.vkNonLocal;
			return vi;
		}
Exemplo n.º 7
0
        //private void GenerateInit

        private void GenerateInitCode(IVAriableDefinitionNode var, ILGenerator ilg)
        {
            ILGenerator ilgn = il;
            IExpressionNode expr = var.inital_value;
            il = ilg;
            if (expr != null && save_debug_info && comp_opt.GenerateDebugInfoForInitalValue)
            {
                if (expr.Location != null && !(expr is IConstantNode) && !(expr is IArrayInitializer) && !(expr is IRecordInitializer))
                    MarkSequencePoint(expr.Location);
            }
            if (expr != null && !(expr is IConstantNode) && !(expr is IArrayInitializer))
            {
                expr.visit(this);
            }
            il = ilgn;
        }
Exemplo n.º 8
0
        //добавление локальной переменной
		public VarInfo AddVariable(IVAriableDefinitionNode var, LocalBuilder lb)
		{
			VarInfo vi = new VarInfo(lb);
			defs[var] = vi;
			return vi;
		}
Exemplo n.º 9
0
 //создание локальной переменной
 private void ConvertLocalVariable(IVAriableDefinitionNode var, bool add_line_info, int beg_line, int end_line)
 {
     TypeInfo ti = helper.GetTypeReference(var.type);
     bool pinned = false;
     if (ti.tp.IsPointer) pinned = true;
     LocalBuilder lb = il.DeclareLocal(ti.tp, pinned);
     //если модуль отладочный, задаем имя переменной
     if (save_debug_info)
         if (add_line_info)
             lb.SetLocalSymInfo(var.name + ":" + beg_line + ":" + end_line);
         else
             lb.SetLocalSymInfo(var.name);
     helper.AddVariable(var, lb);//добавляем переменную
     if (var.type.is_generic_parameter && var.inital_value == null)
     {
         CreateRuntimeInitCodeWithCheck(il, lb, var.type as ICommonTypeNode);
     }
     if (ti.is_arr)
     {
         if (var.inital_value == null || var.inital_value is IArrayConstantNode)
             CreateArrayLocalVariable(il, lb, ti, var.inital_value as IArrayConstantNode, var.type);
         else if (var.inital_value is IArrayInitializer)
             CreateArrayLocalVariable(il, lb, ti, var.inital_value as IArrayInitializer, var.type);
     }
     else if (var.inital_value is IArrayConstantNode)
         CreateArrayLocalVariable(il, lb, ti, var.inital_value as IArrayConstantNode, var.type);
     else if (var.inital_value is IArrayInitializer)
         CreateArrayLocalVariable(il, lb, 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(lb, ti.init_meth, var.inital_value as IConstantNode, var.type);
     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.Stloc, lb);
     }
     in_var_init = true;
     GenerateInitCode(var, il);
     in_var_init = false;
 }
Exemplo n.º 10
0
 private FieldInfo[] get_named_fields(IVAriableDefinitionNode[] fields)
 {
     FieldInfo[] arr = new FieldInfo[fields.Length];
     for (int i = 0; i < arr.Length; i++)
     {
         if (fields[i] is ICompiledClassFieldNode)
             arr[i] = (fields[i] as ICompiledClassFieldNode).compiled_field;
         else
             arr[i] = helper.GetField(fields[i] as ICommonClassFieldNode).fi;
     }
     return arr;
 }
Exemplo n.º 11
0
 public void visit(IVAriableDefinitionNode value)
 {
     string s = value.GetType().Name + ".";
     prepare_string_node(value.name, s + "name");
     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.º 12
0
		public virtual void visit(IVAriableDefinitionNode value)
		{
		}
Exemplo n.º 13
0
 public void visit(IVAriableDefinitionNode value)
 {
     throw new System.NotSupportedException(value.GetType().ToString());
 }