当前位置: 首页>>代码示例>>Java>>正文


Java FunctionCall类代码示例

本文整理汇总了Java中org.mozilla.javascript.ast.FunctionCall的典型用法代码示例。如果您正苦于以下问题:Java FunctionCall类的具体用法?Java FunctionCall怎么用?Java FunctionCall使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FunctionCall类属于org.mozilla.javascript.ast包,在下文中一共展示了FunctionCall类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processClosureCall

import org.mozilla.javascript.ast.FunctionCall; //导入依赖的package包/类
/**
 * call a function through a closure
 */
private void processClosureCall(FunctionCall fc) {

	AstNode target = fc.getTarget();
	ITypeTerm funVar = processExpression(target);

	// for call foo(E_1,...,E_n), equate the type of the call to ret(foo)
	FunctionCallTerm callTerm = findOrCreateFunctionCallTerm(fc);
	callTerm.setTarget(funVar);
	ITypeTerm retTerm = findOrCreateFunctionReturnTerm(funVar, fc.getArguments().size(), fc.getLineno(), fc);
	addTypeEqualityConstraint(callTerm, retTerm, fc.getLineno(), null);

	// for call foo(E_1,...,E_n), generate constraints |E_i| <: Param(foo,i)
	for (int i=0; i < fc.getArguments().size(); i++){
		AstNode arg = fc.getArguments().get(i);
		ITypeTerm argExp = processExpression(arg);
		ITypeTerm paramExp = findOrCreateFunctionParamTerm(funVar, i, fc.getArguments().size(), fc.getLineno());
		processCopy(arg, argExp, paramExp,
				fc.getLineno(), (solution) ->
						subtypeError("bad argument " + shortSrc(arg) + " passed to function",
								solution.typeOfTerm(argExp), solution.typeOfTerm(paramExp), locationOf(arg)));
	}
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:26,代码来源:ConstraintVisitor.java

示例2: getJavaMethodSelector

import org.mozilla.javascript.ast.FunctionCall; //导入依赖的package包/类
private MethodReference getJavaMethodSelector(AstNode node) {
    if (!(node instanceof FunctionCall)) {
        return null;
    }
    FunctionCall call = (FunctionCall) node;
    if (!isJavaMethodRepository(call.getTarget())) {
        return null;
    }
    if (call.getArguments().size() != 1) {
        diagnostics.error(location, "javaMethods.get method should take exactly one argument");
        return null;
    }
    StringBuilder nameBuilder = new StringBuilder();
    if (!extractMethodName(call.getArguments().get(0), nameBuilder)) {
        diagnostics.error(location, "javaMethods.get method should take string constant");
        return null;
    }

    MethodReference method = MethodReference.parseIfPossible(nameBuilder.toString());
    if (method == null) {
        diagnostics.error(location, "Wrong method reference: " + nameBuilder);
    }
    return method;
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:25,代码来源:JavaInvocationProcessor.java

示例3: tryJavaInvocation

import org.mozilla.javascript.ast.FunctionCall; //导入依赖的package包/类
private boolean tryJavaInvocation(FunctionCall node) throws IOException {
    if (!(node.getTarget() instanceof PropertyGet)) {
        return false;
    }

    PropertyGet propertyGet = (PropertyGet) node.getTarget();
    String callMethod = getJavaMethod(propertyGet.getTarget());
    if (callMethod == null || !propertyGet.getProperty().getIdentifier().equals("invoke")) {
        return false;
    }

    MethodReference method = MethodReference.parseIfPossible(callMethod);
    if (method == null) {
        return false;
    }

    writer.appendMethodBody(method).append('(');
    printList(node.getArguments());
    writer.append(')');
    return true;
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:22,代码来源:AstWriter.java

示例4: createLookupString

import org.mozilla.javascript.ast.FunctionCall; //导入依赖的package包/类
private String createLookupString(FunctionCall fn)
{
	StringBuilder sb = new StringBuilder();
	String name = "";
	switch(fn.getTarget().getType())
	{
		case Token.NAME : name = ((Name) fn.getTarget()).getIdentifier();
		break;
	}
	sb.append(name);
	sb.append("(");
	Iterator<AstNode> i = fn.getArguments().iterator();
	while (i.hasNext())
	{
		i.next();
		sb.append("p");
		if(i.hasNext())
			sb.append(",");	
	}
	sb.append(")");
	return sb.toString();
}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:23,代码来源:JavaScriptCompletionResolver.java

示例5: getFunctionNameLookup

import org.mozilla.javascript.ast.FunctionCall; //导入依赖的package包/类
@Override
public String getFunctionNameLookup(FunctionCall call,
		SourceCompletionProvider provider) {
	if (call != null) {
		StringBuilder sb = new StringBuilder();
		if (call.getTarget() instanceof PropertyGet) {
			PropertyGet get = (PropertyGet) call.getTarget();
			sb.append(get.getProperty().getIdentifier());
		}
		sb.append("(");
		int count = call.getArguments().size();
		for (int i = 0; i < count; i++) {
			sb.append("p");
			if (i < count - 1) {
				sb.append(",");
			}
		}
		sb.append(")");
		return sb.toString();
	}
	return null;
}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:23,代码来源:JavaScriptCompletionResolver.java

示例6: transformFunctionCall

import org.mozilla.javascript.ast.FunctionCall; //导入依赖的package包/类
private Node transformFunctionCall(FunctionCall node) {
    Node call = createCallOrNew(Token.CALL, transform(node.getTarget()));
    call.setLineno(node.getLineno());
    decompiler.addToken(Token.LP);
    List<AstNode> args = node.getArguments();
    for (int i = 0; i < args.size(); i++) {
        AstNode arg = args.get(i);
        call.addChildToBack(transform(arg));
        if (i < args.size() - 1) {
            decompiler.addToken(Token.COMMA);
        }
    }
    decompiler.addToken(Token.RP);
    return call;
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:16,代码来源:IRFactory.java

示例7: findFunDecl

import org.mozilla.javascript.ast.FunctionCall; //导入依赖的package包/类
/**
 * Finds the declaration of the called function. Assumes that the call's target
 * is a Name, which is passed as the second parameter.
 *
 */
static FunctionNode findFunDecl(FunctionCall fc, Name funName){
	List<FunctionNode> funsFound = findFunDecl2(fc, new ArrayList<FunctionNode>());
	for (int i=0; i < funsFound.size(); i++){
		FunctionNode fun = funsFound.get(i);
		if (funName.getIdentifier().equals(fun.getName())){
			return fun;
		}
	}
	return null;
}
 
开发者ID:Samsung,项目名称:SJS,代码行数:16,代码来源:ConstraintGenUtil.java

示例8: isSyntacticModuleRequire

import org.mozilla.javascript.ast.FunctionCall; //导入依赖的package包/类
/**
   * Syntactically identify module imports
   */
  private boolean isSyntacticModuleRequire(FunctionCall fc) {
AstNode target = fc.getTarget();
      if (target instanceof Name) {
          Name name = (Name)target;
          return name.getIdentifier().equals("require") && fc.getArguments().size() == 1 && fc.getArguments().get(0) instanceof StringLiteral;
      } else {
          return false;
      }
  }
 
开发者ID:Samsung,项目名称:SJS,代码行数:13,代码来源:ConstraintVisitor.java

示例9: visit

import org.mozilla.javascript.ast.FunctionCall; //导入依赖的package包/类
@Override
public boolean visit(AstNode node) {
	if( Token.NAME == node.getType()){
		if(node.getParent().getType() == Token.CALL){
			FunctionCall parent = (FunctionCall)node.getParent();
			if(parent.getTarget()==node){
				resultSoFar.add(safeGetString(node));
			}
		}
	}
	return true;
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:13,代码来源:FormulaInfo.java

示例10: visit

import org.mozilla.javascript.ast.FunctionCall; //导入依赖的package包/类
@Override
public boolean visit(AstNode node) {
    if (node instanceof FunctionCall) {
        return visit((FunctionCall) node);
    }
    return true;
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:8,代码来源:JavaInvocationProcessor.java

示例11: print

import org.mozilla.javascript.ast.FunctionCall; //导入依赖的package包/类
private void print(FunctionCall node, int precedence) throws IOException {
    if (tryJavaInvocation(node)) {
        return;
    }

    if (precedence < PRECEDENCE_FUNCTION) {
        writer.append('(');
    }
    int innerPrecedence = node instanceof NewExpression ? PRECEDENCE_FUNCTION - 1 : PRECEDENCE_FUNCTION;
    if (node instanceof NewExpression) {
        writer.append("new ");
    }
    print(node.getTarget(), innerPrecedence);
    writer.append('(');
    printList(node.getArguments());
    writer.append(')');
    if (node instanceof NewExpression) {
        writer.ws();
        NewExpression newExpr = (NewExpression) node;
        if (newExpr.getInitializer() != null) {
            print(newExpr.getInitializer());
        }
    }
    if (precedence < PRECEDENCE_FUNCTION) {
        writer.append(')');
    }
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:28,代码来源:AstWriter.java

示例12: findFunctionCallFromNode

import org.mozilla.javascript.ast.FunctionCall; //导入依赖的package包/类
/**
 * Iterate back up through parent nodes and check whether inside a function
 * 
 * If the node is a function, then the Parsed parent node structure is:
 * FunctionCall
 *   --> PropertyGet
 *    --> Name
 * 
 * Anything other structure should be rejected.
 * 
 * @param node
 * @return
 */
public static FunctionCall findFunctionCallFromNode(AstNode node) {
	AstNode parent = node;
	for(int i=0; i<3; i++)
	{
		if(parent == null || (parent instanceof AstRoot))
			break;
		if (parent instanceof FunctionCall) {
			return (FunctionCall) parent;
		}
		parent = parent.getParent();
	}
	return null;
}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:27,代码来源:JavaScriptHelper.java

示例13: getFunctionNameLookup

import org.mozilla.javascript.ast.FunctionCall; //导入依赖的package包/类
@Override
public String getFunctionNameLookup(FunctionCall call, SourceCompletionProvider provider) {
	if (call != null) {
		StringBuilder sb = new StringBuilder();
		if (call.getTarget() instanceof PropertyGet) {
			PropertyGet get = (PropertyGet) call.getTarget();
			sb.append(get.getProperty().getIdentifier());
		}
		sb.append("(");
		int count = call.getArguments().size();
		
		for (int i = 0; i < count; i++) {
			AstNode paramNode = call.getArguments().get(i);
			JavaScriptResolver resolver = provider.getJavaScriptEngine().getJavaScriptResolver(provider);
			Logger.log("PARAM: " + JavaScriptHelper.convertNodeToSource(paramNode));
			try
			{
				TypeDeclaration type = resolver.resolveParamNode(JavaScriptHelper.convertNodeToSource(paramNode));
				String resolved = type != null ? type.getQualifiedName() : "any";
				sb.append(resolved);
				if (i < count - 1) {
					sb.append(",");
				}
			}
			catch(IOException io){io.printStackTrace();}
		}
		sb.append(")");
		return sb.toString();
	}
	return null;
}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:32,代码来源:JSR223JavaScriptCompletionResolver.java

示例14: collectAllNodes

import org.mozilla.javascript.ast.FunctionCall; //导入依赖的package包/类
/**
 * Get all nodes within AstNode and add to an ArrayList
 * 
 * @param node
 */
private void collectAllNodes(AstNode node) {
	if (node.getType() == Token.CALL) {
		// collect all argument nodes
		FunctionCall call = (FunctionCall) node;
		Iterator<AstNode> args = call.getArguments().iterator();
		while (args.hasNext()) {
			AstNode arg = args.next();
			VisitorAll all = new VisitorAll();
			arg.visit(all);
			paramNodes.addAll(all.getAllNodes());
		}
	}
}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:19,代码来源:JavaScriptCompletionResolver.java

示例15: isParameter

import org.mozilla.javascript.ast.FunctionCall; //导入依赖的package包/类
/**
 * Check the function that a name may belong to contains this actual
 * parameter
 * 
 * @param node Node to check
 * @return true if the function contains the parameter
 */
private boolean isParameter(AstNode node) {
	if (paramNodes.contains(node))
		return true;
	// get all params from this function too
	FunctionCall fc = JavaScriptHelper.findFunctionCallFromNode(node);
	if (fc != null && !(node == fc)) {
		collectAllNodes(fc);
		if (paramNodes.contains(node)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:bobbylight,项目名称:RSTALanguageSupport,代码行数:21,代码来源:JavaScriptCompletionResolver.java


注:本文中的org.mozilla.javascript.ast.FunctionCall类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。