本文整理汇总了C#中PrimitiveExpression.AcceptVisitor方法的典型用法代码示例。如果您正苦于以下问题:C# PrimitiveExpression.AcceptVisitor方法的具体用法?C# PrimitiveExpression.AcceptVisitor怎么用?C# PrimitiveExpression.AcceptVisitor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PrimitiveExpression
的用法示例。
在下文中一共展示了PrimitiveExpression.AcceptVisitor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitArrayCreateExpression
protected void VisitArrayCreateExpression()
{
ArrayCreateExpression arrayCreateExpression = this.ArrayCreateExpression;
var rr = this.Emitter.Resolver.ResolveNode(arrayCreateExpression, this.Emitter) as ArrayCreateResolveResult;
var at = (ArrayType)rr.Type;
var rank = arrayCreateExpression.Arguments.Count;
if (arrayCreateExpression.Initializer.IsNull && rank == 1)
{
this.Write("Bridge.Array.init(");
arrayCreateExpression.Arguments.First().AcceptVisitor(this.Emitter);
this.WriteComma();
var def = Inspector.GetDefaultFieldValue(at.ElementType);
if (def == at.ElementType)
{
this.WriteFunction();
this.WriteOpenCloseParentheses();
this.BeginBlock();
this.WriteReturn(true);
this.Write("new " + BridgeTypes.ToJsName(at.ElementType, this.Emitter) + "()");
this.WriteSemiColon();
this.WriteNewLine();
this.EndBlock();
}
else
{
this.WriteScript(def);
}
this.Write(")");
return;
}
if (at.Dimensions > 1)
{
this.Write("Bridge.Array.create(");
var defaultInitializer = new PrimitiveExpression(Inspector.GetDefaultFieldValue(at.ElementType), "?");
if (defaultInitializer == null)
{
this.Write("Bridge.getDefaultValue(" + BridgeTypes.ToJsName(arrayCreateExpression.Type, this.Emitter) + ")");
}
else
{
var primitiveExpr = defaultInitializer as PrimitiveExpression;
if (primitiveExpr != null && primitiveExpr.Value is AstType)
{
this.Write("new " + BridgeTypes.ToJsName((AstType)primitiveExpr.Value, this.Emitter) + "()");
}
else
{
defaultInitializer.AcceptVisitor(this.Emitter);
}
}
this.WriteComma();
}
if (rr.InitializerElements != null && rr.InitializerElements.Count > 0)
{
this.WriteOpenBracket();
var elements = arrayCreateExpression.Initializer.Elements;
new ExpressionListBlock(this.Emitter, elements, null).Emit();
this.WriteCloseBracket();
}
else if (at.Dimensions > 1)
{
this.Write("null");
}
else
{
this.Write("[]");
}
if (at.Dimensions > 1)
{
this.Emitter.Comma = true;
for (int i = 0; i < rr.SizeArguments.Count; i++)
{
var a = rr.SizeArguments[i];
this.EnsureComma(false);
if (a.IsCompileTimeConstant)
{
this.Write(a.ConstantValue);
}
else if (arrayCreateExpression.Arguments.Count > i)
{
var arg = arrayCreateExpression.Arguments.ElementAt(i);
if (arg != null)
{
arg.AcceptVisitor(this.Emitter);
}
}
this.Emitter.Comma = true;
//.........这里部分代码省略.........