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


C# ParseTree.GetAnnotation方法代码示例

本文整理汇总了C#中ParseTree.GetAnnotation方法的典型用法代码示例。如果您正苦于以下问题:C# ParseTree.GetAnnotation方法的具体用法?C# ParseTree.GetAnnotation怎么用?C# ParseTree.GetAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParseTree的用法示例。


在下文中一共展示了ParseTree.GetAnnotation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TranslateFunctionDefinition

		protected override void TranslateFunctionDefinition(List<string> output, ParseTree.FunctionDefinition functionDef)
		{
			output.Add(this.CurrentTabIndention);

			string returnType = "void*";
			Annotation returnTypeAnnotation = functionDef.GetAnnotation("type");
			if (returnTypeAnnotation != null)
			{
				returnType = this.CPlatform.GetTypeStringFromAnnotation(new AnnotatedType(returnTypeAnnotation), false, true);
			}
			output.Add(returnType);
			output.Add(" ");
			output.Add("v_" + functionDef.NameToken.Value);
			output.Add("(");
			for (int i = 0; i < functionDef.ArgNames.Length; ++i)
			{
				if (i > 0) output.Add(", ");
				if (functionDef.ArgAnnotations[i] == null)
				{
					output.Add("object ");
				}
				else
				{
					string argType = functionDef.ArgAnnotations[i].GetSingleArgAsString(null);
					string type = this.CPlatform.GetTypeStringFromAnnotation(functionDef.ArgAnnotations[i].FirstToken, argType, false, true);
					output.Add(type);
					output.Add(" ");
				}
				output.Add("v_" + functionDef.ArgNames[i].Value);
			}
			output.Add(")");
			output.Add(this.NL);
			output.Add(this.CurrentTabIndention);
			output.Add("{");
			output.Add(this.NL);
			this.CurrentIndention++;

			Executable[] code = functionDef.Code;
			if (functionDef.GetAnnotation("omitReturn") != null)
			{
				Executable[] newCode = new Executable[code.Length - 1];
				Array.Copy(code, newCode, newCode.Length);
				code = newCode;
			}
			this.Translate(output, code);

			this.CurrentIndention--;
			output.Add(this.CurrentTabIndention);
			output.Add("}");
			//*/
			output.Add(this.NL);
		}
开发者ID:geofrey,项目名称:crayon,代码行数:52,代码来源:CTranslator.cs

示例2: TranslateFunctionDefinition

		protected override void TranslateFunctionDefinition(List<string> output, ParseTree.FunctionDefinition functionDef)
		{
			Annotation returnType = functionDef.GetAnnotation("type");
			string type = returnType == null ? "Object" : this.JavaPlatform.GetTypeStringFromString(returnType.GetSingleArgAsString(null), false, false);

			output.Add(this.CurrentTabIndention);
			output.Add("public static ");
			output.Add(type);
			output.Add(" v_");
			output.Add(functionDef.NameToken.Value);
			output.Add("(");
			for (int i = 0; i < functionDef.ArgNames.Length; ++i)
			{
				if (i > 0) {
					output.Add(", ");
				}
				Annotation annotation = functionDef.ArgAnnotations[i];
				string argType = annotation == null ? "Object" : annotation.GetSingleArgAsString(null);
				output.Add(this.JavaPlatform.GetTypeStringFromString(argType, false, false));
				output.Add(" v_");
				output.Add(functionDef.ArgNames[i].Value);
			}
			output.Add(") {");
			output.Add(this.NL);

			this.CurrentIndention++;
			Executable[] code = functionDef.Code;
			if (functionDef.GetAnnotation("omitReturn") != null)
			{
				Executable[] newCode = new Executable[code.Length - 1];
				Array.Copy(code, newCode, newCode.Length);
				code = newCode;
			}
			this.Translate(output, code);
			this.CurrentIndention--;

			output.Add(this.CurrentTabIndention);
			output.Add("}");
			output.Add(this.NL);
		}
开发者ID:geofrey,项目名称:crayon,代码行数:40,代码来源:JavaTranslator.cs


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