Search in sources :

Example 11 with FunctionCall

use of claw.tatsu.xcodeml.abstraction.FunctionCall in project claw-compiler by C2SM-RCM.

the class ArrayToFctCall method transform.

@Override
public void transform(XcodeProgram xcodeml, Translator translator, Transformation other) {
    FfunctionType fctType = xcodeml.getTypeTable().getFunctionType(_replaceFct);
    // Prepare the function call
    FunctionCall fctCall = xcodeml.createFctCall(fctType.getReturnType(), _claw.value(ClawClause.FCT_NAME), _replaceFct.getType());
    for (String arg : _claw.values(ClawClause.FCT_PARAMETERS)) {
        fctCall.addArguments(xcodeml.createVar(FortranType.INTEGER, arg, Xscope.LOCAL));
    }
    List<Xnode> refs = XnodeUtil.getAllArrayReferencesInSiblings(_claw.getPragma(), _claw.value(ClawClause.ARRAY_NAME));
    for (Xnode ref : refs) {
        ref.insertAfter(fctCall.cloneNode());
        ref.delete();
    }
    fctCall.delete();
    removePragma();
    transformed();
}
Also used : FfunctionType(claw.tatsu.xcodeml.xnode.fortran.FfunctionType) FunctionCall(claw.tatsu.xcodeml.abstraction.FunctionCall)

Example 12 with FunctionCall

use of claw.tatsu.xcodeml.abstraction.FunctionCall in project claw-compiler by C2SM-RCM.

the class ScaForward method analyze.

@Override
public boolean analyze(XcodeProgram xcodeml, Translator translator) {
    Xnode next = _claw.getPragma().nextSibling();
    if (next == null) {
        xcodeml.addError("Directive is not followed by a valid statement.", _claw.getPragma());
        return false;
    }
    if (Xnode.isOfCode(next, Xcode.EXPR_STATEMENT) || Xnode.isOfCode(next, Xcode.F_ASSIGN_STATEMENT)) {
        _isNestedInAssignment = Xnode.isOfCode(next, Xcode.F_ASSIGN_STATEMENT);
        Xnode fctCallNode = next.matchSeq(Xcode.FUNCTION_CALL);
        if (fctCallNode != null) {
            _fCall = new FunctionCall(fctCallNode);
            return analyzeForward(xcodeml);
        }
    } else if (Xnode.isOfCode(next, Xcode.F_DO_STATEMENT)) {
        _doStatements = new NestedDoStatement(next);
        return analyzeForwardWithDo(xcodeml);
    }
    xcodeml.addError("Directive is not followed by a valid statement.", _claw.getPragma());
    return false;
}
Also used : Xnode(claw.tatsu.xcodeml.xnode.common.Xnode) NestedDoStatement(claw.tatsu.xcodeml.abstraction.NestedDoStatement) FunctionCall(claw.tatsu.xcodeml.abstraction.FunctionCall)

Aggregations

FunctionCall (claw.tatsu.xcodeml.abstraction.FunctionCall)12 Xnode (claw.tatsu.xcodeml.xnode.common.Xnode)7 FfunctionDefinition (claw.tatsu.xcodeml.xnode.fortran.FfunctionDefinition)3 FfunctionType (claw.tatsu.xcodeml.xnode.fortran.FfunctionType)3 Context (claw.tatsu.common.Context)2 IllegalTransformationException (claw.tatsu.xcodeml.exception.IllegalTransformationException)2 Transformation (claw.shenron.transformation.Transformation)1 Translator (claw.shenron.translator.Translator)1 Target (claw.tatsu.common.Target)1 DataMovement (claw.tatsu.directive.common.DataMovement)1 Directive (claw.tatsu.directive.common.Directive)1 DirectiveGenerator (claw.tatsu.directive.generator.DirectiveGenerator)1 Range (claw.tatsu.primitive.Range)1 NestedDoStatement (claw.tatsu.xcodeml.abstraction.NestedDoStatement)1 Xblock (claw.tatsu.xcodeml.abstraction.Xblock)1 XnodeUtil (claw.tatsu.xcodeml.xnode.XnodeUtil)1 Xattr (claw.tatsu.xcodeml.xnode.common.Xattr)1 Xcode (claw.tatsu.xcodeml.xnode.common.Xcode)1 XcodeProgram (claw.tatsu.xcodeml.xnode.common.XcodeProgram)1 Xid (claw.tatsu.xcodeml.xnode.common.Xid)1