挺大的改动。增加 as运算符,转换不了抛出 TypeError。import语法更新。修复try一点错误。现在表达式运算返回ExprResult。通过3个宏实现简便错误传播与解包 unwrap
This commit is contained in:
@@ -31,6 +31,27 @@ public interface Error
|
||||
getErrorMessage() -> String;
|
||||
}
|
||||
|
||||
public struct TypeError
|
||||
{
|
||||
public msg: String;
|
||||
}
|
||||
|
||||
impl Error for TypeError
|
||||
{
|
||||
toString()
|
||||
{
|
||||
return "TypeError: " + getErrorMessage();
|
||||
}
|
||||
getErrorClass()
|
||||
{
|
||||
return "TypeError";
|
||||
}
|
||||
getErrorMessage()
|
||||
{
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
// Operation interface
|
||||
|
||||
public interface Operation
|
||||
|
||||
@@ -3,7 +3,12 @@
|
||||
Library/std/std.fig
|
||||
*/
|
||||
|
||||
import io; // link std.io
|
||||
import value; // link std.type
|
||||
import math; // link std.math
|
||||
import tester; // link std.tester
|
||||
import io as std_io;
|
||||
import value as std_value;
|
||||
import math as std_math;
|
||||
import test as std_test;
|
||||
|
||||
public const io := std_io; // link std.io
|
||||
public const value := std_value; // link std.type
|
||||
public const math := std_math; // link std.math
|
||||
public const test := std_test; // link std.test
|
||||
Reference in New Issue
Block a user