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

Signature infering as a new command in swam cli #12

Merged
merged 6 commits into from
Aug 24, 2020

Conversation

Jacarte
Copy link
Member

@Jacarte Jacarte commented Aug 24, 2020

Creating a pull request from Tareq one.

Signature inferring prints the value of the parameter of the functions name given by the command.
sudo mill cli.run infer --wasi code_analysis/test/resources/coverage-test/formal_data/Deconvolution-1D.wasm _fft

This is function name: _fft
This is param names: Vector(I32, I32, I32, I32)

@Jacarte Jacarte mentioned this pull request Aug 24, 2020
functionName match {
case Some(x) => {
if(x == func_name){
println(s"This is function name : $func_name")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is redundant, we already know the function name :). Remove it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed line in commit 324334e

case Some(x) => {
if(x == func_name){
println(s"This is function name : $func_name")
println(s"This is param names : ${tpe.params}")
Copy link
Member Author

@Jacarte Jacarte Aug 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To better integrate with the already implemented features:

  • Remove the prefix text "This is a param names: ..."
  • Map the SWAM types to the ones that we are using in the env for wafl: I32 to Int32, I64 to Int64, F32 to Float32 and F64 to Float64
  • Print only the data types separated by comma as follows: 'Int32,Int64...'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To better integrate with the already implemented features:

  • Remove the prefix text "This is a param names: ..."
  • Map the SWAM types to the ones that we are using in the env for wafl: I32 to Int32, I64 to Int64, F32 to Float32 and F64 to Float64
  • Print only the data types separated by comma as follows: 'Int32,Int64...'

Printing the parameters below format,

sudo mill cli.run infer --wasi code_analysis/test/resources/coverage-test/formal_data/Deconvolution-1D.wasm _fft

Int32,Int32,Int32,Int32

}
}
case None => {
println(s"The function name does not exists.")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Print to stderr and then exit SWAM with non-zero code

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If function not present then printing the message and exiting the swam code as shown in below screenshot

errorhandle

names.get(typeIndex)
case _ =>
None
})
functionName match {
case Some(x) => {
if(x == func_name){
println(s"This is function name : $func_name")
println(s"This is param names : ${tpe.params}")
val mapping = tpe.params.map(y => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lambda body can be replaced by removing the y => part

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed lambda body as part of the commit 2022710

val check = mapList.exists(j => {j == func_name})
if(!check){
System.err.println("Function name does not exists.")
sys.exit(1)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at how this is handled in a CommandIOApp. You never should directly exit in this way

Copy link

@tareq97-zz tareq97-zz Aug 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked with ExitCode.Error but probably in my code, it was not stopping the execution at that point. But checked you refactored code and understood that the exit code needs to return so that CommandIOApp can capture it and tell the status whether the status of execution is Success or Error

@Jacarte Jacarte merged commit 4035043 into feature/swam-server Aug 24, 2020
@Jacarte Jacarte deleted the signature_infering branch August 25, 2020 13:46
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

Successfully merging this pull request may close these issues.

3 participants