Wrap always_inline and noinline attributes in compiler checks and use MSVC equivalent.
[mono.git] / mcs / class / Microsoft.Build.Engine / Microsoft.Build.BuildEngine / ItemReference.cs
1 //
2 // ItemReference.cs: Represents "@(Reference)" in expression.
3 //
4 // Author:
5 //   Marek Sieradzki (marek.sieradzki@gmail.com)
6 //   Ankit Jain (jankit@novell.com)
7 // 
8 // (C) 2005 Marek Sieradzki
9 // Copyright 2009 Novell, Inc (http://www.novell.com)
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 #if NET_2_0
31
32 using System;
33 using System.Collections;
34 using Microsoft.Build.Framework;
35
36 namespace Microsoft.Build.BuildEngine {
37         internal class ItemReference : IReference {
38         
39                 string          itemName;
40                 Expression      transform;
41                 Expression      separator;
42                 int             start;
43                 int             length;
44                 string          original_string;
45                 
46                 public ItemReference (string original_string, string itemName, string transform, string separator, int start, int length)
47                 {
48                         this.itemName = itemName;
49                         this.start = start;
50                         this.length = length;
51                         this.original_string = original_string;
52
53                         // Transform and separator are never expanded for item refs
54                         if (transform != null) {
55                                 this.transform = new Expression ();
56                                 this.transform.Parse (transform, ParseOptions.AllowMetadata | ParseOptions.Split);
57                         }
58
59                         if (separator != null) {
60                                 this.separator = new Expression ();
61                                 this.separator.Parse (separator, ParseOptions.Split);
62                         }
63                 }
64                 
65                 // when evaluating property, allowItems=false, so,
66                 // ItemRef will _not_ get created, so this wont get hit
67                 // when evaluating items, expand: true
68                 // other cases, expand: true
69                 public string ConvertToString (Project project, ExpressionOptions options)
70                 {
71                         BuildItemGroup group;
72                         if (project.TryGetEvaluatedItemByNameBatched (itemName, out group))
73                                 return group.ConvertToString (transform, separator, options);
74                         else
75                                 return String.Empty;
76                 }
77                 
78                 public ITaskItem [] ConvertToITaskItemArray (Project project, ExpressionOptions options)
79                 {
80                         BuildItemGroup group;
81                         if (project.TryGetEvaluatedItemByNameBatched (itemName, out group))
82                                 return group.ConvertToITaskItemArray (transform, separator, options);
83                         else
84                                 return null;
85                 }
86
87                 public string ItemName {
88                         get { return itemName; }
89                 }
90
91                 public Expression Transform {
92                         get { return transform; }
93                 }
94
95                 public Expression Separator {
96                         get { return separator; }
97                 }
98
99                 public string OriginalString {
100                         get { return original_string; }
101                 }
102
103                 public int Start {
104                         get { return start; }
105                 }
106
107                 public int End {
108                         get { return start + length - 1; }
109                 }
110
111                 public override string ToString ()
112                 {
113                         return original_string;
114                 }
115         }
116 }
117
118 #endif