Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No java code generated #6

Closed
ec0github opened this issue May 12, 2017 · 11 comments
Closed

No java code generated #6

ec0github opened this issue May 12, 2017 · 11 comments
Assignees

Comments

@ec0github
Copy link

Used the SimpleMath example to test the tools. It executed successfully and the last message it prompted is
"02:58:00 [INFO] java_sk/sketch.py:36 => sketch done: result/output/Test.txt"

However, there is nothing in the folder result/output and found there are files in folder sk_Test which was created during synthesis process

@jsjeon
Copy link
Member

jsjeon commented May 25, 2017

Josh, I saw that the master branch is actively changed these days. Could you please take a look at this?

@droptablestar
Copy link
Contributor

Fixed.

@ec0github
Copy link
Author

Thank you.
I want to clarify that should I expect the output is the java sketch with the hole filled i.e. the input is

class SimpleMath {
static int mult2(int x) {
return ?? * {| x , 0 |};
}
}

and the output is something like

class SimpleMath { ...
static public int mult2 (int x) {
return 2 * x;
}
}

The content in the output file Test.txt is

SKETCH version 1.7.2
Benchmark = result/sk_Test/main.sk
Class CSV is a code generator.
Generating code with CSV
mult2_int,StmtAssign,_out = 0
mult2_int,StmtAssign,_out = 2 * x
mult2_int,ExprBinary,2 * x
test,StmtVarDecl,int self_s6 = 0
test,StmtVarDecl,Object@Object self_s8 = null
test,StmtVarDecl,int _out_s10 = 0
test,ExprBinary,_out_s10 == 6
Object,StmtAssign,_out = 0
Object,StmtAssign,_out = 1
Object_Object,StmtAssign,_out = null
Object_Object,StmtAssign,_out = self
[SKETCH] DONE
Total time = 362

It seems the contents to fill up the hole is there but is there any document to explain the output such that I know how to use the result to fill the hole especially if there are more than one hole which is the normal case.

cheers,

@droptablestar
Copy link
Contributor

This is the result of a custom code generator used in the previous version of JSketch. I'm not exactly sure how this was used in the past, maybe @jsjeon has some input here?

I've changed the default behaviour to output the code Sketch produces as opposed to the custom code and added a flag for using the custom code generator (-c). Hope this helps!

@jsjeon
Copy link
Member

jsjeon commented Jun 5, 2017

Previously, if things went well, custom code generator will pick up 2 * x (forgot whether it picked up StmtAssign or ExprBinary, but either one), and replaced the holes with it.

It sounds like the default behavior is changed? From outputting synthesized Java files to outputting Sketch output (either C file or txt like above)? Because this is "JSketch", a Java sketching tool, I wonder we need an opposite flag, a flag that makes the tool stop at Sketch generation phase and not outputting Java output. Of course its default value should be false, so that the default tool behavior is reserved.

@ec0github
Copy link
Author

ec0github commented Jun 7, 2017

Thank you for your continuous help!

I tried with and without -c option. If -c option was specified, it worked as before (use custom code generator) and if -c option was not specified, the output file is:

SKETCH version 1.7.2
Benchmark = result/sk_Test/main.sk
/* BEGIN PACKAGE SimpleMath*/
package SimpleMath{
  /*SimpleMath.sk:7*/
  
void mult2_int (int x, ref int _out)/*SimpleMath.sk:7*/
  {
    _out = 0;
    _out = 2 * x;
    return;
  }
  /* END PACKAGE SimpleMath*/
}
/* BEGIN PACKAGE ANONYMOUS*/
/* END PACKAGE ANONYMOUS*/
/* BEGIN PACKAGE array*/
package array{
  struct Array_bit {
      int length;
      bit[length] A;
  }
  struct Array_char {
      int length;
      char[length] A;
  }
  struct Array_int {
      int length;
      int[length] A;
  }
  struct Array_float {
      int length;
      float[length] A;
  }
  struct Array_double {
      int length;
      double[length] A;
  }
  struct Array_Object {
      int length;
      Object[length] A;
  }
  /* END PACKAGE array*/
}
/* BEGIN PACKAGE Test*/
package Test{
  /*Test.sk:7*/
  
void test ()/*Test.sk:7*/
  {
    int self_s6 = 0;
    Object@meta(self_s6);
    Object@Object self_s8 = null;
    Object_Object@Object(new Object@Object(__cid=self_s6), self_s8);
    int _out_s10 = 0;
    mult2_int@SimpleMath(3, _out_s10);
    assert (_out_s10 == 6); //Assert at Test.sk:9 (-671034161982939304)
  }
  /*Test.sk:7*/
  
void test__Wrapper ()  implements test__WrapperNospec/*Test.sk:7*/
  {
    test();
  }
  /*Test.sk:7*/
  
void test__WrapperNospec ()/*Test.sk:7*/
  { }
  /* END PACKAGE Test*/
}
/* BEGIN PACKAGE meta*/
package meta{
  /*meta.sk:4*/
  
void Object (ref int _out)/*meta.sk:4*/
  {
    _out = 0;
    _out = 1;
    return;
  }
  /* END PACKAGE meta*/
}
/* BEGIN PACKAGE Object*/
package Object{
  struct Object {
      int __cid;
      Array_char _value_String;
      int _count_String;
  }
  /*Object.sk:7*/
  
void Object_Object (Object self, ref Object _out)/*Object.sk:7*/
  {
    _out = null;
    _out = self;
    return;
  }
  /* END PACKAGE Object*/
}
/* BEGIN PACKAGE String*/
package String{
  /* END PACKAGE String*/
}
[SKETCH] DONE
Total time = 385

How can I identify the synthesized code for hole especially if there are multiple fragments and multiple holes.

@droptablestar
Copy link
Contributor

I'm not sure I understand your question. In this example the hole is in mult2, right? Then you would need to look in the code produced by Sketch to see what what synthesised. In this case
_out = 0; _out = 2 * x; return;

@ec0github
Copy link
Author

ec0github commented Jun 17, 2017

Sorry, I haven't made my question clear. My question is if there are multiple holes in the sketch, how can I match the holes with the output? Does the output will have the same syntactic structure as the sketch except the holes are filled. Thanks!

Furthermore, if I want to use some Java libraries will JSKETCH will try with functions in imported packages?
For example, if I want to sort input parameter which is an array of integers and import Collection package in the declaration of java program, will JSKETCH will try to synthesis the program with functions in Collection package? Can I tell JSKETCH that it only need to try a subset of functions of the packages?

@droptablestar
Copy link
Contributor

droptablestar commented Jun 17, 2017 via email

@ec0github
Copy link
Author

In case the functions/variables have been rewritten, how can I match them to the holes? From the positions of the holes?

Eric

@droptablestar
Copy link
Contributor

droptablestar commented Jun 19, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants