本文整理汇总了C#中INode.PrettyPrint方法的典型用法代码示例。如果您正苦于以下问题:C# INode.PrettyPrint方法的具体用法?C# INode.PrettyPrint怎么用?C# INode.PrettyPrint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INode
的用法示例。
在下文中一共展示了INode.PrettyPrint方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateExpr
string CreateExpr(string literal, INode expr)
{
bool requiresParens = false;
string actualExpr;
if (expr != null && expr.NodeType == NodeType.BinaryExpr)
{
var binaryExpr = (BinaryExpr)expr;
actualExpr = binaryExpr.Op;
requiresParens = true;
bool isAssociativeOp = (binaryExpr.opName == "*" && opName == "*") || (binaryExpr.opName == "+" && opName == "+");
if (isAssociativeOp)
{
requiresParens = false;
}
}
else
{
actualExpr = expr == null ? literal : expr.PrettyPrint();
}
return requiresParens ? "(" + actualExpr + ")" : actualExpr;
}
示例2: GetExpr
public string GetExpr(INode expr, string literal)
{
return expr == null ? literal : expr.PrettyPrint();
}
示例3: Evaluate
TypedValue Evaluate(INode expression, bool permRef, object data = null)
{
// Try to get the value from cache
// (the cache is cleared when the process is resumed)
TypedValue val;
if (context.Process.ExpressionsCache.TryGetValue(expression, out val)) {
if (val == null || !val.Value.IsInvalid)
return val;
}
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
watch.Start();
try {
val = (TypedValue)expression.AcceptVisitor(this, data);
if (val != null && permRef)
val = new TypedValue(val.Value.GetPermanentReference(), val.Type);
} catch (GetValueException e) {
e.Expression = expression;
throw;
} catch (NotImplementedException e) {
throw new GetValueException(expression, "Language feature not implemented: " + e.Message);
} finally {
watch.Stop();
context.Process.TraceMessage("Evaluated: {0} in {1} ms total", expression.PrettyPrint(), watch.ElapsedMilliseconds);
}
if (val != null && val.Value.IsInvalid)
throw new DebuggerException("Expression \"" + expression.PrettyPrint() + "\" is invalid right after evaluation");
// Add the result to cache
context.Process.ExpressionsCache[expression] = val;
return val;
}
示例4: BuildElse
void BuildElse(INode node, StringBuilder output)
{
output.AppendLine(" else {");
output.AppendLine(node.PrettyPrint());
output.Append("}");
}