Search in sources :

Example 16 with Context

use of claw.tatsu.common.Context in project claw-compiler by C2SM-RCM.

the class XnodeTest method hasBodyTest.

@Test
public void hasBodyTest() {
    Context context = new TestContext();
    List<Xcode> expectedNodeWithBody = new ArrayList<>(Arrays.asList(Xcode.ASSOCIATE_STATEMENT, Xcode.BLOCK_STATEMENT, Xcode.CRITICAL_STATEMENT, Xcode.ELSE, Xcode.F_CASE_LABEL, Xcode.F_DO_CONCURRENT_STATEMENT, Xcode.F_DO_STATEMENT, Xcode.F_DO_WHILE_STATEMENT, Xcode.F_FUNCTION_DEFINITION, Xcode.FOR_ALL_STATEMENT, Xcode.THEN, Xcode.TYPE_GUARD));
    for (Xcode x : expectedNodeWithBody) {
        assertTrue(x.hasBody());
    }
    XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
    for (Xcode opcode : Xcode.values()) {
        Xnode n = xcodeml.createNode(opcode);
        if (expectedNodeWithBody.contains(n.opcode())) {
            assertTrue(n.opcode().hasBody());
            assertTrue(n.hasBody());
        } else {
            assertFalse(n.opcode().hasBody());
            assertFalse(n.hasBody());
        }
    }
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) TestContext(helper.Utils.TestContext) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 17 with Context

use of claw.tatsu.common.Context in project claw-compiler by C2SM-RCM.

the class XnodeTest method deletedTest.

@Test
public void deletedTest() {
    Context context = new TestContext();
    XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
    Xnode n1 = xcodeml.createNode(Xcode.F_BASIC_TYPE);
    assertFalse(n1.isDeleted());
    n1.delete();
    assertTrue(n1.isDeleted());
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) TestContext(helper.Utils.TestContext) Test(org.junit.Test)

Example 18 with Context

use of claw.tatsu.common.Context in project claw-compiler by C2SM-RCM.

the class XnodeTest method isConstantTest.

@Test
public void isConstantTest() {
    Context context = new TestContext();
    XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
    Xnode n1 = xcodeml.createNode(Xcode.F_BASIC_TYPE);
    Xnode n2 = xcodeml.createNode(Xcode.F_REAL_CONSTANT);
    Xnode n3 = xcodeml.createNode(Xcode.F_INT_CONSTANT);
    Xnode n4 = xcodeml.createNode(Xcode.F_COMPLEX_CONSTANT);
    Xnode n5 = xcodeml.createNode(Xcode.F_LOGICAL_CONSTANT);
    Xnode n6 = xcodeml.createNode(Xcode.F_CHARACTER_CONSTANT);
    assertFalse(n1.isConstant());
    assertTrue(n2.isConstant());
    assertTrue(n3.isConstant());
    assertTrue(n4.isConstant());
    assertTrue(n5.isConstant());
    assertTrue(n6.isConstant());
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) TestContext(helper.Utils.TestContext) Test(org.junit.Test)

Example 19 with Context

use of claw.tatsu.common.Context in project claw-compiler by C2SM-RCM.

the class XnodeTest method enhancedInfoTest.

@Test
public void enhancedInfoTest() {
    Context context = new TestContext();
    String filename = "dummy.f90";
    XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
    Xnode n1 = xcodeml.createNode(Xcode.VAR_DECL);
    n1.setLine(1);
    n1.setFilename(filename);
    assertEquals(1, n1.lineNo());
    assertEquals(filename, n1.filename());
    Xnode n2 = xcodeml.createNode(Xcode.VAR_DECL);
    n1.copyEnhancedInfo(n2);
    assertEquals(1, n2.lineNo());
    assertEquals(filename, n2.filename());
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) TestContext(helper.Utils.TestContext) Test(org.junit.Test)

Example 20 with Context

use of claw.tatsu.common.Context in project claw-compiler by C2SM-RCM.

the class XnodeTest method constructStringTest.

@Test
public void constructStringTest() {
    Context context = new TestContext();
    Xnode arg1Node = XmlHelper.createXnode(ARG_1);
    assertNotNull(arg1Node);
    assertEquals("q(:,1:60)", arg1Node.constructRepresentation(false, false));
    assertEquals("q", arg1Node.constructRepresentation(false, true));
    Xnode arg2Node = XmlHelper.createXnode(ARG_2);
    assertNotNull(arg2Node);
    assertEquals("p(:,:)", arg2Node.constructRepresentation(false, false));
    assertEquals("p", arg2Node.constructRepresentation(false, true));
    Xnode arg3Node = XmlHelper.createXnode(ARG_3);
    assertNotNull(arg3Node);
    assertEquals("ty%y(p,:)", arg3Node.constructRepresentation(false, false));
    assertEquals("ty%y", arg3Node.constructRepresentation(false, true));
    Xnode arg4Node = XmlHelper.createXnode(ARG_4);
    assertNotNull(ARG_4);
    assertEquals("nproma=nproma", arg4Node.constructRepresentation(true, false));
    assertEquals("nproma", arg4Node.constructRepresentation(false, false));
    Xnode arg5Node = XmlHelper.createXnode(ARG_5);
    assertNotNull(arg5Node);
    assertEquals("first%middle%end", arg5Node.constructRepresentation(false, false));
    Xnode arg6Node = XmlHelper.createXnode(ARG_6);
    assertNotNull(arg6Node);
    assertEquals("first%middle%end(p,:)", arg6Node.constructRepresentation(false, false));
    assertEquals("first%middle%end", arg6Node.constructRepresentation(false, true));
    Xnode arg7Node = XmlHelper.createXnode(ARG_7);
    assertNotNull(arg7Node);
    assertEquals("tend(blockid)%t(jl,:)", arg7Node.constructRepresentation(false, false));
    Xnode arg8Node = XmlHelper.createXnode(ARG_8);
    assertNotNull(arg8Node);
    assertEquals("tend(blockid)%t(jl,:,:)", arg8Node.constructRepresentation(false, false));
    Xnode arg9Node = XmlHelper.createXnode(ARG_9);
    assertNotNull(arg9Node);
    assertEquals("q(:)", arg9Node.constructRepresentation(false, false));
    Xnode arg10Node = XmlHelper.createXnode(ARG_10);
    assertNotNull(arg10Node);
    assertEquals("q", arg10Node.constructRepresentation(false, false));
    XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
    Xnode n1 = xcodeml.createNode(Xcode.F_PRAGMA_STATEMENT);
    assertEquals("", n1.constructRepresentation(false, false));
    Xnode n2 = xcodeml.createNode(Xcode.F_DO_STATEMENT);
    assertEquals("", n2.constructRepresentation(false, false));
    assertEquals("", n2.constructRepresentation(false, true));
}
Also used : Context(claw.tatsu.common.Context) TestContext(helper.Utils.TestContext) TestContext(helper.Utils.TestContext) Test(org.junit.Test)

Aggregations

Context (claw.tatsu.common.Context)54 TestContext (helper.Utils.TestContext)44 Test (org.junit.Test)43 Xnode (claw.tatsu.xcodeml.xnode.common.Xnode)27 XcodeProgram (claw.tatsu.xcodeml.xnode.common.XcodeProgram)22 FfunctionDefinition (claw.tatsu.xcodeml.xnode.fortran.FfunctionDefinition)12 IllegalTransformationException (claw.tatsu.xcodeml.exception.IllegalTransformationException)9 Xid (claw.tatsu.xcodeml.xnode.common.Xid)4 FfunctionType (claw.tatsu.xcodeml.xnode.fortran.FfunctionType)4 PromotionInfo (claw.tatsu.xcodeml.abstraction.PromotionInfo)3 Xblock (claw.tatsu.xcodeml.abstraction.Xblock)3 FbasicType (claw.tatsu.xcodeml.xnode.fortran.FbasicType)3 FmoduleDefinition (claw.tatsu.xcodeml.xnode.fortran.FmoduleDefinition)3 Configuration (claw.wani.x2t.configuration.Configuration)3 ClawTranslator (claw.wani.x2t.translator.ClawTranslator)3 ArrayList (java.util.ArrayList)3 DirectiveGenerator (claw.tatsu.directive.generator.DirectiveGenerator)2 DimensionDefinition (claw.tatsu.xcodeml.abstraction.DimensionDefinition)2 XcodeML (claw.tatsu.xcodeml.xnode.common.XcodeML)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2