~ubuntu-branches/ubuntu/trusty/mono-addins/trusty-proposed

« back to all changes in this revision

Viewing changes to Mono.Addins.CecilReflector/Mono.Cecil/Mono.Cecil.Cil/VariableReference.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-04-25 11:11:33 UTC
  • mfrom: (4.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110425111133-t05u5p7o5fxx70fu
Tags: 0.6-2
Upload to Unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
// Author:
5
5
//   Jb Evain (jbevain@gmail.com)
6
6
//
7
 
// (C) 2005 Jb Evain
 
7
// Copyright (c) 2008 - 2010 Jb Evain
8
8
//
9
9
// Permission is hereby granted, free of charge, to any person obtaining
10
10
// a copy of this software and associated documentation files (the
28
28
 
29
29
namespace Mono.Cecil.Cil {
30
30
 
31
 
        public abstract class VariableReference : ICodeVisitable {
 
31
        public abstract class VariableReference {
32
32
 
33
 
                string m_name;
34
 
                int m_index;
35
 
                TypeReference m_variableType;
 
33
                string name;
 
34
                internal int index = -1;
 
35
                protected TypeReference variable_type;
36
36
 
37
37
                public string Name {
38
 
                        get { return m_name; }
39
 
                        set { m_name = value; }
 
38
                        get { return name; }
 
39
                        set { name = value; }
 
40
                }
 
41
 
 
42
                public TypeReference VariableType {
 
43
                        get { return variable_type; }
 
44
                        set { variable_type = value; }
40
45
                }
41
46
 
42
47
                public int Index {
43
 
                        get { return m_index; }
44
 
                        set { m_index = value; }
45
 
                }
46
 
 
47
 
                public TypeReference VariableType {
48
 
                        get { return m_variableType; }
49
 
                        set { m_variableType = value; }
50
 
                }
51
 
 
52
 
                public VariableReference (TypeReference variableType)
53
 
                {
54
 
                        m_variableType = variableType;
55
 
                }
56
 
 
57
 
                public VariableReference (string name, int index, TypeReference variableType) : this (variableType)
58
 
                {
59
 
                        m_name = name;
60
 
                        m_index = index;
61
 
                }
 
48
                        get { return index; }
 
49
                }
 
50
 
 
51
                internal VariableReference (TypeReference variable_type)
 
52
                        : this (string.Empty, variable_type)
 
53
                {
 
54
                }
 
55
 
 
56
                internal VariableReference (string name, TypeReference variable_type)
 
57
                {
 
58
                        this.name = name;
 
59
                        this.variable_type = variable_type;
 
60
                }
 
61
 
 
62
                public abstract VariableDefinition Resolve ();
62
63
 
63
64
                public override string ToString ()
64
65
                {
65
 
                        if (m_name != null && m_name.Length > 0)
66
 
                                return m_name;
67
 
 
68
 
                        return string.Concat ("V_", m_index);
 
66
                        if (!string.IsNullOrEmpty (name))
 
67
                                return name;
 
68
 
 
69
                        if (index >= 0)
 
70
                                return "V_" + index;
 
71
 
 
72
                        return string.Empty;
69
73
                }
70
 
 
71
 
                public abstract void Accept (ICodeVisitor visitor);
72
74
        }
73
75
}