当前位置: 首页>>代码示例>>C#>>正文


C# Ast.PrimitiveExpression类代码示例

本文整理汇总了C#中ICSharpCode.NRefactory.Ast.PrimitiveExpression的典型用法代码示例。如果您正苦于以下问题:C# PrimitiveExpression类的具体用法?C# PrimitiveExpression怎么用?C# PrimitiveExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PrimitiveExpression类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了PrimitiveExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VisitPrimitiveExpression

		public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
		{
			if (primitiveExpression.Value is bool)
				return (bool)primitiveExpression.Value ? SymbolDefined : null;
			else
				return null;
		}
开发者ID:transformersprimeabcxyz,项目名称:monodevelop-1,代码行数:7,代码来源:ConditionalCompilation.cs

示例2: VisitPrimitiveExpression

		public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
		{
			if (primitiveExpression.Value == null) {
				return NullReturnType.Instance;
			} else {
				return resolver.ProjectContent.SystemTypes.CreatePrimitive(primitiveExpression.Value.GetType());
			}
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:8,代码来源:TypeVisitor.cs

示例3: VisitPrimitiveExpression

		public object VisitPrimitiveExpression(PrimitiveExpression pe, object data)
		{
			object val = pe.Value;
			if (val == null) {
				return new B.NullLiteralExpression(GetLexicalInfo(pe));
			}
			if (val is string) {
				return new B.StringLiteralExpression(GetLexicalInfo(pe), (string)val);
			}
			if (val is char) {
				return new B.CharLiteralExpression(GetLexicalInfo(pe), ((char)val).ToString());
			}
			if (val is bool) {
				return new B.BoolLiteralExpression(GetLexicalInfo(pe), (bool)val);
			}
			if (val is byte) {
				AddWarning(pe, "Converting byte literal to int literal");
				return new B.IntegerLiteralExpression(GetLexicalInfo(pe), (byte)val, false);
			}
			if (val is short) {
				AddWarning(pe, "Converting short literal to int literal");
				return new B.IntegerLiteralExpression(GetLexicalInfo(pe), (short)val, false);
			}
			if (val is int) {
				return new B.IntegerLiteralExpression(GetLexicalInfo(pe), (int)val, false);
			}
			if (val is long) {
				return new B.IntegerLiteralExpression(GetLexicalInfo(pe), (long)val, true);
			}
			if (val is sbyte) {
				AddWarning(pe, "Converting sbyte literal to int literal");
				return new B.IntegerLiteralExpression(GetLexicalInfo(pe), (sbyte)val, false);
			}
			if (val is ushort) {
				AddWarning(pe, "Converting ushort literal to int literal");
				return new B.IntegerLiteralExpression(GetLexicalInfo(pe), (ushort)val, false);
			}
			if (val is uint) {
				AddWarning(pe, "Converting uint literal to int/long literal");
				return new B.IntegerLiteralExpression(GetLexicalInfo(pe), (uint)val);
			}
			if (val is ulong) {
				AddWarning(pe, "Converting ulong literal to long literal");
				return new B.IntegerLiteralExpression(GetLexicalInfo(pe), (long)((ulong)val), true);
			}
			if (val is float) {
				return new B.DoubleLiteralExpression(GetLexicalInfo(pe), (float)val, true);
			}
			if (val is double) {
				return new B.DoubleLiteralExpression(GetLexicalInfo(pe), (double)val, false);
			}
			if (val is decimal) {
				AddWarning(pe, "Converting decimal literal to double literal");
				return new B.DoubleLiteralExpression(GetLexicalInfo(pe), (double)(decimal)val);
			}
			AddError(pe, "Unknown primitive literal of type " + val.GetType().FullName);
			return null;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:58,代码来源:ConvertVisitorExpressions.cs

示例4: IsMatch

 private bool IsMatch(PrimitiveExpression l, PrimitiveExpression r)
 {
     if (l.Value == null && r.Value == null)
     {
         // both null counts as a match
     }
     else if (l.Value == null || r.Value == null || !l.Value.Equals(r.Value))
     {
         // Fail if one or the other is null, or the values don't match.
         return false;
     }
     return true;
 }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:13,代码来源:AstComparisonVisitor.cs

示例5: add_Return

 public static BlockStatement add_Return(this BlockStatement blockStatement, object returnData)
 {
     if (returnData.notNull())
     {
         Expression returnStatement;
         //if (returnData is ExpressionStatement)
         //returnStatement = returnData as ExpressionStatement;
         if (returnData is Expression)
             returnStatement = (returnData as Expression);
         else
             returnStatement = new PrimitiveExpression(returnData, returnData.str());
         blockStatement.append(new ReturnStatement(returnStatement));
     }
     return blockStatement;
 }
开发者ID:pusp,项目名称:o2platform,代码行数:15,代码来源:BlockStatement_ExtensionMethod.cs

示例6: CompleteInternal

        protected void CompleteInternal(CompletionContext context, string key)
        {
            string insertString;

            if (this.outputVisitor != null) {
                PrimitiveExpression pre = new PrimitiveExpression(key, key);
                pre.AcceptVisitor(this.outputVisitor, null);
                insertString = this.outputVisitor.Text;
            } else {
                insertString = key;
            }

            context.Editor.Document.Replace(context.StartOffset, context.Length, insertString);
            context.EndOffset = context.StartOffset + insertString.Length;
        }
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:15,代码来源:ResourceCodeCompletionItem.cs

示例7: GenerateCode

		protected override string GenerateCode(LanguageProperties language, IClass currentClass)
		{
			string[] fields = listBox.SelectedItems.OfType<PropertyOrFieldWrapper>().Select(f2 => f2.MemberName).ToArray();
			
			Ast.PrimitiveExpression formatString = new Ast.PrimitiveExpression(GenerateFormatString(currentClass, language.CodeGenerator, fields));
			List<Ast.Expression> param = new List<Ast.Expression>() { formatString };
			
			Ast.ReturnStatement ret = new Ast.ReturnStatement(new Ast.InvocationExpression(
				new Ast.MemberReferenceExpression(new Ast.TypeReferenceExpression(new Ast.TypeReference("System.String", true)), "Format"),
				param.Concat(fields.Select(f => new Ast.IdentifierExpression(f))).ToList()
			));
			
			insertedCode = language.CodeGenerator.GenerateCode(ret, "").Trim();
			
			return insertedCode;
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:16,代码来源:OverrideToStringMethodDialog.xaml.cs

示例8: add_Return

        public static BlockStatement add_Return(this BlockStatement blockStatement, object returnData)
        {
			Expression returnStatement;
			if (returnData.isNull())
				returnStatement = new PrimitiveExpression(null);
			else
			{
				if (returnData is Expression)
					returnStatement = (returnData as Expression);
				else
					returnStatement = new PrimitiveExpression(returnData, returnData.str());

			}
			blockStatement.append(new ReturnStatement(returnStatement));
            return blockStatement;
        }
开发者ID:SiGhTfOrbACQ,项目名称:O2.Platform.Projects,代码行数:16,代码来源:BlockStatement_ExtensionMethod.cs

示例9: InsertAction

		/// <summary>
		/// Insert the element represented by the completion data into the text
		/// editor.
		/// </summary>
		/// <param name="textArea">TextArea to insert the completion data in.</param>
		/// <param name="ch">Character that should be inserted after the completion data.
		/// \0 when no character should be inserted.</param>
		/// <returns>Returns true when the insert action has processed the character
		/// <paramref name="ch"/>; false when the character was not processed.</returns>
		public override bool InsertAction(TextArea textArea, char ch)
		{
			string insertString;
			
			if (this.outputVisitor != null) {
				PrimitiveExpression pre = new PrimitiveExpression(this.Text, this.Text);
				pre.AcceptVisitor(this.outputVisitor, null);
				insertString = this.outputVisitor.Text;
			} else {
				insertString = this.Text;
			}
			
			textArea.InsertString(insertString);
			if (ch == insertString[insertString.Length - 1]) {
				return true;
			}
			return false;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:27,代码来源:ResourceCodeCompletionData.cs

示例10: SimpleNonInvocationExpression

	void SimpleNonInvocationExpression(
#line  1593 "VBNET.ATG" 
out Expression pexpr) {

#line  1595 "VBNET.ATG" 
		Expression expr;
		TypeReference type = null;
		string name = String.Empty;
		pexpr = null;
		
		if (StartOf(29)) {
			switch (la.kind) {
			case 3: {
				lexer.NextToken();

#line  1603 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val);  
				break;
			}
			case 4: {
				lexer.NextToken();

#line  1604 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val);  
				break;
			}
			case 7: {
				lexer.NextToken();

#line  1605 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val);  
				break;
			}
			case 6: {
				lexer.NextToken();

#line  1606 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val);  
				break;
			}
			case 5: {
				lexer.NextToken();

#line  1607 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val);  
				break;
			}
			case 9: {
				lexer.NextToken();

#line  1608 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val);  
				break;
			}
			case 8: {
				lexer.NextToken();

#line  1609 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val);  
				break;
			}
			case 173: {
				lexer.NextToken();

#line  1611 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(true, "true");  
				break;
			}
			case 96: {
				lexer.NextToken();

#line  1612 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(false, "false"); 
				break;
			}
			case 130: {
				lexer.NextToken();

#line  1613 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(null, "null");  
				break;
			}
			case 24: {
				lexer.NextToken();
				Expr(
#line  1614 "VBNET.ATG" 
out expr);
				Expect(25);

#line  1614 "VBNET.ATG" 
				pexpr = new ParenthesizedExpression(expr); 
				break;
			}
			case 2: case 47: case 49: case 50: case 51: case 70: case 95: case 134: case 144: case 169: case 176: case 177: case 205: {
				Identifier();

#line  1616 "VBNET.ATG" 
				pexpr = new IdentifierExpression(t.val); 

#line  1617 "VBNET.ATG" 
//.........这里部分代码省略.........
开发者ID:almazik,项目名称:ILSpy,代码行数:101,代码来源:Parser.cs

示例11: VisitPrimitiveExpression

		public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
		{
			if (primitiveExpression.Value == null) 
				return CreateResult ("");
			Type type = primitiveExpression.Value.GetType();
			return CreateResult (type.FullName);
		}
开发者ID:Ein,项目名称:monodevelop,代码行数:7,代码来源:ResolveVisitor.cs

示例12: VisitPrimitiveExpression

 public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
 {
     return new CodePrimitiveExpression(primitiveExpression.Value);
 }
开发者ID:almazik,项目名称:ILSpy,代码行数:4,代码来源:CodeDOMOutputVisitor.cs

示例13: VisitPrimitiveExpression

 public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
 {
     foreach (var r in Replacements)
     {
         if (ReferenceEquals(primitiveExpression, r.Target))
         {
             ReplaceCurrentNode(r.Replacement);
         }
     }
     return base.VisitPrimitiveExpression(primitiveExpression, data);
 }
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:11,代码来源:LiteralToParameterExpansion.cs

示例14: SimpleNonInvocationExpression

	void SimpleNonInvocationExpression(
#line  1730 "VBNET.ATG" 
out Expression pexpr) {

#line  1732 "VBNET.ATG" 
		Expression expr;
		CollectionInitializerExpression cie;
		TypeReference type = null;
		string name = String.Empty;
		Location startLocation = la.Location;
		pexpr = null;
		
		if (StartOf(35)) {
			switch (la.kind) {
			case 3: {
				lexer.NextToken();

#line  1742 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 4: {
				lexer.NextToken();

#line  1743 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 7: {
				lexer.NextToken();

#line  1744 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 6: {
				lexer.NextToken();

#line  1745 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 5: {
				lexer.NextToken();

#line  1746 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 9: {
				lexer.NextToken();

#line  1747 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 8: {
				lexer.NextToken();

#line  1748 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(t.literalValue, t.val) { LiteralFormat = t.literalFormat };  
				break;
			}
			case 220: {
				lexer.NextToken();

#line  1750 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(true, "true");  
				break;
			}
			case 124: {
				lexer.NextToken();

#line  1751 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(false, "false"); 
				break;
			}
			case 168: {
				lexer.NextToken();

#line  1752 "VBNET.ATG" 
				pexpr = new PrimitiveExpression(null, "null");  
				break;
			}
			case 37: {
				lexer.NextToken();
				Expr(
#line  1753 "VBNET.ATG" 
out expr);
				Expect(38);

#line  1753 "VBNET.ATG" 
				pexpr = new ParenthesizedExpression(expr); 
				break;
			}
			case 2: case 58: case 62: case 64: case 65: case 66: case 67: case 68: case 69: case 72: case 89: case 100: case 106: case 109: case 118: case 123: case 128: case 135: case 141: case 145: case 148: case 149: case 150: case 173: case 179: case 181: case 187: case 206: case 215: case 216: case 226: case 227: case 233: case 240: {
				Identifier();

#line  1755 "VBNET.ATG" 
				pexpr = new IdentifierExpression(t.val);
//.........这里部分代码省略.........
开发者ID:BooMWax,项目名称:SharpDevelop,代码行数:101,代码来源:Parser.cs

示例15: VisitPrimitiveExpression

		public override object VisitPrimitiveExpression(PrimitiveExpression primitiveExpression, object data)
		{
			if (primitiveExpression.Value == null) {
				return CreateResolveResult(NullReturnType.Instance);
			} else if (primitiveExpression.Value is int) {
				return new IntegerLiteralResolveResult(resolver.CallingClass, resolver.CallingMember, resolver.ProjectContent.SystemTypes.Int32);
			} else {
				return CreateResolveResult(resolver.ProjectContent.SystemTypes.CreatePrimitive(primitiveExpression.Value.GetType()));
			}
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:10,代码来源:ResolveVisitor.cs


注:本文中的ICSharpCode.NRefactory.Ast.PrimitiveExpression类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。