Skip to content

add trycatch support#186

Merged
lightszero merged 30 commits intomasterfrom
Branch_lights_trycatch
May 6, 2020
Merged

add trycatch support#186
lightszero merged 30 commits intomasterfrom
Branch_lights_trycatch

Conversation

@lightszero
Copy link
Copy Markdown
Member

@lightszero lightszero commented Jan 21, 2020

working

else if (_type.DeclaringType.FullName.Contains("Exception"))
{
//对异常对象要留一个,因为catch 会处理这个栈
_Convert1by1(VM.OpCode.NOP, src, to);//空白
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we use the optimizer to delete NOP, does that affect this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

#if DEBUG ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

do not worry,optimzer is safe to delete any NOP

@Tommo-L
Copy link
Copy Markdown
Contributor

Tommo-L commented Apr 14, 2020

@lightszero dalao, vm has merged the try-catch pr, we can continue this pr now. 😂

@lightszero
Copy link
Copy Markdown
Member Author

go go go

@lightszero
Copy link
Copy Markdown
Member Author

@Tommo-L many unittest had fail, help

@Tommo-L
Copy link
Copy Markdown
Contributor

Tommo-L commented Apr 16, 2020

@Tommo-L many unittest had fail, help

Ok, I'll help fix these ut.

@Tommo-L
Copy link
Copy Markdown
Contributor

Tommo-L commented Apr 16, 2020

This pr blocked by #219, as neo-core have merged the offset pr, most ut need to adjust.

@ShawnYun ShawnYun mentioned this pull request Apr 26, 2020
@ProDog
Copy link
Copy Markdown
Contributor

ProDog commented Apr 30, 2020

Can we supports catching details of exceptions? like:

try
{
                   
}

catch (Exception ex)
{
    Runtime.Notify("error:" + ex.Message);
}

@lightszero
Copy link
Copy Markdown
Member Author

Can we supports catching details of exceptions? like:

try
{
                   
}

catch (Exception ex)
{
    Runtime.Notify("error:" + ex.Message);
}

we can do that next step.

@Tommo-L
Copy link
Copy Markdown
Contributor

Tommo-L commented Apr 30, 2020

@lightszero need your help, I have tried to fix it but failed, I need more time. Could you have a look?

public static object tryWithTwoFinally()
{
	int v = 0;
	try
	{
		try
		{
			v++;
		}
		catch
		{
			v += 2;
		}
		finally
		{
			v += 3;
		}
	}
	catch
	{
		v += 4;
	}
	finally
	{
		v += 5;
	}
	return v;
}

Found by @ProDog

@lightszero
Copy link
Copy Markdown
Member Author

got it,I will check that.
but the ut had passed?so ut had problem?

@Tommo-L
Copy link
Copy Markdown
Contributor

Tommo-L commented Apr 30, 2020

It's a new ut. The current ut all are passed. Should I send a new PR to add the new ut. And the source code is here, #186 (comment)

@lightszero
Copy link
Copy Markdown
Member Author

you could direct add ut in this pr.

@Tommo-L
Copy link
Copy Markdown
Contributor

Tommo-L commented Apr 30, 2020

Plz, merge this pr #261, I don't have the authorization to push commit directly.

@lightszero
Copy link
Copy Markdown
Member Author

@Tommo-L done,it worked.

Tommo-L
Tommo-L previously approved these changes May 2, 2020
@lightszero lightszero requested a review from shargon May 2, 2020 03:30
@Tommo-L
Copy link
Copy Markdown
Contributor

Tommo-L commented May 2, 2020

Need your last test @ProDog

@ProDog
Copy link
Copy Markdown
Contributor

ProDog commented May 6, 2020

Need your last test @ProDog

Cool, I have tested it passed.

@lightszero lightszero merged commit 9a8ccac into master May 6, 2020
@lightszero lightszero deleted the Branch_lights_trycatch branch May 6, 2020 02:50
Jim8y pushed a commit that referenced this pull request Aug 3, 2025
* parseTryCatch
* fix try endpos problem
* add parse code for  no catch and no finally
* update trycatch
* add a unittest
* fix compile error on compiler
* fix compiler about trycatch
* fix opcodes
* fix optimizer for try catch
* open optimize for trycatch unittest
* Fix format
* fix UT (#255)
* add try-finally ut (#259)
* add try-finally ut
* format, translate
* fix try-finally and add try-catch
* refactor code
* keep only one try-catch matched
* add commont for exception paramcount.
* Update src/Neo.Compiler.MSIL/MSIL/Converter.cs
* Update src/Neo.Compiler.MSIL/MSIL/Converter.cs
* add try-catch failure ut (#261)
* fix some skip leaves problem.
* Reduce changes
Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: ShawnYun <42930111+ShawnYun@users.noreply.github.com>
Co-authored-by: Luchuan <luchuan@neo.org>
Jim8y pushed a commit that referenced this pull request Aug 18, 2025
* parseTryCatch

* fix try endpos problem

* add parse code for  no catch and no finally

* update trycatch

* add a unittest

* fix compile error on compiler

* fix compiler about trycatch

* fix opcodes

* fix optimizer for try catch

* open optimize for trycatch unittest

* Fix format

* fix UT (#255)

* add try-finally ut (#259)

* add try-finally ut

* format, translate

* fix try-finally and add try-catch

* refactor code

* keep only one try-catch matched

* add commont for exception paramcount.

* Update src/Neo.Compiler.MSIL/MSIL/Converter.cs

* Update src/Neo.Compiler.MSIL/MSIL/Converter.cs

* add try-catch failure ut (#261)

* fix some skip leaves problem.

* Reduce changes

Co-authored-by: Shargon <shargon@gmail.com>
Co-authored-by: ShawnYun <42930111+ShawnYun@users.noreply.github.com>
Co-authored-by: Luchuan <luchuan@neo.org>
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.

6 participants