本文整理汇总了C#中INode.AcceptVisitor方法的典型用法代码示例。如果您正苦于以下问题:C# INode.AcceptVisitor方法的具体用法?C# INode.AcceptVisitor怎么用?C# INode.AcceptVisitor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INode
的用法示例。
在下文中一共展示了INode.AcceptVisitor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run(INode typeDeclaration)
{
typeDeclaration.AcceptVisitor(this, null);
foreach (VariableDeclaration decl in fields) {
decl.Name = prefix + decl.Name;
}
}
示例2: ToText
public static string ToText(INode node)
{
var output = new CSharpOutputVisitor();
node.AcceptVisitor(output, null);
return output.Text;
}
示例3: TrackedVisit
public object TrackedVisit(INode node, object data)
{
BeginNode(node);
object ret = node.AcceptVisitor(callVisitor, data);
EndNode(node);
return ret;
}
示例4: OutputNode
public string OutputNode (ProjectDom dom, INode node, string indent)
{
CSharpOutputVisitor outputVisitor = new CSharpOutputVisitor ();
CSharpFormatter.SetFormatOptions (outputVisitor, dom != null && dom.Project != null ? dom.Project.Policies : null);
int col = CSharpFormatter.GetColumn (indent, 0, 4);
outputVisitor.OutputFormatter.IndentationLevel = System.Math.Max (0, col / 4);
node.AcceptVisitor (outputVisitor, null);
return outputVisitor.Text;
}
示例5: GenerateCode
protected override string GenerateCode(INode unit, bool installSpecials)
{
CSharpOutputVisitor visitor = new CSharpOutputVisitor();
if (installSpecials) {
SpecialNodesInserter.Install(this.specialsList, visitor);
}
unit.AcceptVisitor(visitor, null);
return visitor.Text;
}
示例6: GenerateCode
private static string GenerateCode(INode unit/*, bool installSpecials*/)
{
CSharpOutputVisitor visitor = new CSharpOutputVisitor();
// if (installSpecials)
// {
// SpecialNodesInserter.Install(this.specialsList, visitor);
// }
unit.AcceptVisitor(visitor, null);
return visitor.Text;
}
示例7: CreateCode
string CreateCode(INode node, IOutputAstVisitor outputVisitor)
{
using (SpecialNodesInserter.Install(specials, outputVisitor)) {
node.AcceptVisitor(outputVisitor, null);
}
return outputVisitor.Text;
}
示例8: GetString
public string GetString (INode domVisitable, OutputSettings settings)
{
if (domVisitable == null)
return nullString;
string result = (string)domVisitable.AcceptVisitor (OutputVisitor, settings);
if (settings is OutputSettings)
((OutputSettings)settings).PostProcess (domVisitable, ref result);
return result;
}
示例9: 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;
}
示例10: RenameVariable
static void RenameVariable(INode method, string from, ref int index)
{
index += 1;
method.AcceptVisitor(new RenameLocalVariableVisitor(from, from + "__" + index, StringComparer.Ordinal), null);
}
示例11: ChangeInvocationName
private INode ChangeInvocationName(string newName, INode node)
{
RenameIdentifierVisitor v = new RenameIdentifierVisitor("NewMethod", newName, StringComparer.InvariantCulture);
node.AcceptVisitor(v, null);
return node;
}
示例12: EmitBlockOrIndentedLine
void EmitBlockOrIndentedLine (INode node)
{
bool block = node is BlockStatement;
if (!block) {
NewLine ();
Indent ();
} else {
Write (" ");
}
node.AcceptVisitor (this, null);
if (!block)
Outdent ();
}
示例13: EmitLambda
void EmitLambda (List<ParameterDeclarationExpression> parameters, INode body, INode context, Mono.Collections.Generic.Collection<ParameterDefinition> paramdefinitions)
{
PushLocals ();
if (paramdefinitions == null) {
AddLocals (parameters);
} else {
for (var i = 0; i < paramdefinitions.Count; i++) {
ParameterDefinition p = paramdefinitions[i];
//Console.WriteLine ("AddLocal: {0}: {1}", parameters[i].ParameterName, p.ParameterType);
Locals.Add (parameters[i].ParameterName, p.ParameterType);
}
}
bool block = body is BlockStatement;
Write ("");
var savedPos = Output.Length;
var savedThisCount = ThisRefCountInMethods;
Write ("function");
EmitMethodParameters (parameters, context);
Write (" ");
if (!block) {
Write ("{ ");
}
if (body.Parent is LambdaExpression && !block)
Write ("return ");
body.AcceptVisitor (this, null);
if (!block) {
Write (" }");
}
//if (ThisRefCountInMethods > savedThisCount) {
//Output.Insert(savedPos, RUNTIME_HELPER_NAME + ".bind(this)(");
Write (".bind(this)");
//}
PopLocals ();
}
示例14: StatementUsesExpr
private bool StatementUsesExpr(INode node, IdentifierExpression ie)
{
FindReferenceVisitor visitor = new FindReferenceVisitor(true, ie.Identifier, node.StartLocation, node.EndLocation);
node.AcceptVisitor(visitor, null);
return visitor.Identifiers.Count > 0;
}
示例15: GetExtractableChildren
public static List<INode> GetExtractableChildren(INode node)
{
var v = new GetImmediateChildrenVisitor();
node.AcceptVisitor(v, null);
return v.Children;
}