Search in sources :

Example 1 with LocalVariableInfo

use of org.ballerinalang.util.codegen.LocalVariableInfo in project ballerina by ballerina-lang.

the class ResourceImpl method getParamDetails.

@Override
public List<ParamDetail> getParamDetails() {
    LocalVariableAttributeInfo attributeInfo = (LocalVariableAttributeInfo) resourceInfo.getAttributeInfo(AttributeInfo.Kind.LOCAL_VARIABLES_ATTRIBUTE);
    List<ParamDetail> paramDetails = new ArrayList<>();
    for (LocalVariableInfo variableInfo : attributeInfo.getLocalVariableInfoEntries()) {
        paramDetails.add(new ParamDetail(variableInfo.getVariableType(), variableInfo.getVariableName()));
    }
    return paramDetails;
}
Also used : LocalVariableInfo(org.ballerinalang.util.codegen.LocalVariableInfo) LocalVariableAttributeInfo(org.ballerinalang.util.codegen.attributes.LocalVariableAttributeInfo) ParamDetail(org.ballerinalang.connector.api.ParamDetail) ArrayList(java.util.ArrayList)

Example 2 with LocalVariableInfo

use of org.ballerinalang.util.codegen.LocalVariableInfo in project ballerina by ballerina-lang.

the class BLangVMStructs method createBConnector.

/**
 * Create BConnector with given values.
 *
 * @param connectorInfo {@link ConnectorInfo} of the {@link BConnector}
 * @param values        field values of the connector ( including args ).
 * @return BStruct instance.
 */
public static BConnector createBConnector(ConnectorInfo connectorInfo, Object... values) {
    BConnector bConnector = new BConnector(connectorInfo.getType());
    final LocalVariableAttributeInfo localVar = (LocalVariableAttributeInfo) connectorInfo.getAttributeInfo(AttributeInfo.Kind.LOCAL_VARIABLES_ATTRIBUTE);
    int i = 0;
    int[] indexes = new int[] { -1, -1, -1, -1, -1, -1 };
    for (LocalVariableInfo variableInfo : localVar.getLocalVariables()) {
        if (values.length < i + 1) {
            break;
        }
        final BType varType = variableInfo.getVariableType();
        setValue(bConnector, indexes, varType.getTag(), values[i]);
    }
    return bConnector;
}
Also used : BConnector(org.ballerinalang.model.values.BConnector) LocalVariableInfo(org.ballerinalang.util.codegen.LocalVariableInfo) LocalVariableAttributeInfo(org.ballerinalang.util.codegen.attributes.LocalVariableAttributeInfo) BType(org.ballerinalang.model.types.BType)

Aggregations

LocalVariableInfo (org.ballerinalang.util.codegen.LocalVariableInfo)2 LocalVariableAttributeInfo (org.ballerinalang.util.codegen.attributes.LocalVariableAttributeInfo)2 ArrayList (java.util.ArrayList)1 ParamDetail (org.ballerinalang.connector.api.ParamDetail)1 BType (org.ballerinalang.model.types.BType)1 BConnector (org.ballerinalang.model.values.BConnector)1