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


C# Identifier.Add方法代码示例

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


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

示例1: Generate

		private SLE.Expression Generate(MJCP.Expression Input)
		{
			Init ();
			SLE.Expression result = null;
			if (Input == null)
				return null;
			List<SLE.Expression> arguments;
			List<SLE.Expression> initializers;
			SLE.Expression right;

			MJCP.BinaryOperatorExpression binOp;
			switch (Input.Opcode) {

				case MJCP.Expression.Operation.SyntaxError :
					return null;//sample show null
				case [email protected] :
					//TODO this must not be a variable!
					if (withinFunction > 1)//if this is call inside a function
						result = SLE.Expression.Read (builder.CreateVariable (GetSymbolId(thisIdent), SLE.Variable.VariableKind.Global, null));
					else {//if this is call ouside of function
						arguments = new List<SLE.Expression> ();
						arguments.Add (SLE.Expression.CodeContext ());
						result = SLE.Expression.Call (typeof (MJR.JSOps).GetMethod ("GetGlobalObject"), arguments.ToArray ());
					}
					break;
				case [email protected] :
					result = SLE.Expression.False ();
					break;
				case [email protected] :
					result = SLE.Expression.True ();
					break;
				case MJCP.Expression.Operation.Identifier :
						Identifier id = ((MJCP.IdentifierExpression)Input).ID;//TODO make a tree of variable and allow to get it 
						result = SLE.Expression.Read (builder.CreateVariable (GetSymbolId(id), SLE.Variable.VariableKind.Global, null));
						break;
				case MJCP.Expression.Operation.NumericLiteral :
					double val = 0;
					try {
						val = Double.Parse (((MJCP.NumericLiteralExpression)Input).Spelling);
						result = SLE.Expression.Constant (val);
					} catch {
						//TODO 
					}
					break;
				case MJCP.Expression.Operation.HexLiteral :
					result = SLE.Expression.Constant (((MJCP.HexLiteralExpression)Input).Value);
					break;
				case MJCP.Expression.Operation.OctalLiteral :
					result = SLE.Expression.Constant (((MJCP.OctalLiteralExpression)Input).Value);
					break;
				case MJCP.Expression.Operation.RegularExpressionLiteral :
					//TODO
					throw new NotImplementedException ();
				case MJCP.Expression.Operation.StringLiteral :
					result = SLE.Expression.Constant (((MJCP.StringLiteralExpression)Input).Value);
					break;
				case MJCP.Expression.Operation.ArrayLiteral :
					arguments = new List<SLE.Expression> ();
					
					arguments.Add (SLE.Expression.CodeContext ());

					initializers =new List<SLE.Expression> ();
					foreach (MJCP.ExpressionListElement element in ((MJCP.ArrayLiteralExpression)Input).Elements)
							initializers.Add (Generate (element.Value));
					arguments.Add (SLE.Expression.NewArray (typeof (object []), initializers));

					result = SLE.Expression.Call (typeof (CompilerHelpers).GetMethod ("ConstructArrayFromArrayLiteral"), arguments.ToArray ());
					break;
				case MJCP.Expression.Operation.ObjectLiteral :
					arguments = new List<SLE.Expression> ();

					arguments.Add (SLE.Expression.CodeContext ());
					
					initializers = new List<SLE.Expression> ();
					List<SLE.Expression> initializers2 = new List<SLE.Expression> ();
					foreach (MJCP.ObjectLiteralElement element in ((MJCP.ObjectLiteralExpression)Input).Elements) {
						initializers.Add (Generate (element.Name));
						initializers2.Add (Generate (element.Value));
					}
					arguments.Add (SLE.Expression.NewArray (typeof (object[]), initializers));
					arguments.Add (SLE.Expression.NewArray (typeof (object[]), initializers2));

					result = SLE.Expression.Call (typeof (CompilerHelpers).GetMethod ("ConstructObjectFromLiteral"), arguments.ToArray ());
					break;
				case MJCP.Expression.Operation.Parenthesized :
					result = Generate (((MJCP.UnaryOperatorExpression)Input).Operand); 
					break;
				case MJCP.Expression.Operation.Invocation :
					arguments = new List<SLE.Expression> ();
					//TODO fill arguments
					//args = new List<SLE.Arg> ();
					foreach (MJCP.ExpressionListElement element in ((MJCP.InvocationExpression)Input).Arguments.Arguments)
						arguments.Add (Generate (element.Value));
					
					SLE.Expression instance = Generate (((MJCP.InvocationExpression)Input).Target);
					//(Expression instance,) MethodInfo method, params Expression[] arguments
					//TODO MethodInfo!
					result = SLE.Expression.Call (instance, null, arguments.ToArray ());
					break;
				case MJCP.Expression.Operation.Subscript :
//.........这里部分代码省略.........
开发者ID:alesliehughes,项目名称:olive,代码行数:101,代码来源:RowanGenerator.cs


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