Closed vlad-serbanescu closed 9 years ago
Let's work by example. Can we two examples of small ABS code showing one ClassDecl
and one ClassImplements
? Because these are two that we actually begin a new Java class for.
module PrimeCWI; import * from ABS.FLI;
interface IPrime { Unit divide (Int n); }
interface IRead { Int read(); }
[Foreign] class Read implements IRead { Int read() { return 10000; // stub } }
class Sieve(Int bound) { Int n = 0; IPrime two; { two = new Prime(2); n = 3; } Unit run() { while (n < bound) { two!divide(n) ; n = n + 1; } } }
class Prime (Int p) implements IPrime { IPrime next; Unit divide (Int n) { if ( (n % p) != 0) { if (next != null) { next!divide (n); } else { next = new Prime(n); } } } }
{ IRead r = new local Read(); Int bound = r.read(); new Sieve(bound); }
This has both types of Class Declarations. Al classes in ABS have to implement at least one interface to have some behaviour other than run(). If a class doesn't implement an interface it only has the run() method. Such a class must extend abs.api.Actor all others implement interfaces that implicitly extend abs.api.Actor
We can create a concatenation of getQTypeName(QType qtype) calls on p.listqtype_ instead of visiting all nodes of Qtype. I assume that is what that method is for in the Visitor.java class right ?
Closed on with this auxiliary method "protected String toString(ListQType qtypes, String delimiter)" implemented
Plus, we started to use StringWriter
for nesting generation of elements inside a higher element.
We have to insert as the argument what w emits after visiting p.