本文整理汇总了C#中IronPython.Compiler.Ast.Expression类的典型用法代码示例。如果您正苦于以下问题:C# Expression类的具体用法?C# Expression怎么用?C# Expression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Expression类属于IronPython.Compiler.Ast命名空间,在下文中一共展示了Expression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AndExpression
public AndExpression(Expression left, Expression right)
{
this.left = left;
this.right = right;
this.Start = left.Start;
this.End = right.End;
}
示例2: GetTypeName
/// <summary>
/// Gets the fully qualified name of the type from the expression.
/// </summary>
/// <remarks>
/// The expression is the first target of a call expression.
///
/// A call expression is a method or constructor call (right hand side of expression below):
///
/// a = Root.Test.Class1()
///
/// So the expression passed to this method will be a field expression in the
/// above example which refers to Class1. The next target will be a field
/// expression referring to Test. The The last target will be a name expression
/// referring to Root.
///
/// If we have
///
/// a = Class1()
///
/// then the expression will be a name expression referring to Class1.
/// </remarks>
string GetTypeName(Expression expression)
{
NameExpression nameExpression = expression as NameExpression;
if (nameExpression != null) {
return nameExpression.Name;
}
return PythonControlFieldExpression.GetMemberName(expression as MemberExpression);
}
示例3: AddBaseType
void AddBaseType(Expression baseTypeExpression)
{
NameExpression nameExpression = baseTypeExpression as NameExpression;
MemberExpression memberExpression = baseTypeExpression as MemberExpression;
if (nameExpression != null) {
AddBaseType(nameExpression.Name);
} else if (memberExpression != null) {
AddBaseType(memberExpression);
}
}
示例4: FinishCallExpr
private CallExpression FinishCallExpr(Expression target, params Arg[] args) {
bool hasArgsTuple = false;
bool hasKeywordDict = false;
int keywordCount = 0;
int extraArgs = 0;
foreach (Arg arg in args) {
if (arg.Name == null) {
if (hasArgsTuple || hasKeywordDict || keywordCount > 0) {
ReportSyntaxError(IronPython.Resources.NonKeywordAfterKeywordArg);
}
} else if (arg.Name == "*") {
if (hasArgsTuple || hasKeywordDict) {
ReportSyntaxError(IronPython.Resources.OneListArgOnly);
}
hasArgsTuple = true; extraArgs++;
} else if (arg.Name == "**") {
if (hasKeywordDict) {
ReportSyntaxError(IronPython.Resources.OneKeywordArgOnly);
}
hasKeywordDict = true; extraArgs++;
} else {
if (hasKeywordDict) {
ReportSyntaxError(IronPython.Resources.KeywordOutOfSequence);
}
keywordCount++;
}
}
return new CallExpression(target, args);
}
示例5: FinishDictComp
// comp_iter '}'
private DictionaryComprehension FinishDictComp(Expression key, Expression value, int oStart, int oEnd) {
ComprehensionIterator[] iters = ParseCompIter();
Eat(TokenKind.RightBrace);
var cStart = GetStart();
var cEnd = GetEnd();
if (_sink != null) {
_sink.MatchPair(
new SourceSpan(_tokenizer.IndexToLocation(oStart), _tokenizer.IndexToLocation(oEnd)),
new SourceSpan(_tokenizer.IndexToLocation(cStart), _tokenizer.IndexToLocation(cEnd)),
1
);
}
var ret = new DictionaryComprehension(key, value, iters);
ret.SetLoc(_globalParent, oStart, cEnd);
return ret;
}
示例6: FinishExpressionListAsExpr
private Expression FinishExpressionListAsExpr(Expression expr) {
var start = GetStart();
bool trailingComma = true;
List<Expression> l = new List<Expression>();
l.Add(expr);
while (true) {
if (NeverTestToken(PeekToken())) break;
expr = ParseExpression();
l.Add(expr);
if (!MaybeEat(TokenKind.Comma)) {
trailingComma = false;
break;
}
trailingComma = true;
}
Expression ret = MakeTupleOrExpr(l, trailingComma);
ret.SetLoc(_globalParent, start, GetEnd());
return ret;
}
示例7: FinishKeywordArgument
private Arg FinishKeywordArgument(Expression t) {
NameExpression n = t as NameExpression;
if (n == null) {
ReportSyntaxError(IronPython.Resources.ExpectedName);
Arg arg = new Arg(null, t);
arg.SetLoc(_globalParent, t.StartIndex, t.EndIndex);
return arg;
} else {
Expression val = ParseExpression();
Arg arg = new Arg(n.Name, val);
arg.SetLoc(_globalParent, n.StartIndex, val.EndIndex);
return arg;
}
}
示例8: AddTrailers
// trailer: '(' [ arglist_genexpr ] ')' | '[' subscriptlist ']' | '.' NAME
private Expression AddTrailers(Expression ret, bool allowGeneratorExpression) {
bool prevAllow = _allowIncomplete;
try {
_allowIncomplete = true;
while (true) {
switch (PeekToken().Kind) {
case TokenKind.LeftParenthesis:
if (!allowGeneratorExpression) return ret;
NextToken();
Arg[] args = FinishArgListOrGenExpr();
CallExpression call;
if (args != null) {
call = FinishCallExpr(ret, args);
} else {
call = new CallExpression(ret, new Arg[0]);
}
call.SetLoc(_globalParent, ret.StartIndex, GetEnd());
ret = call;
break;
case TokenKind.LeftBracket:
NextToken();
Expression index = ParseSubscriptList();
IndexExpression ie = new IndexExpression(ret, index);
ie.SetLoc(_globalParent, ret.StartIndex, GetEnd());
ret = ie;
break;
case TokenKind.Dot:
NextToken();
string name = ReadNameMaybeNone();
MemberExpression fe = new MemberExpression(ret, name);
fe.SetLoc(_globalParent, ret.StartIndex, GetEnd());
ret = fe;
break;
case TokenKind.Constant:
// abc.1, abc"", abc 1L, abc 0j
ReportSyntaxError("invalid syntax");
return Error();
default:
return ret;
}
}
} finally {
_allowIncomplete = prevAllow;
}
}
示例9: ParseConditionalTest
private Expression ParseConditionalTest(Expression trueExpr) {
Expression expr = ParseOrTest();
Eat(TokenKind.KeywordElse);
Expression falseExpr = ParseExpression();
return new ConditionalExpression(expr, trueExpr, falseExpr);
}
示例10: ExecStatement
public ExecStatement(Expression code, Expression locals, Expression globals)
{
this.code = code;
this.locals = locals;
this.globals = globals;
}
示例11: DelStatement
public DelStatement(Expression[] expressions)
{
this.exprs = expressions;
}
示例12: YieldStatement
public YieldStatement(Expression expression, int index)
{
this.expr = expression;
this.index = index;
}
示例13: WithStatement
private List<YieldTarget> yieldTargets; // = new List<YieldTarget>();
#endregion Fields
#region Constructors
public WithStatement(Expression contextManager, Expression var, Statement body)
{
this.contextManager = contextManager;
this.var = var;
this.body = body;
}
示例14: WhileStatement
public WhileStatement(Expression test, Statement body, Statement else_)
{
this.test = test; this.body = body; this.elseStmt = else_;
}
示例15: TryStatementHandler
public TryStatementHandler(Expression test, Expression target, Statement body)
{
this.test = test; this.target = target; this.body = body;
}