forked from JavaTX/JavaCompilerCore
314 lines
7.2 KiB
Java
Executable File
314 lines
7.2 KiB
Java
Executable File
package test;
|
|
|
|
|
|
|
|
import SourceFile;
|
|
import Class;
|
|
import ClassBody;
|
|
import InstVarDecl;
|
|
import DeclId;
|
|
import Method;
|
|
import Return;
|
|
import ParameterList;
|
|
import FormalParameter;
|
|
import Block;
|
|
import Assign;
|
|
import Receiver;
|
|
import MethodCall;
|
|
import LocalOrFieldVar;
|
|
import ClassDeclId;
|
|
import UsedId;
|
|
import Type;
|
|
import SCException;
|
|
|
|
|
|
|
|
|
|
public class SCTest
|
|
{
|
|
public SourceFile source=new SourceFile();
|
|
|
|
private boolean extendedsc;
|
|
|
|
public void build_tree()
|
|
{
|
|
Class a=new Class();
|
|
Class class1=new Class();
|
|
Class class2=new Class();
|
|
Class class3 =new Class();
|
|
Class b=new Class();
|
|
Class c=new Class();
|
|
Class dc=new Class();
|
|
ClassBody ab=new ClassBody();
|
|
ClassBody b1=new ClassBody();
|
|
ClassBody b2=new ClassBody();
|
|
ClassBody b3=new ClassBody();
|
|
ClassBody bb=new ClassBody();
|
|
ClassBody cb=new ClassBody();
|
|
ClassBody dcb=new ClassBody();
|
|
InstVarDecl i=new InstVarDecl();
|
|
InstVarDecl j=new InstVarDecl();
|
|
InstVarDecl ij=new InstVarDecl();
|
|
InstVarDecl inst1=new InstVarDecl();
|
|
InstVarDecl inst2=new InstVarDecl();
|
|
InstVarDecl inst3=new InstVarDecl();
|
|
InstVarDecl binstvar1=new InstVarDecl();
|
|
InstVarDecl binstvar2=new InstVarDecl();
|
|
InstVarDecl aformeth=new InstVarDecl();
|
|
InstVarDecl aformeth2=new InstVarDecl();
|
|
DeclId adeclformeth=new DeclId();
|
|
DeclId decl1=new DeclId();
|
|
DeclId decl2=new DeclId();
|
|
DeclId decl3=new DeclId();
|
|
DeclId decl=new DeclId();
|
|
DeclId d=new DeclId();
|
|
DeclId d1=new DeclId();
|
|
DeclId d2=new DeclId();
|
|
DeclId d3=new DeclId();
|
|
DeclId bd1=new DeclId();
|
|
DeclId bd2=new DeclId();
|
|
DeclId amd1=new DeclId();
|
|
DeclId amd2=new DeclId();
|
|
DeclId dcmd1=new DeclId();
|
|
DeclId dcmd2=new DeclId();
|
|
DeclId adc=new DeclId();
|
|
DeclId cmname=new DeclId();
|
|
DeclId dcmname=new DeclId();
|
|
Method m=new Method();
|
|
Method bm=new Method();
|
|
Method cm=new Method();
|
|
Method dcm=new Method();
|
|
Return amr=new Return();
|
|
ParameterList amp=new ParameterList();
|
|
ParameterList dcmp=new ParameterList();
|
|
FormalParameter dcmpf=new FormalParameter();
|
|
FormalParameter ampf1=new FormalParameter();
|
|
FormalParameter ampf2=new FormalParameter();
|
|
FormalParameter dcmpf1=new FormalParameter();
|
|
FormalParameter dcmpf2=new FormalParameter();
|
|
Block bl=new Block();
|
|
Block bbl=new Block();
|
|
Block dcmb=new Block();
|
|
Block cmb=new Block();
|
|
Assign as=new Assign();
|
|
Receiver amrcv=new Receiver();
|
|
Receiver amrcv2=new Receiver();
|
|
MethodCall ammc=new MethodCall();
|
|
MethodCall ammc2=new MethodCall();
|
|
LocalOrFieldVar lf=new LocalOrFieldVar();
|
|
LocalOrFieldVar lf2=new LocalOrFieldVar();
|
|
LocalOrFieldVar amerst=new LocalOrFieldVar();
|
|
LocalOrFieldVar amzwei=new LocalOrFieldVar();
|
|
LocalOrFieldVar am2=new LocalOrFieldVar();
|
|
ClassDeclId cdi=new ClassDeclId();
|
|
ClassDeclId cdi1=new ClassDeclId();
|
|
ClassDeclId cdi2=new ClassDeclId();
|
|
ClassDeclId cdi3=new ClassDeclId();
|
|
ClassDeclId bcd=new ClassDeclId();
|
|
ClassDeclId ccd=new ClassDeclId();
|
|
ClassDeclId dccd=new ClassDeclId();
|
|
UsedId u1=new UsedId();
|
|
UsedId u2=new UsedId();
|
|
UsedId text=new UsedId();
|
|
UsedId dccdsclass=new UsedId();
|
|
UsedId ausedformeth=new UsedId();
|
|
UsedId ausedformeth2=new UsedId();
|
|
UsedId ausedinmeth=new UsedId();
|
|
UsedId ausedinmeth2=new UsedId();
|
|
Type t=new Type();
|
|
Type t1=new Type();
|
|
Type t2=new Type();
|
|
Type t3=new Type();
|
|
Type t4=new Type();
|
|
Type t5=new Type();
|
|
Type t6=new Type();
|
|
|
|
cdi.set_classname("test");
|
|
cdi1.set_classname("class1");
|
|
cdi2.set_classname("class2");
|
|
cdi3.set_classname("class3");
|
|
bcd.set_classname("extendtest");
|
|
ccd.set_classname("methtestbasis");
|
|
dccd.set_classname("methtestinherit");
|
|
|
|
text.set_Name("extendtest");
|
|
dccdsclass.set_Name("methtestbasis");
|
|
a.set_ClassDeclId(cdi);
|
|
a.set_UsedId(text);
|
|
class1.set_ClassDeclId(cdi1);
|
|
class2.set_ClassDeclId(cdi2);
|
|
class3.set_ClassDeclId(cdi3);
|
|
b.set_ClassDeclId(bcd);
|
|
c.set_ClassDeclId(ccd);
|
|
dc.set_ClassDeclId(dccd);
|
|
dc.set_UsedId(dccdsclass);
|
|
|
|
d1.set_Name("testint1");
|
|
d2.set_Name("testint2");
|
|
d3.set_Name("class1var");
|
|
decl1.set_Name("class2var");
|
|
decl2.set_Name("class3var");
|
|
decl3.set_Name("inttest");
|
|
bd1.set_Name("externesint1");
|
|
bd2.set_Name("externesint2");
|
|
adeclformeth.set_Name("klassenvariable");
|
|
adc.set_Name("klassenvariabledc");
|
|
|
|
t.set_Type("int");
|
|
t1.set_Type("class2");
|
|
t2.set_Type("class3");
|
|
t3.set_Type("int");
|
|
t4.set_Type("class1");
|
|
t5.set_Type("extendtest");
|
|
t6.set_Type("methtestinherit");
|
|
|
|
inst1.set_Type(t1);
|
|
inst2.set_Type(t2);
|
|
inst3.set_Type(t3);
|
|
ij.set_Type(t4);
|
|
i.set_Type(t);
|
|
j.set_Type(t);
|
|
aformeth.set_Type(t5);
|
|
binstvar1.set_Type(t);
|
|
binstvar2.set_Type(t);
|
|
aformeth2.set_Type(t6);
|
|
|
|
i.set_DeclId(d1);
|
|
j.set_DeclId(d2);
|
|
ij.set_DeclId(d3);
|
|
aformeth.set_DeclId(adeclformeth);
|
|
inst1.set_DeclId(decl1);
|
|
inst2.set_DeclId(decl2);
|
|
inst3.set_DeclId(decl3);
|
|
binstvar1.set_DeclId(bd1);
|
|
binstvar2.set_DeclId(bd2);
|
|
aformeth2.set_DeclId(adc);
|
|
|
|
ab.set_FieldDecl(i);
|
|
ab.set_FieldDecl(j);
|
|
ab.set_FieldDecl(ij);
|
|
ab.set_FieldDecl(aformeth);
|
|
b1.set_FieldDecl(inst1);
|
|
b2.set_FieldDecl(inst2);
|
|
b3.set_FieldDecl(inst3);
|
|
bb.set_FieldDecl(binstvar1);
|
|
bb.set_FieldDecl(binstvar2);
|
|
ab.set_FieldDecl(aformeth2);
|
|
|
|
u1.set_Name("class1var");
|
|
u1.set_Name("class2var");
|
|
u1.set_Name("class3var");
|
|
u1.set_Name("inttest");
|
|
u2.set_Name("testint2");
|
|
ausedformeth.set_Name("testfkt");
|
|
ausedinmeth.set_Name("klassenvariable");
|
|
ausedformeth2.set_Name("klassenvariabledc");
|
|
ausedformeth2.set_Name("testen");
|
|
|
|
lf.set_UsedId(u1);
|
|
lf2.set_UsedId(u2);
|
|
amerst.set_UsedId(u1);
|
|
amzwei.set_UsedId(ausedinmeth);
|
|
|
|
as.set_Expr(lf,lf2);
|
|
amr.set_ReturnExpr(lf2);
|
|
|
|
amrcv.set_Expr(lf);
|
|
ammc.set_Receiver(amrcv);
|
|
ammc.set_UsedId(ausedformeth);
|
|
ammc.add_Expr(amerst);
|
|
ammc.add_Expr(amzwei);
|
|
ammc2.set_Receiver(amrcv);
|
|
ammc2.set_UsedId(ausedformeth2);
|
|
|
|
bl.set_Statement(as);
|
|
bl.set_Statement(ammc);
|
|
bl.set_Statement(ammc2);
|
|
bl.set_Statement(amr);
|
|
|
|
amd1.set_Name("intwert");
|
|
amd2.set_Name("extendtest");
|
|
dcmd1.set_Name("intwert");
|
|
dcmd2.set_Name("intwert");
|
|
|
|
ampf1.set_Type(t);
|
|
ampf2.set_Type(t5);
|
|
ampf1.set_DeclId(amd1);
|
|
ampf2.set_DeclId(amd2);
|
|
dcmpf1.set_Type(t);
|
|
dcmpf2.set_Type(t);
|
|
dcmpf1.set_DeclId(dcmd1);
|
|
dcmpf2.set_DeclId(dcmd2);
|
|
|
|
amp.set_AddParameter(ampf1);
|
|
amp.set_AddParameter(ampf2);
|
|
dcmp.set_AddParameter(dcmpf1);
|
|
dcmp.set_AddParameter(dcmpf2);
|
|
|
|
dcm.set_ParaList(dcmp);
|
|
m.set_ParaList(amp);
|
|
|
|
dcm.set_Block(dcmb);
|
|
m.set_Block(bl);
|
|
cm.set_Block(cmb);
|
|
|
|
d.set_Name("testfkt");
|
|
cmname.set_Name("testen");
|
|
dcmname.set_Name("testen");
|
|
|
|
m.set_ReturnType(t);
|
|
cm.set_ReturnType(t);
|
|
dcm.set_ReturnType(t);
|
|
|
|
m.set_DeclId(d);
|
|
cm.set_DeclId(cmname);
|
|
dcm.set_DeclId(dcmname);
|
|
|
|
ab.set_FieldDecl(m);
|
|
cb.set_FieldDecl(cm);
|
|
dcb.set_FieldDecl(dcm);
|
|
|
|
a.set_ClassBody(ab);
|
|
class1.set_ClassBody(b1);
|
|
class2.set_ClassBody(b2);
|
|
class3.set_ClassBody(b3);
|
|
b.set_ClassBody(bb);
|
|
c.set_ClassBody(cb);
|
|
dc.set_ClassBody(dcb);
|
|
|
|
source.set_Class(c);
|
|
source.set_Class(dc);
|
|
source.set_Class(b);
|
|
source.set_Class(class3);
|
|
source.set_Class(class2);
|
|
source.set_Class(class1);
|
|
source.set_Class(a);
|
|
try
|
|
{
|
|
source.sc_check(extendedsc);
|
|
}
|
|
catch (SCException ex)
|
|
{
|
|
ex.fehlerausgabe();
|
|
}
|
|
}
|
|
|
|
public void set_ext(boolean ext)
|
|
{
|
|
extendedsc=ext;
|
|
}
|
|
|
|
public static void main(String args[])
|
|
{
|
|
SCTest test=new SCTest();
|
|
if(args!=null)
|
|
{
|
|
if(args[0].equals("fullinfo"))
|
|
test.set_ext(true);
|
|
else
|
|
test.set_ext(false);
|
|
}
|
|
test.build_tree();
|
|
|
|
}
|
|
} |