-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
68 changed files
with
2,681 additions
and
1,510 deletions.
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
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 |
---|---|---|
@@ -1,13 +1,16 @@ | ||
createBenchmarker := -> { | ||
return { | ||
startedAt: null, | ||
endedAt: null, | ||
start: -> { | ||
this.startedAt = DateTime.now().millisecondsSinceEpoch; | ||
}, | ||
end: -> { | ||
this.endedAt = DateTime.now().millisecondsSinceEpoch; | ||
print('Took ' + (this.endedAt - this.startedAt) + 'ms'); | ||
}, | ||
}; | ||
Benchmarker := $ { | ||
static __name__: -> : "Benchmarker", | ||
__constructor__: -> { | ||
this.startedAt = null; | ||
this.endedAt = null; | ||
}, | ||
start: -> { | ||
this.startedAt = DateTime.now().millisecondsSinceEpoch; | ||
}, | ||
end: -> { | ||
this.endedAt = DateTime.now().millisecondsSinceEpoch; | ||
print('Took ' + (this.endedAt - this.startedAt) + 'ms'); | ||
}, | ||
}; | ||
|
||
print(Benchmarker); |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
printHello := -> async { | ||
print("Hello World"); | ||
Welcomer := $ { | ||
static hello: "hello", | ||
static __toString__: -> : "WelcomerToString", | ||
__constructor__: -> { | ||
this.hello2 = "hello"; | ||
}, | ||
__toString__: -> : "WelcomerToString2", | ||
}; | ||
|
||
main := -> async { | ||
printHello().await; | ||
}; | ||
|
||
main().await; | ||
print(Welcomer()); |
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
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
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
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
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 |
---|---|---|
@@ -1,12 +1,17 @@ | ||
class BeizeLexerUtils { | ||
static bool isWhitespace(final String char) => char.trim().isEmpty; | ||
|
||
static bool isNumeric(final String char) => '0123456789'.contains(char); | ||
|
||
static bool isNumericContent(final String char) => | ||
'+-0123456789.exabcdef'.contains(char.toLowerCase()); | ||
|
||
static bool isQuote(final String char) => | ||
char == "'" || char == '"' || char == '`'; | ||
|
||
static bool isAlpha(final String char) => | ||
r'$_abcdefghijklmnopqrstuvwxyz'.contains(char.toLowerCase()); | ||
'_abcdefghijklmnopqrstuvwxyz'.contains(char.toLowerCase()); | ||
|
||
static bool isAlphaNumeric(final String char) => | ||
isAlpha(char) || isNumeric(char); | ||
} |
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
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
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
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 |
---|---|---|
|
@@ -42,4 +42,6 @@ enum BeizeOpCodes { | |
opBeginTry, | ||
opEndTry, | ||
opImport, | ||
opIs, | ||
opClass, | ||
} |
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 |
---|---|---|
@@ -1,63 +1,65 @@ | ||
import '../bytecode.dart'; | ||
import '../values/exports.dart'; | ||
import 'native_exception.dart'; | ||
|
||
class BeizeRuntimeExpection extends BeizeNativeException { | ||
BeizeRuntimeExpection(super.message); | ||
class BeizeRuntimeException extends BeizeNativeException { | ||
BeizeRuntimeException(super.message); | ||
|
||
factory BeizeRuntimeExpection.invalidLeftOperandType( | ||
factory BeizeRuntimeException.invalidLeftOperandType( | ||
final String expected, | ||
final String received, | ||
) => | ||
BeizeRuntimeExpection( | ||
BeizeRuntimeException( | ||
'Invalid left operand value type (expected "$expected", received "$received")', | ||
); | ||
|
||
factory BeizeRuntimeExpection.invalidRightOperandType( | ||
factory BeizeRuntimeException.invalidRightOperandType( | ||
final String expected, | ||
final String received, | ||
) => | ||
BeizeRuntimeExpection( | ||
BeizeRuntimeException( | ||
'Invalid right operand value type (expected "$expected", received "$received")', | ||
); | ||
|
||
factory BeizeRuntimeExpection.undefinedVariable(final String name) => | ||
BeizeRuntimeExpection('Undefined variable "$name"'); | ||
factory BeizeRuntimeException.undefinedVariable(final String name) => | ||
BeizeRuntimeException('Undefined variable "$name"'); | ||
|
||
factory BeizeRuntimeExpection.cannotRedecalreVariable(final String name) => | ||
BeizeRuntimeExpection('Cannot redeclare variable "$name"'); | ||
factory BeizeRuntimeException.cannotRedeclareVariable(final String name) => | ||
BeizeRuntimeException('Cannot redeclare variable "$name"'); | ||
|
||
factory BeizeRuntimeExpection.unknownOpCode(final BeizeOpCodes opCode) => | ||
BeizeRuntimeExpection('Unknown op code: ${opCode.name}'); | ||
factory BeizeRuntimeException.unknownOpCode(final BeizeOpCodes opCode) => | ||
BeizeRuntimeException('Unknown op code: ${opCode.name}'); | ||
|
||
factory BeizeRuntimeExpection.unknownConstant(final dynamic constant) => | ||
BeizeRuntimeExpection('Unknown constant: $constant'); | ||
factory BeizeRuntimeException.unknownConstant(final dynamic constant) => | ||
BeizeRuntimeException('Unknown constant: $constant'); | ||
|
||
factory BeizeRuntimeExpection.cannotCastTo( | ||
final BeizeValueKind expected, | ||
final BeizeValueKind received, | ||
factory BeizeRuntimeException.cannotCastTo( | ||
final String expected, | ||
final String received, | ||
) => | ||
BeizeRuntimeExpection( | ||
'Cannot cast "${received.code}" to "${expected.code}"', | ||
BeizeRuntimeException( | ||
'Cannot cast "$received" to "$expected"', | ||
); | ||
|
||
factory BeizeRuntimeExpection.unwrapFailed(final String message) => | ||
BeizeRuntimeExpection('Unwrap failed due to "$message"'); | ||
factory BeizeRuntimeException.unwrapFailed(final String message) => | ||
BeizeRuntimeException('Unwrap failed due to "$message"'); | ||
|
||
factory BeizeRuntimeExpection.cannotConvertDoubleToInteger( | ||
factory BeizeRuntimeException.cannotConvertDoubleToInteger( | ||
final double value, | ||
) => | ||
BeizeRuntimeExpection('Cannot convert "$value" to integer'); | ||
BeizeRuntimeException('Cannot convert "$value" to integer'); | ||
|
||
factory BeizeRuntimeExpection.unexpectedArgumentType( | ||
factory BeizeRuntimeException.unexpectedArgumentType( | ||
final int index, | ||
final BeizeValueKind expected, | ||
final BeizeValueKind received, | ||
final String expected, | ||
final String received, | ||
) => | ||
BeizeRuntimeExpection( | ||
'Expected argument at $index to be "${expected.code}", received "${received.code}"', | ||
BeizeRuntimeException( | ||
'Expected argument at $index to be "$expected", received "$received"', | ||
); | ||
|
||
factory BeizeRuntimeException.notCallable(final String value) => | ||
BeizeRuntimeException('Value "$value" is not callable'); | ||
|
||
@override | ||
String toString() => 'BeizeRuntimeExpection: $message'; | ||
String toString() => 'BeizeRuntimeException: $message'; | ||
} |
Oops, something went wrong.