本文整理汇总了C#中Microsoft.PythonTools.Parsing.Ast.Expression类的典型用法代码示例。如果您正苦于以下问题:C# Expression类的具体用法?C# Expression怎么用?C# Expression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Expression类属于Microsoft.PythonTools.Parsing.Ast命名空间,在下文中一共展示了Expression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefineExpr
private void DefineExpr(Expression lhs) {
if (lhs is NameExpression) {
lhs.Walk(Define);
} else {
// fob.oar = 42, fob[oar] = 42, we don't actually define any variables
lhs.Walk(this);
}
}
示例2: BinaryExpression
public BinaryExpression(PythonOperator op, Expression left, Expression right) {
Contract.Assert(left != null);
Contract.Assert(right != null);
if (op == PythonOperator.None) throw new ArgumentException("bad operator");
_op = op;
_left = left;
_right = right;
StartIndex = left.StartIndex;
EndIndex = right.EndIndex;
}
示例3: AppendCodeString
internal void AppendCodeString(StringBuilder res, PythonAst ast, CodeFormattingOptions format, string start, string end, Expression item) {
if (!String.IsNullOrEmpty(start)) {
format.ReflowComment(res, this.GetProceedingWhiteSpace(ast));
res.Append(start);
}
item.AppendCodeString(res, ast, format);
for (int i = 0; i < Iterators.Count; i++) {
Iterators[i].AppendCodeString(res, ast, format);
}
if (!String.IsNullOrEmpty(end)) {
res.Append(this.GetSecondWhiteSpace(ast));
res.Append(end);
}
}
示例4: GetValueFromExpression
private IMember GetValueFromExpression(Expression expr, Dictionary<string, IMember> scope) {
var ne = expr as NameExpression;
if (ne != null) {
IMember existing = null;
if (scope != null && scope.TryGetValue(ne.Name, out existing) && existing != null) {
return existing;
}
if (_members != null && _members.TryGetValue(ne.Name, out existing) && existing != null) {
return existing;
}
}
var type = GetTypeFromExpression(expr);
if (type != null) {
return new AstPythonConstant(type, GetLoc(expr));
}
return null;
}
示例5: GetFirstNameExpression
private static NameExpression GetFirstNameExpression(Expression expr) {
NameExpression nameExpr;
CallExpression callExpr;
MemberExpression membExpr;
if ((nameExpr = expr as NameExpression) != null) {
return nameExpr;
}
if ((callExpr = expr as CallExpression) != null) {
return GetFirstNameExpression(callExpr.Target);
}
if ((membExpr = expr as MemberExpression) != null) {
return GetFirstNameExpression(membExpr.Target);
}
return null;
}
示例6: AssertStatement
public AssertStatement(Expression test, Expression message) {
_test = test;
_message = message;
}
示例7: ForceExplicitSign
private static Expression ForceExplicitSign(Expression expr, out int sign) {
var constExpr = expr as ConstantExpression;
if (constExpr != null && (constExpr.Value is int || constExpr.Value is double || constExpr.Value is BigInteger || constExpr.Value is Complex)) {
sign = 1;
return new UnaryExpression(PythonOperator.Pos, constExpr);
}
var unaryExpr = expr as UnaryExpression;
if (unaryExpr != null) {
switch (unaryExpr.Op) {
case PythonOperator.Pos:
sign = 1;
return unaryExpr;
case PythonOperator.Negate:
sign = -1;
return unaryExpr;
}
}
sign = 0;
return expr;
}
示例8: IfStatementTest
public IfStatementTest(Expression test, Statement body) {
_test = test;
_body = body;
}
示例9: WalkCollection
private bool WalkCollection(Expression node, IEnumerable<Expression> items) {
CanComplete = HasCaret(node);
int count = 0;
Expression last = null;
foreach (var e in items) {
count += 1;
last = e;
}
if (count == 0) {
CommitByDefault = false;
} else if (count == 1) {
last.Walk(this);
CommitByDefault = false;
} else {
CommitByDefault = true;
last.Walk(this);
}
return false;
}
示例10: FinishSetComp
// comp_iter '}'
private SetComprehension FinishSetComp(Expression item, out bool ateTerminator) {
ComprehensionIterator[] iters = ParseCompIter();
ateTerminator = Eat(TokenKind.RightBrace);
return new SetComprehension(item, iters);
}
示例11: ParseGeneratorExpression
// genexpr_for ::= "for" target_list "in" or_test [comp_iter]
//
// "for" has NOT been eaten before entering this method
private Expression ParseGeneratorExpression(Expression expr, string rightParenWhiteSpace = null) {
ComprehensionIterator[] iters = ParseCompIter();
GeneratorExpression ret = new GeneratorExpression(expr, iters);
ret.SetLoc(expr.StartIndex, GetEnd());
return ret;
}
示例12: FinishExpressionListAsExpr
private Expression FinishExpressionListAsExpr(Expression expr) {
var start = GetStart();
bool trailingComma = true;
List<Expression> l = new List<Expression>();
List<string> itemWhiteSpace = MakeWhiteSpaceList();
if (itemWhiteSpace != null) {
itemWhiteSpace.Add(_tokenWhiteSpace);
}
l.Add(expr);
while (true) {
if (NeverTestToken(PeekToken())) break;
expr = ParseExpression();
l.Add(expr);
if (!MaybeEat(TokenKind.Comma)) {
trailingComma = false;
break;
}
if (itemWhiteSpace != null) {
itemWhiteSpace.Add(_tokenWhiteSpace);
}
trailingComma = true;
}
Expression ret = MakeTupleOrExpr(l, itemWhiteSpace, trailingComma);
ret.SetLoc(start, GetEnd());
return ret;
}
示例13: ParseTestListAsExpr
private List<Expression> ParseTestListAsExpr(Expression expr, out List<string> itemWhiteSpace, out bool trailingComma) {
var l = new List<Expression>();
itemWhiteSpace = MakeWhiteSpaceList();
if (expr != null) {
l.Add(expr);
if (itemWhiteSpace != null) {
Debug.Assert(_token.Token.Kind == TokenKind.Comma);
itemWhiteSpace.Add(_tokenWhiteSpace);
}
}
trailingComma = true;
while (true) {
if (NeverTestToken(PeekToken())) break;
l.Add(ParseExpression());
if (!MaybeEat(TokenKind.Comma)) {
trailingComma = false;
break;
}
if (itemWhiteSpace != null) {
itemWhiteSpace.Add(_tokenWhiteSpace);
}
}
return l;
}
示例14: DecoratorStatement
public DecoratorStatement(Expression[] decorators) {
_decorators = decorators;
}
示例15: IsActualExpression
private static bool IsActualExpression(Expression node) {
return node != null && !(node is ErrorExpression);
}