本文整理汇总了C#中Boo.Lang.Compiler.Ast.ArrayLiteralExpression类的典型用法代码示例。如果您正苦于以下问题:C# ArrayLiteralExpression类的具体用法?C# ArrayLiteralExpression怎么用?C# ArrayLiteralExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayLiteralExpression类属于Boo.Lang.Compiler.Ast命名空间,在下文中一共展示了ArrayLiteralExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LeaveArrayLiteralExpression
public override void LeaveArrayLiteralExpression(ArrayLiteralExpression node)
{
if (LookingFor(node))
{
Found(node.Type);
}
}
示例2: typesOf
public static Expression typesOf(params Expression[] args)
{
var result = new ArrayLiteralExpression();
foreach (var arg in args)
result.Items.Add(CodeBuilder.CreateTypeofExpression(arg.ExpressionType));
return result;
}
示例3: AddDependency
protected virtual void AddDependency(ArrayLiteralExpression dependencies, BinaryExpression binaryExpression)
{
StringLiteralExpression dependency;
//HACK: replace with proper AST method invocation
if (binaryExpression.Left is StringLiteralExpression)
{
dependency = new StringLiteralExpression(string.Format("{0}|{1}",
binaryExpression.Left.ToString().Trim('\''),
binaryExpression.Right.ToString().Trim('\'')));
}
else if(binaryExpression.Left is BinaryExpression)
{
var left = (BinaryExpression) binaryExpression.Left;
var package = left.Left.ToString().Trim('\'');
var version = left.Right.ToString().Trim('\'');
var dll = binaryExpression.Right.ToString().Trim('\'');
dependency = new StringLiteralExpression(string.Format("{0}|{1}|{2}",
package,
dll,
version));
}
else
throw new ArgumentOutOfRangeException(string.Format("Unknown Expression type {0} passed to RightShiftToMethodCompilerStep.AddDependency", binaryExpression.Left.GetType().Name));
dependencies.Items.Add(dependency);
}
示例4: OnMethodInvocationExpression
protected virtual void OnMethodInvocationExpression(ArrayLiteralExpression dependencies, MethodInvocationExpression expression)
{
foreach (var arg in expression.Arguments)
{
var binaryExpression = arg as BinaryExpression;
if (binaryExpression == null || binaryExpression.Operator != BinaryOperatorType.ShiftRight)
continue;
AddDependency(dependencies, binaryExpression);
}
}
示例5: LeaveArrayLiteralExpression
public override void LeaveArrayLiteralExpression(ArrayLiteralExpression node)
{
IType elementType = GetExpressionType(node).ElementType;
for (int i = 0; i < node.Items.Count; ++i)
{
Expression converted = Convert(elementType, node.Items[i]);
if (null != converted)
{
node.Items.ReplaceAt(i, converted);
}
}
}
示例6: data
public static Expression data(params StringLiteralExpression[] expressions)
{
var arrayExpression = new ArrayLiteralExpression();
for (var i = 0; i < expressions.Length; i++)
arrayExpression.Items.Add(expressions[i]);
return new MethodInvocationExpression(
new ReferenceExpression("SetData"),
arrayExpression
);
}
示例7: ExpandComplexArraySlicing
void ExpandComplexArraySlicing(SlicingExpression node)
{
if (node.Indices.Count > 1)
{
MethodInvocationExpression mie = null;
var computeEnd = new ArrayLiteralExpression();
var collapse = new ArrayLiteralExpression();
var ranges = new ArrayLiteralExpression();
for (int i = 0; i < node.Indices.Count; i++)
{
ranges.Items.Add(node.Indices[i].Begin);
if (node.Indices[i].End == null )
{
var end = new BinaryExpression(BinaryOperatorType.Addition, node.Indices[i].Begin, new IntegerLiteralExpression(1));
ranges.Items.Add(end);
BindExpressionType(end, GetExpressionType(node.Indices[i].Begin));
computeEnd.Items.Add(new BoolLiteralExpression(false));
collapse.Items.Add(new BoolLiteralExpression(true));
}
else if (node.Indices[i].End == OmittedExpression.Default)
{
var end = new IntegerLiteralExpression(0);
ranges.Items.Add(end);
BindExpressionType(end, GetExpressionType(node.Indices[i].Begin));
computeEnd.Items.Add(new BoolLiteralExpression(true));
collapse.Items.Add(new BoolLiteralExpression(false));
}
else
{
ranges.Items.Add(node.Indices[i].End);
computeEnd.Items.Add(new BoolLiteralExpression(false));
collapse.Items.Add(new BoolLiteralExpression(false));
}
}
mie = CodeBuilder.CreateMethodInvocation(MethodCache.RuntimeServices_GetMultiDimensionalRange1, node.Target, ranges);
mie.Arguments.Add(computeEnd);
mie.Arguments.Add(collapse);
BindExpressionType(ranges, TypeSystemServices.Map(typeof(int[])));
BindExpressionType(computeEnd, TypeSystemServices.Map(typeof(bool[])));
BindExpressionType(collapse, TypeSystemServices.Map(typeof(bool[])));
node.ParentNode.Replace(node, mie);
}
else
{
var slice = node.Indices[0];
var mie = IsNullOrOmitted(slice.End)
? CodeBuilder.CreateMethodInvocation(MethodCache.RuntimeServices_GetRange1, node.Target, slice.Begin)
: CodeBuilder.CreateMethodInvocation(MethodCache.RuntimeServices_GetRange2, node.Target, slice.Begin, slice.End);
node.ParentNode.Replace(node, mie);
}
}
示例8: DoExpand
/// <summary>
/// Perform the actual expansion of the macro
/// </summary>
/// <param name="macro">The macro.</param>
/// <returns></returns>
protected override Statement DoExpand(MacroStatement macro)
{
Block body = (Block)macro.GetAncestor(NodeType.Block);
MacroStatement macroParent = (MacroStatement)macro.GetAncestor(NodeType.MacroStatement);
if (macro.Body.Statements.Count < 1 && parent.Name=="join")
{
Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo, "Join " + name + " section must contain at least a single expression statement"));
return null;
}
if (macro.Arguments.Count == 0 && parent.Name!="join")
{
Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo, "Join " + name + " section must contain at least one key column"));
return null;
}
if (macro.Arguments.Count > 0)
{
ArrayLiteralExpression ale = new ArrayLiteralExpression(macro.LexicalInfo);
ale.Type = new ArrayTypeReference(CodeBuilder.CreateTypeReference(typeof(string)));
foreach (Expression argument in macro.Arguments)
{
ReferenceExpression expr = argument as ReferenceExpression;
if (expr == null)
{
Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo,"Join " + name +" section arguments must be reference expressions. Example: " + name + " name, surname"));
return null;
}
ale.Items.Add(new StringLiteralExpression(expr.Name));
}
var keyExpr = new BinaryExpression(BinaryOperatorType.Assign, new ReferenceExpression(name+"KeyColumns"), ale);
macroParent.Arguments.Add(keyExpr);
}
foreach (Statement statement in macro.Body.Statements)
{
ExpressionStatement exprStmt = statement as ExpressionStatement;
if(exprStmt==null)
{
Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo, "Join " + name + " section can only contain expressions"));
return null;
}
Expression expr = exprStmt.Expression;
parent.Arguments.Add(new MethodInvocationExpression(new ReferenceExpression(name), expr));
}
return null;
}
示例9: IsCompoundAssignment
public static bool IsCompoundAssignment(Expression expression,
out ArrayLiteralExpression assignments)
{
assignments = expression as ArrayLiteralExpression;
if (assignments != null)
{
BinaryExpression assignment;
return (assignments.Items.Count > 1 &&
IsAssignment(assignments.Items[1], out assignment));
}
return false;
}
示例10: CreateGetColumnsToGroupByMethod
private Method CreateGetColumnsToGroupByMethod(MacroStatement macro, IEnumerable<string> columns)
{
Method method = new Method("GetColumnsToGroupBy");
method.Modifiers = TypeMemberModifiers.Override;
ArrayLiteralExpression ale = new ArrayLiteralExpression(macro.LexicalInfo);
ale.Type = new ArrayTypeReference(CodeBuilder.CreateTypeReference(typeof(string)));
foreach (string column in columns)
{
ale.Items.Add(new StringLiteralExpression(column));
}
method.Body.Statements.Add(new ReturnStatement(ale));
return method;
}
示例11: OnArrayLiteralExpression
public override void OnArrayLiteralExpression(ArrayLiteralExpression node)
{
var need_expansion = false;
if(node.Items.Count==2 && node.Items[0].ToCodeString().StartsWith("@_")){
need_expansion = true;
}
base.OnArrayLiteralExpression(node);
if(need_expansion){
if(node.Items[0] is NullLiteralExpression){
node.ParentNode.Replace(node, node.Items[1].CloneNode());
}
else{
node.ParentNode.Replace(node, node.Items[0].CloneNode());
}
}
}
示例12: LeaveArrayLiteralExpression
public override void LeaveArrayLiteralExpression(ArrayLiteralExpression node)
{
IType expectedType = GetExpressionType(node).ElementType;
if (!TypeSystemServices.IsPrimitiveNumber(expectedType))
return;
foreach (Expression item in node.Items)
{
IType itemType = item.ExpressionType;
if (item is LiteralExpression)
{
if (item.NodeType == NodeType.IntegerLiteralExpression)
AssertLiteralInRange((IntegerLiteralExpression) item, expectedType);
if (expectedType != itemType)
BindExpressionType(item, expectedType);
}
}
}
示例13: exclude
public static Expression exclude(BlockExpression action)
{
var arrayExpression = new ArrayLiteralExpression();
foreach (Statement statement in action.Body.Statements)
{
var stringLiteral =
new StringLiteralExpression(
((MethodInvocationExpression) (((ExpressionStatement) (statement)).Expression)).Arguments[0].ToString().Trim(new[]{'\''}));
arrayExpression.Items.Add(stringLiteral);
}
return new MethodInvocationExpression(
new ReferenceExpression("SetExcludeList"),
arrayExpression
);
}
示例14: OnBlockExpression
public override void OnBlockExpression(BlockExpression node)
{
var dependencies = new ArrayLiteralExpression();
foreach (Statement statement in node.Body.Statements)
{
var expressionStatement = (ExpressionStatement)statement;
var expression = (MethodInvocationExpression)expressionStatement.Expression;
OnMethodInvocationExpression(dependencies, expression);
}
if (dependencies.Items.Count == 0)
return;
var referenceExpression = new ReferenceExpression("AddDependencies");
var replacementMethod = new MethodInvocationExpression(referenceExpression, dependencies);
ReplaceCurrentNode(replacementMethod);
}
示例15: OnArrayLiteralExpression
override public void OnArrayLiteralExpression(ArrayLiteralExpression node)
{
if (!_checked)
return;
base.OnArrayLiteralExpression(node);
var expectedType = GetExpressionType(node).ElementType;
if (!TypeSystemServices.IsPrimitiveNumber(expectedType))
return;
foreach (var item in node.Items)
{
var integerLiteral = item as IntegerLiteralExpression;
if (integerLiteral != null)
{
AssertLiteralInRange(integerLiteral, expectedType);
continue;
}
}
}