本文整理汇总了C#中IronRuby.Compiler.Ast.AstGenerator.TransformStatementsToExpression方法的典型用法代码示例。如果您正苦于以下问题:C# AstGenerator.TransformStatementsToExpression方法的具体用法?C# AstGenerator.TransformStatementsToExpression怎么用?C# AstGenerator.TransformStatementsToExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IronRuby.Compiler.Ast.AstGenerator
的用法示例。
在下文中一共展示了AstGenerator.TransformStatementsToExpression方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransformRead
internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
return AstFactory.Condition(
Methods.IsFalse.OpCall(AstFactory.Box(_condition.TransformRead(gen))),
gen.TransformStatementsToExpression(_statements),
gen.TransformStatementsToExpression(_elseClause != null ? _elseClause.Statements : null)
);
}
示例2: TransformRead
internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
MSA.Expression result;
int i = _elseIfClauses.Count - 1;
if (i >= 0 && _elseIfClauses[i].Condition == null) {
// ... else body end
result = gen.TransformStatementsToExpression(_elseIfClauses[i].Statements);
i--;
} else {
// no else clause => the result of the if-expression is nil:
result = AstUtils.Constant(null);
}
while (i >= 0) {
// emit: else (if (condition) body else result)
result = AstFactory.Condition(
_elseIfClauses[i].Condition.TransformCondition(gen, true),
gen.TransformStatementsToExpression(_elseIfClauses[i].Statements),
result
);
i--;
}
// if (condition) body else result
return AstFactory.Condition(
_condition.TransformCondition(gen, true),
gen.TransformStatementsToExpression(_body),
result
);
}
示例3: TransformRead
internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
return AstFactory.Condition(
_condition.TransformCondition(gen, false),
gen.TransformStatementsToExpression(_statements),
gen.TransformStatementsToExpression(_elseClause != null ? _elseClause.Statements : null)
);
}
示例4: TransformRead
internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
Assert.NotNull(gen);
if (HasExceptionHandling) {
MSA.Expression resultVariable = gen.CurrentScope.DefineHiddenVariable("#block-result", typeof(object));
return AstFactory.Block(
TransformExceptionHandling(gen, ResultOperation.Store(resultVariable)),
resultVariable
);
} else {
return gen.TransformStatementsToExpression(_statements);
}
}
示例5: TransformRead
internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
return gen.TransformStatementsToExpression(_statements);
}
示例6: TransformRead
internal override MSA.Expression/*!*/ TransformRead(AstGenerator/*!*/ gen) {
MSA.Expression result;
if (_elseStatements != null) {
// ... else body end
result = gen.TransformStatementsToExpression(_elseStatements);
} else {
// no else clause => the result of the if-expression is nil:
result = Ast.Constant(null);
}
MSA.Expression value;
if (_value != null) {
value = gen.CurrentScope.DefineHiddenVariable("#case-compare-value", typeof(object));
} else {
value = null;
}
for (int i = _whenClauses.Count - 1; i >= 0; i-- ) {
// emit: else (if (condition) body else result)
result = AstFactory.Condition(
TransformWhenCondition(gen, _whenClauses[i].Comparisons, _whenClauses[i].ComparisonArray, value),
gen.TransformStatementsToExpression(_whenClauses[i].Statements),
result
);
}
if (_value != null) {
result = AstFactory.Block(
Ast.Assign(value, Ast.Convert(_value.TransformRead(gen), typeof(object))),
result
);
}
return result;
}