void addKeyValueToWaitForAll(DiagnosticPos pos, Set<Whitespace> ws, String identifier, boolean containsExpr) { BLangWaitForAllExpr.BLangWaitKeyValue keyValue = TreeBuilder.createWaitKeyValueNode(); keyValue.addWS(ws); keyValue.pos = pos; // Add the key as an identifier BLangIdentifier key = (BLangIdentifier) TreeBuilder.createIdentifierNode(); key.setLiteral(false); key.setValue(identifier); keyValue.key = key; // Add the value. If it is a Identifier:expr pair then add the value by popping the expr from the expression // stack else the value is not assigned. if (containsExpr) { keyValue.valueExpr = (BLangExpression) exprNodeStack.pop(); } else { BLangSimpleVarRef varRef = (BLangSimpleVarRef) TreeBuilder.createSimpleVariableReferenceNode(); varRef.pos = pos; varRef.variableName = key; varRef.addWS(ws); varRef.pkgAlias = (BLangIdentifier) TreeBuilder.createIdentifierNode(); keyValue.keyExpr = varRef; } waitCollectionStack.peek().keyValuePairs.add(keyValue); } }
private BLangInvocation createInvocationNode(String functionName, List<BLangExpression> args, BType retType) { BLangInvocation invocationNode = (BLangInvocation) TreeBuilder.createInvocationNode(); BLangIdentifier name = (BLangIdentifier) TreeBuilder.createIdentifierNode(); name.setLiteral(false); name.setValue(functionName); invocationNode.name = name; invocationNode.pkgAlias = (BLangIdentifier) TreeBuilder.createIdentifierNode(); // TODO: 2/28/18 need to find a good way to refer to symbols invocationNode.symbol = symTable.rootScope.lookup(new Name(functionName)).symbol; invocationNode.type = retType; invocationNode.requiredArgs = args; return invocationNode; }
static BLangTypeInit createEmptyTypeInit(DiagnosticPos pos, BType type) { BLangTypeInit objectInitNode = (BLangTypeInit) TreeBuilder.createInitNode(); objectInitNode.pos = pos; objectInitNode.type = type; BLangInvocation invocationNode = (BLangInvocation) TreeBuilder.createInvocationNode(); invocationNode.symbol = ((BObjectTypeSymbol) type.tsymbol).initializerFunc.symbol; invocationNode.type = type; BLangIdentifier pkgNameNode = (BLangIdentifier) TreeBuilder.createIdentifierNode(); BLangIdentifier nameNode = (BLangIdentifier) TreeBuilder.createIdentifierNode(); nameNode.setLiteral(false); nameNode.setValue(Names.OBJECT_INIT_SUFFIX.getValue()); invocationNode.name = nameNode; invocationNode.pkgAlias = pkgNameNode; objectInitNode.initInvocation = invocationNode; return objectInitNode; }
private BLangInvocation createInvocationNode(BPackageSymbol pkgSymbol, String functionName, List<BLangExpression> args) { BLangInvocation invocationNode = (BLangInvocation) TreeBuilder.createInvocationNode(); BLangIdentifier name = (BLangIdentifier) TreeBuilder.createIdentifierNode(); name.setLiteral(false); name.setValue(functionName); invocationNode.name = name; invocationNode.pkgAlias = (BLangIdentifier) TreeBuilder.createIdentifierNode(); invocationNode.symbol = pkgSymbol.scope.lookup(new Name(functionName)).symbol; invocationNode.type = new BNilType(); invocationNode.requiredArgs = args; return invocationNode; }