@Override public CAstNode visitLabel(Label node, WalkContext arg) { String label = node.getName(); return Ast.makeConstant(label); }
@Override public CAstNode visitRegExpLiteral(RegExpLiteral node, WalkContext arg) { CAstNode flagsNode = Ast.makeConstant(node.getFlags()); CAstNode valNode = Ast.makeConstant(node.getValue()); return handleNew(arg, "RegExp", new CAstNode[]{ flagsNode, valNode }); }
@Override public CAstNode visitNumberLiteral(NumberLiteral node, WalkContext arg) { return Ast.makeConstant(node.getDouble()); }
@Override public CAstNode visitStringLiteral(StringLiteral node, WalkContext arg) { return Ast.makeConstant(node.getValue()); }
private CAstNode copyConstant(CAstNode root, NodePos context, Map<Pair<CAstNode, NoKey>, CAstNode> nodeMap) { CAstNode newNode = Ast.makeConstant(root.getValue()); nodeMap.put(Pair.make(root, context.key()), newNode); return newNode; }
private CAstNode copyConstant(CAstNode root, NodePos context, Map<Pair<CAstNode, NoKey>, CAstNode> nodeMap) { CAstNode newNode = Ast.makeConstant(root.getValue()); nodeMap.put(Pair.make(root, context.key()), newNode); return newNode; }
private CAstNode visit(TypeLiteral n, WalkContext context) { String typeName = fIdentityMapper.typeToTypeID(n.resolveTypeBinding()); return makeNode(context, fFactory, n, CAstNode.TYPE_LITERAL_EXPR, fFactory.makeConstant(typeName)); }
@Override protected CAstNode copyNodes(CAstNode root, CAstControlFlowMap cfg, NonCopyingContext c, Map<Pair<CAstNode, NoKey>, CAstNode> nodeMap) { if (root.getKind() == CAstNode.ASSIGN) { ((AssignSkipContext)c).skip.add(root.getChild(0)); } if (root.getKind() == CAstNode.VAR && constants.containsKey(root.getChild(0).getValue()) && ! ((AssignSkipContext)c).skip.contains(root)) { return Ast.makeConstant(constants.get(root.getChild(0).getValue())); } else { return super.copyNodes(root, cfg, c, nodeMap); } }
@Override protected CAstNode copyNodes(CAstNode root, CAstControlFlowMap cfg, NonCopyingContext c, Map<Pair<CAstNode, NoKey>, CAstNode> nodeMap) { if (root.getKind() == CAstNode.ASSIGN) { ((AssignSkipContext)c).skip.add(root.getChild(0)); } if (root.getKind() == CAstNode.VAR && constants.containsKey(root.getChild(0).getValue()) && ! ((AssignSkipContext)c).skip.contains(root)) { return Ast.makeConstant(constants.get(root.getChild(0).getValue())); } else { return super.copyNodes(root, cfg, c, nodeMap); } }
private CAstNode createReturnFixup(ExtractionPos context, CAstEntity entity) { return Ast.makeNode(IF_STMT, Ast.makeNode(BINARY_EXPR, CAstOperator.OP_EQ, addExnFlow(Ast.makeNode(OBJECT_REF, addExnFlow(makeVarRef("re$"), JavaScriptTypes.ReferenceError, entity, context), Ast.makeConstant("type")), JavaScriptTypes.TypeError, entity, context), Ast.makeConstant("return")), Ast.makeNode(RETURN, addExnFlow(Ast.makeNode(OBJECT_REF, addExnFlow(makeVarRef("re$"), JavaScriptTypes.ReferenceError, entity, context), Ast.makeConstant("value")), JavaScriptTypes.TypeError, entity, context))); }
@Override public CAstNode visitPropertyGet(PropertyGet node, WalkContext arg) { CAstNode elt = Ast.makeConstant(node.getProperty().getString()); return visitObjectRead(node, node.getTarget(), elt, arg); }
private CAstNode visit(PostfixExpression n, WalkContext context) { CAstOperator op = (n.getOperator() == PostfixExpression.Operator.DECREMENT) ? CAstOperator.OP_SUB : CAstOperator.OP_ADD; return makeNode(context, fFactory, n, CAstNode.ASSIGN_POST_OP, visitNode(n.getOperand(), context), fFactory.makeConstant(1), op); }
private CAstNode visit(ThisExpression n, WalkContext context) { if (n.getQualifier() != null) { ITypeBinding owningType = n.getQualifier().resolveTypeBinding(); TypeReference owningTypeRef = fIdentityMapper.getTypeRef(owningType); return makeNode(context, fFactory, n, CAstNode.THIS, fFactory.makeConstant(owningTypeRef)); } else return makeNode(context, fFactory, n, CAstNode.THIS); }
private CAstNode visit(InstanceofExpression n, WalkContext context) { return makeNode(context, fFactory, n, CAstNode.INSTANCEOF, fFactory.makeConstant(fTypeDict.getCAstTypeFor(n.getRightOperand() .resolveBinding())), visitNode(n.getLeftOperand(), context)); }
private CAstNode copyIncludeExpr(CAstNode expr) { if (expr.getValue() != null) { return Ast.makeConstant(expr.getValue()); } else if (expr instanceof CAstOperator) { return expr; } else { CAstNode nc[] = new CAstNode[expr.getChildCount()]; for (int i = 0; i < expr.getChildCount(); i++) { nc[i] = copyIncludeExpr(expr.getChild(i)); } return Ast.makeNode(expr.getKind(), nc); } }
private CAstNode copyIncludeExpr(CAstNode expr) { if (expr.getValue() != null) { return Ast.makeConstant(expr.getValue()); } else if (expr instanceof CAstOperator) { return expr; } else { CAstNode nc[] = new CAstNode[expr.getChildCount()]; for (int i = 0; i < expr.getChildCount(); i++) { nc[i] = copyIncludeExpr(expr.getChild(i)); } return Ast.makeNode(expr.getKind(), nc); } }
private CAstNode visit(SuperFieldAccess n, WalkContext context) { CAstNode targetNode; if (n.getQualifier() == null) targetNode = makeNode(context, fFactory, n, CAstNode.SUPER); else { TypeReference owningTypeRef = fIdentityMapper.getTypeRef(n.getQualifier().resolveTypeBinding()); targetNode = makeNode(context, fFactory, n, CAstNode.SUPER, fFactory.makeConstant(owningTypeRef)); } return createFieldAccess(targetNode, n.getName().getIdentifier(), n.resolveFieldBinding(), n, context); }
private CAstNode visit(SuperMethodInvocation n, WalkContext context) { CAstNode target; if (n.getQualifier() == null) target = makeNode(context, fFactory, n, CAstNode.SUPER); else { TypeReference owningTypeRef = fIdentityMapper.getTypeRef(n.getQualifier().resolveTypeBinding()); target = makeNode(context, fFactory, n, CAstNode.SUPER, fFactory.makeConstant(owningTypeRef)); } // GENERICS getMethodDeclaration() return createMethodInvocation(n, n.resolveMethodBinding().getMethodDeclaration(), target, n.arguments(), context); }
private CAstNode visit(ArrayAccess n, WalkContext context) { TypeReference eltTypeRef = fIdentityMapper.getTypeRef(n.resolveTypeBinding()); CAstNode cast = makeNode(context, fFactory, n, CAstNode.ARRAY_REF, visitNode(n.getArray(), context), fFactory.makeConstant(eltTypeRef), visitNode(n.getIndex(), context)); hookUpNPETargets(n, context); context.cfg().map(n, cast); return cast; }
private CAstNode visit(CatchClause n, WalkContext context) { Block body = n.getBody(); SingleVariableDeclaration formal = n.getException(); CAstNode excDecl = makeNode(context, fFactory, n, CAstNode.CATCH, fFactory.makeConstant(formal.getName().getIdentifier()), visitNode(body, context)); CAstNode localScope = makeNode(context, fFactory, n, CAstNode.LOCAL_SCOPE, excDecl); context.cfg().map(n, excDecl); context.getNodeTypeMap().add(excDecl, fTypeDict.getCAstTypeFor(n.getException().resolveBinding().getType())); return localScope; }