[英]How to scan Annotations used in contracts written using COFOJA?
I am working on a project, where I have to write a contract for a method using COFOJA, and I have to generate code for method from the contracts using heuristics.我正在做一个项目,我必须为使用 COFOJA 的方法编写合同,并且必须使用启发式从合同中生成方法代码。
1) How will I be able to scan Annotations used in COFOJA like @ requires, @ensures etc? 1) 我如何能够扫描 COFOJA 中使用的注释,例如 @requires、@ensures 等? 2) IF I generate Abstract syntax tree, whether the AST will contain annotations / contract language also? 2)如果我生成抽象语法树,AST是否也会包含注释/合同语言?
for ex: consider following input to my project例如:考虑对我的项目进行以下输入
class Test{
@requires( { a> 0})
@ensures( {a==0 implies fact(a)=1 , and a>0 implies fact(a) = fact(a-1)*a } )
public int fact (int a)
{
}
}
// Output of first version of code: (Its a rough estimate of code,)
class Test1{
public int fact (int a)
{
if (a==0)
return 1;
if(a >0)
return a*fact(a-1);
if(a<0) throw new AssertionException("Precondition failed/violated a<0 ");
}
} // end of class
to set eclipse: http://webcourse.cs.technion.ac.il/236700/Spring2013/ho/WCFiles/Contracts%20for%20Java.pdf设置 eclipse: http://webcourse.cs.technion.ac.il/236700/Spring2013/ho/WCFiles/Contracts%20for%20Java.Z437000941BA4193974910EE
and for cofoja: https://fsteeg.wordpress.com/2011/02/07/setting-up-contracts-for-java-in-eclipse/对于 cofoja: https://fsteeg.wordpress.com/2011/02/07/setting-up-contracts-for-java-in-eclipse/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.