forked from satabin/swam
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
18923cf
Signature infering as a new command in swam cli
tareq97 324334e
Added the mapping, error message and removed unnecessary messages.
tareq97 2022710
Removed lamda body for mapping the data types
tareq97 3dcbba3
Fix lambda empty body
Jacarte 9527a1d
No void parameter type message removal
Jacarte 75ba976
Refactoring and cleaning
Jacarte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -340,25 +340,38 @@ object Main extends CommandIOApp(name = "swam-cli", header = "Swam from the comm | |
val functionName = | ||
compiled.names.flatMap(_.subsections.collectFirstSome { | ||
case FunctionNames(names) => | ||
|
||
val mapList = names.values | ||
val check = mapList.exists(j => {j == func_name}) | ||
if(!check){ | ||
System.err.println("Function name does not exists.") | ||
sys.exit(1) | ||
} | ||
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 => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The lambda body can be replaced by removing the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed lambda body as part of the commit 2022710 |
||
y match { | ||
case ValType.I32 => "Int32" | ||
case ValType.I64 => "Int64" | ||
case ValType.F32 => "Float32" | ||
case ValType.F64 => "Float64" | ||
} | ||
}) | ||
val resultParams = mapping.mkString(",") | ||
if(resultParams == ""){ | ||
println("void") | ||
} | ||
println(resultParams) | ||
} | ||
} | ||
case None => { | ||
println(s"The function name does not exists.") | ||
} | ||
} | ||
|
||
case _ => None | ||
} | ||
}) | ||
_ <- IO(Infer) | ||
//_ <- IO(println(module)) | ||
} yield ExitCode.Success | ||
case Compile(file, out, debug) => | ||
for { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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