本文整理汇总了C#中JSNode类的典型用法代码示例。如果您正苦于以下问题:C# JSNode类的具体用法?C# JSNode怎么用?C# JSNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSNode类属于命名空间,在下文中一共展示了JSNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitNodeInternalUp
private void VisitNodeInternalUp(JSNode node, IEnumerable<SequencePoint> sequencePoints)
{
if (node == null)
{
return;
}
if (sequencePoints != null && node.SymbolInfo == null)
{
node.SymbolInfo = new SymbolInfo(sequencePoints, true);
}
foreach (var child in node.Children)
{
if (child == null)
{
continue;
}
if (child.SymbolInfo != null)
{
sequencePoints = child.SymbolInfo.SequencePoints;
}
VisitNodeInternalUp(child, sequencePoints);
}
}
示例2: EliminateVariable
protected void EliminateVariable (JSNode context, JSVariable variable, JSExpression replaceWith, QualifiedMemberIdentifier method) {
{
var replacer = new VariableEliminator(
variable,
JSChangeTypeExpression.New(replaceWith, variable.GetActualType(TypeSystem), TypeSystem)
);
replacer.Visit(context);
}
{
var replacer = new VariableEliminator(variable, replaceWith);
var assignments = (from a in FirstPass.Assignments where
variable.Equals(a.NewValue) ||
a.NewValue.SelfAndChildrenRecursive.Any(variable.Equals)
select a).ToArray();
foreach (var a in assignments) {
if (!variable.Equals(a.NewValue))
replacer.Visit(a.NewValue);
}
}
Variables.Remove(variable.Identifier);
FunctionSource.InvalidateFirstPass(method);
}
示例3: JSAstCursor
public JSAstCursor(JSNode root, params string[] namesToSkip)
{
Root = root;
NamesToSkip = new HashSet<string>(namesToSkip);
Reset();
}
示例4: State
public State (JSNode node, string name, int depth, int nodeIndex, int? statementIndex) {
Node = node;
Name = name;
Depth = depth;
NodeIndex = nodeIndex;
StatementIndex = statementIndex;
}
示例5: DeconstructMutationAssignment
public static JSExpression DeconstructMutationAssignment (
JSNode parentNode, JSBinaryOperatorExpression boe, TypeSystem typeSystem, TypeReference intermediateType
) {
var assignmentOperator = boe.Operator as JSAssignmentOperator;
if (assignmentOperator == null)
return null;
JSBinaryOperator replacementOperator;
if (!IntroduceEnumCasts.ReverseCompoundAssignments.TryGetValue(assignmentOperator, out replacementOperator))
return null;
var leftType = boe.Left.GetActualType(typeSystem);
var newBoe = new JSBinaryOperatorExpression(
JSOperator.Assignment, MakeLhsForAssignment(boe.Left),
new JSBinaryOperatorExpression(
replacementOperator, boe.Left, boe.Right, intermediateType
),
leftType
);
var result = ConvertReadExpressionToWriteExpression(newBoe, typeSystem);
if (parentNode is JSExpressionStatement) {
return result;
} else {
var comma = new JSCommaExpression(
newBoe, boe.Left
);
return comma;
}
}
示例6: SkipNode
private void SkipNode (JSNode node, string name, Indices indices, int depth) {
indices.GetNodeIndex();
if (node is JSStatement)
indices.GetStatementIndex();
foreach (var e in VisitChildren(node, indices, depth)) {
foreach (var c in e)
;
}
}
示例7: IsPropertySetterInvocation
public static bool IsPropertySetterInvocation(JSNode parentNode, JSBinaryOperatorExpression boe, out JSPropertyAccess pa)
{
var isValidParent =
(parentNode is JSExpressionStatement);
pa = boe.Left as JSPropertyAccess;
return (pa != null) &&
pa.IsWrite &&
(boe.Operator == JSOperator.Assignment) &&
isValidParent &&
CanConvertToInvocation(pa);
}
示例8: ReplaceChild
public override void ReplaceChild (JSNode oldChild, JSNode newChild) {
if (oldChild == null)
throw new ArgumentNullException("oldChild");
var stmt = newChild as JSStatement;
if (stmt == null)
return;
for (int i = 0, c = Statements.Count; i < c; i++) {
if (Statements[i] == oldChild)
Statements[i] = stmt;
}
}
示例9: IsPropertyGetterInvocation
public static bool IsPropertyGetterInvocation(JSNode parentNode, JSPropertyAccess pa)
{
var parentBoe = parentNode as JSBinaryOperatorExpression;
var parentUoe = parentNode as JSUnaryOperatorExpression;
bool isMutation = (
(parentUoe != null) &&
(parentUoe.Operator is JSUnaryMutationOperator)
) || (
(parentBoe != null) &&
(parentBoe.Operator is JSAssignmentOperator) &&
(pa == parentBoe.Left)
);
return !pa.IsWrite &&
!isMutation &&
CanConvertToInvocation(pa);
}
示例10: VisitNode
public override void VisitNode(JSNode node)
{
if (node == null)
{
return;
}
if (node.SymbolInfo != null /* && node.SymbolInfo.Inferred*/)
{
if ((ParentNode is JSForLoop && ((JSForLoop) ParentNode).Condition == node))
{
}
else
{
node.SymbolInfo = null;
}
}
VisitChildren(node);
}
示例11: VisitNode
private IEnumerable<State> VisitNode (JSNode node, string name = null, Indices indices = null, int depth = 0) {
int? statementIndex = null;
if (indices == null)
indices = new Indices();
int nodeIndex = indices.GetNodeIndex();
if (node is JSStatement)
statementIndex = indices.GetStatementIndex();
yield return new State(
node, name, depth, nodeIndex, statementIndex
);
foreach (var e in VisitChildren(node, indices, depth)) {
foreach (var c in e)
yield return c;
}
}
示例12: VisitNodeInternalDown
private void VisitNodeInternalDown(JSNode node)
{
if (node == null)
{
return;
}
foreach (var child in node.Children)
{
VisitNodeInternalDown(child);
}
if (node.SymbolInfo == null)
{
var childSymboInfo = node.Children.Where(item => item != null).Select(item => item.SymbolInfo).FirstOrDefault(item => item != null);
if (childSymboInfo != null)
{
node.SymbolInfo = new SymbolInfo(childSymboInfo.SequencePoints, true);
}
}
}
示例13: ReplaceChild
public override void ReplaceChild(JSNode oldChild, JSNode newChild)
{
if (oldChild == null)
throw new ArgumentNullException("oldChild");
if (CatchVariable == oldChild)
CatchVariable = (JSVariable)newChild;
if (Catch == oldChild)
Catch = (JSStatement)newChild;
if (Finally == oldChild)
Finally = (JSStatement)newChild;
Body.ReplaceChild(oldChild, newChild);
}
示例14: GetChild
protected static bool GetChild(JSNode parent, int index, out JSNode node, out string name)
{
var self = (JSLabelGroupStatement)parent;
if (index >= self.Labels.Count) {
node = null;
name = null;
return false;
}
node = self.Labels.AtIndex(index).Value;
name = "Labels";
return true;
}
示例15: ReplaceChild
public override void ReplaceChild(JSNode oldChild, JSNode newChild)
{
if (GenericArguments == null)
return;
var oldExpression = oldChild as JSExpression;
var newExpression = newChild as JSExpression;
if (
(oldExpression != null) &&
((newExpression != null) == (newChild != null))
) {
for (var i = 0; i < GenericArguments.Length; i++) {
if (GenericArguments[i] == oldExpression)
GenericArguments[i] = newExpression;
}
}
}