diff --git a/ets/std/array/methods.ets b/ets/std/array/methods.ets new file mode 100644 index 0000000000000000000000000000000000000000..5307b941c69048a76b29c48648e30245c9664a03 --- /dev/null +++ b/ets/std/array/methods.ets @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.array; + +function length(arr: T[]): int { + return a.length(); +} + +function fill(arr: T[], value: T, from: int, to: int): void {} + +function join(arr: T[], separator: String): String {} + +function reverse(arr: T[]): T[] {} + +// Value v is found in array +function hasValue(arr: T[], v: T): boolean {} + +// There is a value in array conforming predicate +function someValue(arr: T[], fn: (value: T): boolean): boolean {} +function someValueI(arr: T[], fn: (value: T, index: int): boolean): boolean {} + +// All values conform predicate +function allValues(arr: T[], fn: (value: T): boolean): boolean {} +function allValuesI(arr: T[], fn: (value: T, index: int): boolean): boolean {} + +// Index of value v in array or -1 otherwise +function indexOf(arr: T[], v: T): int {} + +// Index of a last position of value v in array or -1 if no value found (start search `from` index or 0) +function lastIndexOf(arr: T[], v: T): int {} +function lastIndexOf(arr: T[], v: T, fromIndex: int): int {} + +function fold(arr: T, initialValue: V, fn: (accumulator: V, value: V): V): V {} +function foldI(arr: T, initialValue: V, fn: (accumulator: V, value: V, index: int): V): V {} + +function foldRight(arr: T, initialValue: V, fn: (accumulator: V, value: V): V): V {} +function foldIRight(arr: T, initialValue: V, fn: (accumulator: V, value: V, index: int): V): V {} + +function map(arr: T[], fn(value: T): V): V[] {} +function mapI(arr: T[], fn(value: T, index: int): V): V[] {} + +function filter(arr: T[], fn: (value: T): boolean): T[] {} +function filterI(arr: T[], fn: (value: T, index: int): boolean): T[] {} + +function touchEvery(arr: T[], fn: (value: T): void): void {} +function touchEveryI(arr: T[], fn: (value: T, index: int): void): void {} + +function toString(arr: T[]): String {} diff --git a/ets/std/array/sort.ets b/ets/std/array/sort.ets new file mode 100644 index 0000000000000000000000000000000000000000..46b91a39f4ccf052507a442f730e98454309d11b --- /dev/null +++ b/ets/std/array/sort.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.array; + +function sort(arr: T[]): T[] {} +function sort(arr: T[], comparator: (a, b: T): int): T[] {} + diff --git a/ets/std/containers/Map.ets b/ets/std/containers/Map.ets new file mode 100644 index 0000000000000000000000000000000000000000..568fc9e0ed5ba88b2ee98aa12598cba84a49893c --- /dev/null +++ b/ets/std/containers/Map.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.containers; + +class Map { + constructor () {} + constructor (values: T[]) {} + put(k: K, v: V): void {} + hasKey(k: K): boolean {} + length(): int {} + remove(k: K): void {} + clear(): void {} + // Panic if no key found + get(k: V): V {} + // Return default value if no key found + get(k: V, def: V): V {} +} diff --git a/ets/std/containers/Set.ets b/ets/std/containers/Set.ets new file mode 100644 index 0000000000000000000000000000000000000000..e5d96fa00e868bce97a2f5b8a3cda143bf5751e5 --- /dev/null +++ b/ets/std/containers/Set.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.containers; + +class Set { + private map: Map = new Map(); + + constructor () {} + constructor (values: T[]) {} + + put(v: T): void { + this.map.put(v, true); + } + + hasValue(v: T): boolean { + return this.map.hasKey(v); + } + + length(): int { + return this.map.length(); + } + + remove(v: T): void { + this.map.remove(v); + } + + clear(): void { + this.map.clear(); + } +} \ No newline at end of file diff --git a/ets/std/core/.gitignore b/ets/std/core/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..6b87ca7ca829f6ea988e63bcc6929d2bb550dfff --- /dev/null +++ b/ets/std/core/.gitignore @@ -0,0 +1 @@ +license.head diff --git a/ets/std/core/Boolean.ets b/ets/std/core/Boolean.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8c1982a5715a13e80d328429c86980da37743f4 --- /dev/null +++ b/ets/std/core/Boolean.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class Boolean extends Object { +} diff --git a/ets/std/core/Byte.ets b/ets/std/core/Byte.ets new file mode 100644 index 0000000000000000000000000000000000000000..178892a325e034bba05695199aaa1505be15d134 --- /dev/null +++ b/ets/std/core/Byte.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class Byte extends Integral implements Comparable { + + private value: byte; + + public static MIN_VALUE: byte = -128; + public static MAX_VALUE: byte = 127; + public static BIT_SIZE: byte = 8; + public static BYTE_SIZE: byte = 1; + + public byteValue(): byte { + return this.value; + } + + public shortValue(): short { + return this.value as short; + } + + public intValue(): int { + return this.value as int; + } + + public longValue(): long { + return this.value as long; + } + + public floatValue(): float { + return this.value as float; + } + + public doubleValue(): double { + return this.value as double; + } + + public compareTo(to: Byte): int { + return 0; + } + + public toString(): String {} + + public hashCode(): int {} + + public equals(to: Object): boolean {} +} diff --git a/ets/std/core/Character.ets b/ets/std/core/Character.ets new file mode 100644 index 0000000000000000000000000000000000000000..89ba81cd9f66f119ce9db1537208ed9ae30798a1 --- /dev/null +++ b/ets/std/core/Character.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class Character extends Object { +} diff --git a/ets/std/core/Comparable.ets b/ets/std/core/Comparable.ets new file mode 100644 index 0000000000000000000000000000000000000000..2896206d0e51b3685907ae979518603799284139 --- /dev/null +++ b/ets/std/core/Comparable.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +interface Comparable { + compareTo(to: T): int; +} diff --git a/ets/std/core/Console.ets b/ets/std/core/Console.ets new file mode 100644 index 0000000000000000000000000000000000000000..89c49e8024f1cd93d79c24e6755b30e192ff62ca --- /dev/null +++ b/ets/std/core/Console.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class Console { + public println(o: Object) {} + public println(s: String): void {} + public println(i: byte): void {} + public println(i: short): void {} + public println(i: int): void {} + public println(i: long): void {} + public println(i: float): void {} + public println(i: double): void {} + public println(i: char): void {} +} + +export const console = new Console(); \ No newline at end of file diff --git a/ets/std/core/Double.ets b/ets/std/core/Double.ets new file mode 100644 index 0000000000000000000000000000000000000000..4139ceba77be0f75c5972d03745a6fd30a0446e6 --- /dev/null +++ b/ets/std/core/Double.ets @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +const INF = Double.POSITIVE_INFINITY; +const NaN = Double.NaN; + +class Double extends Floating implements Comparable { + private value: double; + + public static MIN_VALUE: double = 1.7976931348623157e+308; + public static MAX_VALUE: double = 4.9e-324; + public static BIT_SIZE: byte = 64; + public static BYTE_SIZE: byte = 8; + + public static final NaN: double = 0.0 / 0.0; + public static final POSITIVE_INFINITIY: double = 1.0 / 0.0; + public static final NEGATIVE_INFINITIY: double = -1.0 / 0.0; + public static final PRECISION: byte = 53; + + public byteValue(): byte { + return this.value as byte; + } + + public shortValue(): short { + return this.value as short; + } + + public intValue(): int { + return this.value as int; + } + + public longValue(): long { + return this.value as long; + } + + public floatValue(): float { + return this.value as float; + } + + public doubleValue(): double { + return this.value; + } + + public compareTo(to: Double): int { + return 0; + } + + public toString(): String {} + + public hashCode(): int {} + + public equals(to: Object): boolean {} +} diff --git a/ets/std/core/Exception.ets b/ets/std/core/Exception.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c21d8396560860f773f3038158fa786459448f2 --- /dev/null +++ b/ets/std/core/Exception.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class Exception { + constructor () { + st = StackTrace.provisionStackTrace() + } +} \ No newline at end of file diff --git a/ets/std/core/Float.ets b/ets/std/core/Float.ets new file mode 100644 index 0000000000000000000000000000000000000000..d2b3872a6d29922eaa581272ac179dc1e289140b --- /dev/null +++ b/ets/std/core/Float.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +const INF = Float.POSITIVE_INFINITY; + +class Float extends Floating implements Comparable { + private value: float; + + public static MIN_VALUE: float = 3.4023235e+38; + public static MAX_VALUE: float = 1.4e-45; + public static BIT_SIZE: byte = 32; + public static BYTE_SIZE: byte = 4; + + public static final NaN: float = 0.0 / 0.0; + public static final POSITIVE_INFINITIY: float = 1.0 / 0.0; + public static final NEGATIVE_INFINITIY: float = -1.0 / 0.0; + public static final PRECISION: byte = 24; + + public byteValue(): byte { + return this.value as byte; + } + + public shortValue(): short { + return this.value as short; + } + + public intValue(): int { + return this.value as int; + } + + public longValue(): long { + return this.value as long; + } + + public floatValue(): float { + return this.value; + } + + public doubleValue(): double { + return this.value as double; + } + + public compareTo(to: Float): int { + return 0; + } + + public toString(): String {} + + public hashCode(): int {} + + public equals(to: Object): boolean {} +} diff --git a/ets/std/core/Floating.ets b/ets/std/core/Floating.ets new file mode 100644 index 0000000000000000000000000000000000000000..3596aba45cda6e5a657050a9e98bfa70ccb34b21 --- /dev/null +++ b/ets/std/core/Floating.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class Floating extends Object { +} diff --git a/ets/std/core/Integer.ets b/ets/std/core/Integer.ets new file mode 100644 index 0000000000000000000000000000000000000000..12df8f1623bfd6f8786488f34c7e0bf274c45807 --- /dev/null +++ b/ets/std/core/Integer.ets @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class Integer extends Integral implements Comparable { + private value: int; + + public static MIN_VALUE: int = -2147483648; + public static MAX_VALUE: int = 2147483647; + public static BIT_SIZE: byte = 32; + public static BYTE_SIZE: byte = 4; + + public byteValue(): byte { + return this.value as byte; + } + + public shortValue(): short { + return this.value as short; + } + + public intValue(): int { + return this.value; + } + + public longValue(): long { + return this.value as long; + } + + public floatValue(): float { + return this.value as float; + } + + public doubleValue(): double { + return this.value as double; + } + + public compareTo(to: Integer): int { + return 0; + } + + public toString(): String {} + + public hashCode(): int {} + + public equals(to: Object): boolean {} + +} diff --git a/ets/std/core/Integral.ets b/ets/std/core/Integral.ets new file mode 100644 index 0000000000000000000000000000000000000000..170f130072b076c7fab178450a1b85aaabc13b39 --- /dev/null +++ b/ets/std/core/Integral.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class Integral extends Object { + + constructor () { + super(); + } + + public abstract byteValue(): byte; + public abstract intValue(): int; + public abstract shortValue(): short; + public abstract longValue(): long; + public abstract floatValue(): float; + public abstract doubleValue(): double; +} diff --git a/ets/std/core/Long.ets b/ets/std/core/Long.ets new file mode 100644 index 0000000000000000000000000000000000000000..e2872e91dbaad79c8904824bd570a66b26309d9a --- /dev/null +++ b/ets/std/core/Long.ets @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class Long extends Integral implements Comparable { + + private value: long; + + public static MIN_VALUE: long = -9223372036854775808; + public static MAX_VALUE: long = 9223372036854775807; + public static BIT_SIZE: byte = 64; + public static BYTE_SIZE: byte = 8; + + public byteValue(): byte { + return this.value as byte; + } + + public shortValue(): short { + return this.value as short; + } + + public intValue(): int { + return this.value as int; + } + + public longValue(): long { + return this.value; + } + + public floatValue(): float { + return this.value as float; + } + + public doubleValue(): double { + return this.value as double; + } + + public compareTo(to: Long): int { + return 0; + } + + public toString(): String {} + + public hashCode(): int {} + + public equals(to: Object): boolean {} + +} diff --git a/ets/std/core/Object.ets b/ets/std/core/Object.ets new file mode 100644 index 0000000000000000000000000000000000000000..be66da1c6a79e0e4fcffeb1d739d105f048a91a0 --- /dev/null +++ b/ets/std/core/Object.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class Object { + + // Constructs a new object + constructor () {} + + // String representation of the object + public toString(): String { + return types.getType(this).toString(); + } + + // Hash code value for the object + public hash(): int { + return runtime.GetHashCode(this); + } + + // Default reference equality + public equals(to: Object): boolean { + return this == to; + } +} diff --git a/ets/std/core/Panic.ets b/ets/std/core/Panic.ets new file mode 100644 index 0000000000000000000000000000000000000000..b6b527e6642baea7fd1ff0fda862019a0596546c --- /dev/null +++ b/ets/std/core/Panic.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class Panic { + constructor () { + st = StackTrace.provisionStackTrace() + } +} \ No newline at end of file diff --git a/ets/std/core/Runtime.ets b/ets/std/core/Runtime.ets new file mode 100644 index 0000000000000000000000000000000000000000..4a5168377ab75731d93ea4d22ffee5b445e091fe --- /dev/null +++ b/ets/std/core/Runtime.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class Runtime { + GetHashCode(o: Object) {} +} + +export const runtime = new Runtime(); \ No newline at end of file diff --git a/ets/std/core/Short.ets b/ets/std/core/Short.ets new file mode 100644 index 0000000000000000000000000000000000000000..a918d66ed0aa1f2dc99d86dd7eda3b78ecb23d81 --- /dev/null +++ b/ets/std/core/Short.ets @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class Short extends Integral implements Comparable { + + private value: short; + + public static MIN_VALUE: short = -32768; + public static MAX_VALUE: short = 32767; + public static BIT_SIZE: byte = 16; + public static BYTE_SIZE: byte = 2; + + public byteValue(): byte { + return this.value as byte; + } + + public shortValue(): short { + return this.value; + } + + public intValue(): int { + return this.value as int; + } + + public longValue(): long { + return this.value as long; + } + + public floatValue(): float { + return this.value as float; + } + + public doubleValue(): double { + return this.value as double; + } + + public compareTo(to: Short): int { + return 0; + } + + public toString(): String {} + + public hashCode(): int {} + + public equals(to: Object): boolean {} + +} diff --git a/ets/std/core/StackTrace.ets b/ets/std/core/StackTrace.ets new file mode 100644 index 0000000000000000000000000000000000000000..8268a3fe19a56e7608974f37b73c0ee5a16167bc --- /dev/null +++ b/ets/std/core/StackTrace.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class StackTraceElement { + // ... +} + +class StackTrace { + // Method provides stack of methods at the place of a call + native static provisionStackTrace(): StackTraceElement[] +} diff --git a/ets/std/core/StdExceptions.ets b/ets/std/core/StdExceptions.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc524ff6798d37b236c42bd5cc1db98f14027f93 --- /dev/null +++ b/ets/std/core/StdExceptions.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class NullPointerException extends Exception {} + +class ArrayIndexOutOfBoundsException extends Exception {} + +class ArithmeticException extends Exception {} diff --git a/ets/std/core/StdPanics.ets b/ets/std/core/StdPanics.ets new file mode 100644 index 0000000000000000000000000000000000000000..5e5ad628d36e15b651a3aece738cdbff5a02fa74 --- /dev/null +++ b/ets/std/core/StdPanics.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class DivideByZeroPanic extends Panic {} + +class NullPointerPanic extends Panic {} + +class UncatchedExceptionPanic extends Panic {} + diff --git a/ets/std/core/String.ets b/ets/std/core/String.ets new file mode 100644 index 0000000000000000000000000000000000000000..04a6af2848d89a339bcadaaf3f06d2d3052db42a --- /dev/null +++ b/ets/std/core/String.ets @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class String extends Object implements Comparable { + private value: string; + constructor() { + this.value = ""; + } + + constructor(s: string) { + this.value = s; + } + + constructor(fromChar: char) {} + constructor(fromChars: char[]) {} + + public isEmpty(): boolean { + return this.value == ""; + } + + public charAt(index: int): char {} + public codePointAt(index: int): int {} + public codePointCount(begin: int, end: int): int {} + public getChars(begin: int, end: int): char[] {} + public getBytes(begin: int, end: int): byte[] {} + public equals(to: Object): boolean {} + public contentEquals(sb: StringBuilder): boolean {} + + public compareTo(to: String): int { + return 0; + } + + public startsWith(prefix: String): boolean {} + public startsWith(prefix: String, fromIndex: int): boolean {} + public endsWith(suffix: String): boolean {} + + public hashCode(): int {} + + public indexOf(ch: int): int {} + public indexOf(ch: int, fromIndex: int): int {} + + public indexOf(str: String): int {} + public indexOf(str: String, fromIndex: int): int {} + + public lastIndexOf(ch: int): int {} + public lastIndexOf(ch: int, fromIndex: int): int {} + + public lastIndexOf(str: String): int {} + public lastIndexOf(str: String, fromIndex: int): int {} + + public substring(begin: int): String {} + public substring(begin: int, end: int): String {} + + public concat(to: String): String {} + + public replaceChar(oldCh: char, newCh: char): String {} + public contains(str: String): boolean {} + public contains(str: String, fromIndex: int): boolean {} + + public join(strings: String[], delim: String): String {} + public join(strings: String[], delim: String, prefix: String, suffix: String): String {} + + public toLowerCase(): String {} + public toUpperCase(): String {} + + public trim(): String {} + public trimLeft(): String {} + public trimRight(): String {} + + public trim(remove: char[]): String {} + public trimLeft(remove: char[]): String {} + public trimRight(remove: char[]): String {} + + public padLeft(pad: char, count: int): String {} + public padRight(pad: char, count: int): String {} + + // Repeat this string count times, i.e. + // a = "A", + // a.repeat(2) == "AA" + public repeat(count: int): String {} + + public length(): int {} + +} diff --git a/ets/std/core/StringBuilder.ets b/ets/std/core/StringBuilder.ets new file mode 100644 index 0000000000000000000000000000000000000000..4f138d854c4307797387db33923a62d9746da55e --- /dev/null +++ b/ets/std/core/StringBuilder.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class StringBuilder { + public constructor () {} + public constructor (s: String) {} + public append(o: Object): StringBuilder { + return this; + } + public append(s: String): StringBuilder { + return this; + } + public append(i: byte): StringBuilder { + return this; + } + public append(i: short): StringBuilder { + return this; + } + public append(i: int): StringBuilder { + return this; + } + public append(i: long): StringBuilder { + return this; + } + public append(i: float): StringBuilder { + return this; + } + public append(i: double): StringBuilder { + return this; + } + public append(i: char): StringBuilder { + return this; + } + public toString(): String { + return ""; + } +} \ No newline at end of file diff --git a/ets/std/core/System.ets b/ets/std/core/System.ets new file mode 100644 index 0000000000000000000000000000000000000000..95bbe76be800e34b68791724b12e30436ac12d94 --- /dev/null +++ b/ets/std/core/System.ets @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +function exit(code: int) {} diff --git a/ets/std/core/Types.ets b/ets/std/core/Types.ets new file mode 100644 index 0000000000000000000000000000000000000000..2dc64e89c910afcbb57646ac2fa858cfd116818a --- /dev/null +++ b/ets/std/core/Types.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.core; + +class Type { + +} + +class Types { + getType(o: Object): Type {} +} + +export const types = new Types(); \ No newline at end of file diff --git a/ets/std/math/license.head b/ets/std/math/license.head new file mode 100644 index 0000000000000000000000000000000000000000..cdef9643213eb0aa78068a3c49ce2134e0a68cbd --- /dev/null +++ b/ets/std/math/license.head @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + diff --git a/ets/std/math/math.ets b/ets/std/math/math.ets new file mode 100644 index 0000000000000000000000000000000000000000..4c7d0d1cf21b9175ad0652a31fb80f2e41c1ea99 --- /dev/null +++ b/ets/std/math/math.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package std.math; + +export function max(a: T, b: T): T {} + +export function sqrt(v: double): double {} + +export function power(x: double, y: double): double {} + +export function sin(x: double): double {} + +export function cos(x: double): double {} + +export function abs(x: double): double {} + +export function random(): double {} + diff --git a/migrator/sts_check_syntax.bat b/migrator/sts_check_syntax.bat new file mode 100644 index 0000000000000000000000000000000000000000..c75819203ec2cbc31fe4d0ce9d3ea249261d61b2 --- /dev/null +++ b/migrator/sts_check_syntax.bat @@ -0,0 +1,3 @@ +@echo off + +java -jar %~dp0/out/migrator-0.1.jar -T %1 diff --git a/migrator/sts_check_syntax.sh b/migrator/sts_check_syntax.sh new file mode 100755 index 0000000000000000000000000000000000000000..52118bac3acabd85ace930a5e39759054243cdc1 --- /dev/null +++ b/migrator/sts_check_syntax.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +java -jar out/migrator-0.1.jar -T $1