use of org.wso2.ballerinalang.compiler.semantics.model.types.BType in project ballerina by ballerina-lang.
the class SymbolResolver method visit.
public void visit(BLangTupleTypeNode tupleTypeNode) {
List<BType> memberTypes = tupleTypeNode.memberTypeNodes.stream().map(memTypeNode -> resolveTypeNode(memTypeNode, env)).collect(Collectors.toList());
resultType = new BTupleType(memberTypes);
}
use of org.wso2.ballerinalang.compiler.semantics.model.types.BType in project ballerina by ballerina-lang.
the class SymbolResolver method getBinaryOpForNullChecks.
private BSymbol getBinaryOpForNullChecks(OperatorKind opKind, BType lhsType, BType rhsType) {
if (opKind != OperatorKind.EQUAL && opKind != OperatorKind.NOT_EQUAL) {
return symTable.notFoundSymbol;
}
int opcode = (opKind == OperatorKind.EQUAL) ? InstructionCodes.REQ_NULL : InstructionCodes.RNE_NULL;
if (lhsType.tag == TypeTags.NULL && (rhsType.tag == TypeTags.STRUCT || rhsType.tag == TypeTags.CONNECTOR || rhsType.tag == TypeTags.ENUM || rhsType.tag == TypeTags.INVOKABLE)) {
List<BType> paramTypes = Lists.of(lhsType, rhsType);
List<BType> retTypes = Lists.of(symTable.booleanType);
BInvokableType opType = new BInvokableType(paramTypes, retTypes, null);
return new BOperatorSymbol(names.fromString(opKind.value()), null, opType, null, opcode);
}
if ((lhsType.tag == TypeTags.STRUCT || lhsType.tag == TypeTags.CONNECTOR || lhsType.tag == TypeTags.ENUM || lhsType.tag == TypeTags.INVOKABLE) && rhsType.tag == TypeTags.NULL) {
List<BType> paramTypes = Lists.of(lhsType, rhsType);
List<BType> retTypes = Lists.of(symTable.booleanType);
BInvokableType opType = new BInvokableType(paramTypes, retTypes, null);
return new BOperatorSymbol(names.fromString(opKind.value()), null, opType, null, opcode);
}
if (lhsType.tag == TypeTags.ENUM && rhsType.tag == TypeTags.ENUM && lhsType == rhsType) {
opcode = (opKind == OperatorKind.EQUAL) ? InstructionCodes.REQ : InstructionCodes.RNE;
List<BType> paramTypes = Lists.of(lhsType, rhsType);
List<BType> retTypes = Lists.of(symTable.booleanType);
BInvokableType opType = new BInvokableType(paramTypes, retTypes, null);
return new BOperatorSymbol(names.fromString(opKind.value()), null, opType, null, opcode);
}
return symTable.notFoundSymbol;
}
use of org.wso2.ballerinalang.compiler.semantics.model.types.BType in project ballerina by ballerina-lang.
the class SymbolResolver method visit.
public void visit(BLangUnionTypeNode unionTypeNode) {
Set<BType> memberTypes = unionTypeNode.memberTypeNodes.stream().map(memTypeNode -> resolveTypeNode(memTypeNode, env)).flatMap(memBType -> memBType.tag == TypeTags.UNION ? ((BUnionType) memBType).memberTypes.stream() : Stream.of(memBType)).collect(Collectors.toSet());
resultType = new BUnionType(null, memberTypes, memberTypes.contains(symTable.nullType));
}
use of org.wso2.ballerinalang.compiler.semantics.model.types.BType in project ballerina by ballerina-lang.
the class SymbolResolver method resolveOperator.
private BSymbol resolveOperator(ScopeEntry entry, List<BType> types) {
BSymbol foundSymbol = symTable.notFoundSymbol;
while (entry != NOT_FOUND_ENTRY) {
BInvokableType opType = (BInvokableType) entry.symbol.type;
if (types.size() == opType.paramTypes.size()) {
boolean match = true;
for (int i = 0; i < types.size(); i++) {
if (types.get(i).tag != opType.paramTypes.get(i).tag) {
match = false;
}
}
if (match) {
foundSymbol = entry.symbol;
break;
}
}
entry = entry.next;
}
return foundSymbol;
}
use of org.wso2.ballerinalang.compiler.semantics.model.types.BType in project ballerina by ballerina-lang.
the class TaintAnalyzer method isEntryPoint.
// Private methods related to invokable node analysis and taint-table generation.
private boolean isEntryPoint(BLangFunction funcNode) {
// Service resources are handled through BLangResource visitor.
boolean isMainFunction = false;
if (funcNode.name.value.equals(MAIN_FUNCTION_NAME) && funcNode.symbol.params.size() == 1 && funcNode.symbol.retParams.size() == 0) {
BType paramType = funcNode.symbol.params.get(0).type;
BArrayType arrayType = (BArrayType) paramType;
if (paramType.tag == TypeTags.ARRAY && arrayType.eType.tag == TypeTags.STRING) {
isMainFunction = true;
}
}
return isMainFunction;
}
Aggregations