Support #6848
TRPL questions and issues
0%
History
#1 Updated by Vladimir Tsichevski almost 4 years ago
- Subject changed from TRPL issues and question to TRPL questions and issues
Questions about the TRPL language should be posted and discussed here.
#2 Updated by Vladimir Tsichevski almost 4 years ago
I found, that to convert a Java array to java.util.List, the createListFromObject library function can be used.
But in the dbref/collect_refs.xml module, the createListFromArray library function is called instead, which is not implemented.
I think, this is a regression.
Also, since this causes no issues when converting, I suspect the code referencing this non-existing function, is dead, and should be removed.
#3 Updated by Vladimir Tsichevski almost 4 years ago
About the legacy annotation attribute values.
Annotations containing attributes can look like this:
@SomeAnno(value="TheValue"). @SomeAnno(value='TheValue').
The annotation attribute value must be quoted or double-quoted.
I suppose quotes are part of the syntax and must not go to the AST, but they do go:
<ast col="1" id="124554051630" line="8" text="@" type="ANNOTATION">
...
<ast col="13" id="124554051634" line="8" text="=" type="ASSIGN">
...
<ast col="14" id="124554051636" line="8" text="'TheValue'" type="STRING">
...
</ast>
</ast>
</ast>
<ast col="1" id="124554051622" line="7" text="@" type="ANNOTATION">
...
<ast col="13" id="124554051626" line="7" text="=" type="ASSIGN">
...
<ast col="14" id="124554051628" line="7" text=""TheValue"" type="STRING">
...
</ast>
</ast>
</ast>
Is this behavior correct/intended?
#4 Updated by Greg Shah almost 4 years ago
dbref/collect_refs.xml is currently disabled code and was left there on purpose. It is intended to identify referenced database fields. At some point we will finish the idea and make it work. Please just leave it.
Is this behavior correct/intended?
Yes. We remove the quotes later in the process. Leaving them behind allows us to anti-parse back to 4GL code as well as properly reporting on the true contents of the original source code.
#5 Updated by Vladimir Tsichevski almost 4 years ago
I need to create a Java annotation of the following type:
public @interface SelectClasses
{
Class<?>[] value();
}
and I have trouble understanding which AST should I create for the class references.
If I create string literals:
<ast col="0" id="124554051668" line="0" text="'TheValue'" type="STRING">
<annotation datatype="java.lang.Boolean" key="is-literal" value="true"/>
</ast>
then a quoted string is generated:
@SelectClasses(value =
{
"TheValue"
})
If I use the SYMBOL type, then no output is generated in jast.
Should I use some other output node type, or generating symbols instead of string literals is not supported in FWD at the moment?
#6 Updated by Greg Shah almost 4 years ago
We wouldn't get very far in conversion if we couldn't emit symbols or data types. The authoritative source of how Java ASTs emit as Java source code is in convert/brew.xml.
If you look in convert/java_templates.tpl you can search on type="ANNOTATION" to see examples of templates for creating Java annotations. You can also look at some .jast files to see actual examples.
#7 Updated by Vladimir Tsichevski almost 4 years ago
Greg Shah wrote:
We wouldn't get very far in conversion if we couldn't emit symbols or data types. The authoritative source of how Java ASTs emit as Java source code is in
convert/brew.xml.If you look in
convert/java_templates.tplyou can search ontype="ANNOTATION"to see examples of templates for creating Java annotations. You can also look at some.jastfiles to see actual examples.
I gather these files convert JAST to Java sources. My problem is that no JAST is generated for AST SYMBOL node.
#8 Updated by Greg Shah almost 4 years ago
The SYMBOL you are referencing may be the prog.symbol type. Notice this is in the prog (for Progress) namespace. We don't use java.symbol in Java ASTs, nor do we use any prog.<token_type> there. If you look in the java_templates.tpl or in the .jast you will see that everything is in the java namespace. You can lookup the valid types for this namespace in JavaTokenTypes. As noted above, even though there is a java.symbol, we don't use it.
You can look at brew.xml to see how things emit. I would look at things like java.reference, java.reference_def and java.lbracket to see how they emit. Pay attention to the AST annotations as they can control aspects of the anti-parsing.
#9 Updated by Vladimir Tsichevski almost 4 years ago
Greg Shah wrote:
The
SYMBOLyou are referencing may be theprog.symboltype. Notice this is in theprog(forProgress) namespace. We don't usejava.symbolin Java ASTs, nor do we use anyprog.<token_type>there. If you look in thejava_templates.tplor in the.jastyou will see that everything is in thejavanamespace. You can lookup the valid types for this namespace inJavaTokenTypes. As noted above, even though there is ajava.symbol, we don't use it.You can look at
brew.xmlto see how things emit. I would look at things likejava.reference,java.reference_defandjava.lbracketto see how they emit. Pay attention to the AST annotations as they can control aspects of the anti-parsing.
Greg, as I see it, my problem it not in how Java text is generated from JAST (which is in the java namespace, yes).
My problem is that no contents in java namespace is generated from a prog.symbol node in AST.
So I need to either find the place in the code, in which the prog.symbol can be converted to java symbol and fix it, or create an AST node of different Progress type, which converts to java.symbol.
#10 Updated by Greg Shah almost 4 years ago
I need to either find the place in the code, in which the prog.symbol can be converted to java symbol and fix it
Yes, this one.
create an AST node of different Progress type, which converts to java.symbol.
There is no such thing.
#11 Updated by Vladimir Tsichevski almost 4 years ago
I need to convert legacy class names to converted Java class name (simple names and FQN). Which library method should I use for this?
#12 Updated by Greg Shah almost 4 years ago
Please just read the pkgname and classname annotations from the root node of the AST. You should not be converting the names yourself.
#13 Updated by Vladimir Tsichevski over 3 years ago
Greg Shah wrote:
Please just read the
pkgnameandclassnameannotations from the root node of the AST. You should not be converting the names yourself.
I need to convert arbitrary 4gl class names, not the names which do exist in the current AST.
Conversion example:
@TestSuite(classes="unittests.SimpleTestOEUnit, unittests.SimpleTestOEUnitInherited").
Here I need to know the Java class names for legacy classes unittests.SimpleTestOEUnit, and unittests.SimpleTestOEUnitInherited.
#14 Updated by Constantin Asofiei over 3 years ago
Vladimir Tsichevski wrote:
Here I need to know the Java class names for legacy classes
unittests.SimpleTestOEUnit, andunittests.SimpleTestOEUnitInherited.
There is ObjectOps.resolveClass(String) which gives you a Class extends _BaseObject_> reference. Also, for legacy OE classes, you need to use ObjectOps.newDynamicInstance if you want to instantiate them.
Remember that 'static' class members in converted code are not Java 'static', these are FWD context-local.
#15 Updated by Vladimir Tsichevski over 3 years ago
Constantin Asofiei wrote:
Vladimir Tsichevski wrote:
Here I need to know the Java class names for legacy classes
unittests.SimpleTestOEUnit, andunittests.SimpleTestOEUnitInherited.There is
ObjectOps.resolveClass(String)which gives you aClass extends _BaseObject_>reference.
I wonder if these Java class objects can be created in conversion time at the annotation stage. I do not need the Java classes, just class names.
Remember that 'static' class members in converted code are not Java 'static', these are FWD context-local.
No, they are:
@BeforeClass.
METHOD PUBLIC STATIC VOID BeforeClass():
// Do some stuff once before this class is loaded
END METHOD.
is converted as:
@LegacySignature(type = Type.METHOD, name = "BeforeClass")
@BeforeAll
public static void beforeClass()
{
internalProcedure(SimpleTestOeunit.class, "BeforeClass", new Block());
}
#16 Updated by Vladimir Tsichevski over 3 years ago
As the temporary workaround (just to continue the development), I can use the Java class names in the legacy 4gl sources. But this problem must be solved somehow.