-
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
79 changed files
with
1,181 additions
and
755 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ main := -> async { | |
}; | ||
|
||
main().await; | ||
print(); |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import '../chunk.dart'; | ||
import 'constant.dart'; | ||
|
||
class BeizeClassConstant { | ||
BeizeClassConstant({ | ||
required this.moduleIndex, | ||
required this.chunk, | ||
}); | ||
|
||
factory BeizeClassConstant.deserialize( | ||
final BeizeSerializedConstant serialized, | ||
) => | ||
BeizeClassConstant( | ||
moduleIndex: serialized[0] as int, | ||
chunk: BeizeChunk.deserialize(serialized[1] as BeizeSerializedConstant), | ||
); | ||
|
||
final int moduleIndex; | ||
final BeizeChunk chunk; | ||
|
||
BeizeSerializedConstant serialize() => | ||
<dynamic>[moduleIndex, chunk.serialize()]; | ||
} |
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,3 +1,4 @@ | ||
export 'class.dart'; | ||
export 'constant.dart'; | ||
export 'function.dart'; | ||
export 'program.dart'; |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import '../../vm/exports.dart'; | ||
import '../exports.dart'; | ||
|
||
class BeizeBooleanValue extends BeizeNativeObjectValue { | ||
BeizeBooleanValue(this.value); | ||
|
||
final bool value; | ||
|
||
@override | ||
final BeizeValueKind kind = BeizeValueKind.boolean; | ||
|
||
@override | ||
BeizeBooleanValue kClone() => BeizeBooleanValue(value); | ||
|
||
@override | ||
String kToString() => value.toString(); | ||
|
||
@override | ||
BeizeClassValue? kClassInternal(final BeizeVM vm) => vm.globals.booleanClass; | ||
|
||
@override | ||
BeizeClassValue get kClass => throw UnimplementedError(); | ||
|
||
@override | ||
bool get isTruthy => value; | ||
|
||
@override | ||
int get kHashCode => value.hashCode; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import '../exports.dart'; | ||
|
||
class BeizeBooleanClassValue extends BeizeNativeClassValue { | ||
@override | ||
BeizeBooleanValue kInstantiate(final BeizeCallableCall call) { | ||
final BeizeValue value = call.argumentAt(0); | ||
return BeizeBooleanValue(value.isTruthy); | ||
} | ||
|
||
@override | ||
BeizeBooleanClassValue kClone() => this; | ||
|
||
@override | ||
String kToString() => '<boolean class>'; | ||
|
||
@override | ||
bool get isTruthy => true; | ||
|
||
@override | ||
int get kHashCode => hashCode; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'boolean.dart'; | ||
export 'boolean_class.dart'; |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import '../../vm/exports.dart'; | ||
import '../exports.dart'; | ||
|
||
abstract class BeizeCallableValue extends BeizeObjectValue { | ||
BeizeInterpreterResult kCall(final BeizeCallableCall call); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'call.dart'; | ||
export 'callable.dart'; |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import '../../vm/exports.dart'; | ||
import '../exports.dart'; | ||
|
||
abstract class BeizeClassValue extends BeizeNativeObjectValue | ||
implements BeizeCallableValue { | ||
BeizeObjectValue kInstantiate(final BeizeCallableCall call); | ||
|
||
@override | ||
BeizeInterpreterResult kCall(final BeizeCallableCall call) { | ||
final BeizeObjectValue value = kInstantiate(call); | ||
return BeizeInterpreterResult.success(value); | ||
} | ||
|
||
@override | ||
BeizeClassValue get kClass => this; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import '../exports.dart'; | ||
|
||
// what the fuck is this naming | ||
class BeizeClassClassValue extends BeizeNativeClassValue { | ||
BeizeClassClassValue() { | ||
set( | ||
BeizeStringValue('of'), | ||
BeizeNativeFunctionValue.sync( | ||
(final BeizeCallableCall call) { | ||
final BeizeObjectValue value = call.argumentAt(0); | ||
return value.kClassInternal(call.frame.vm) ?? value.kClass; | ||
}, | ||
), | ||
); | ||
} | ||
|
||
@override | ||
BeizeClassValue kInstantiate(final BeizeCallableCall call) { | ||
final BeizeClassValue value = call.argumentAt(0); | ||
return value; | ||
} | ||
|
||
@override | ||
BeizeClassClassValue kClone() => this; | ||
|
||
@override | ||
String kToString() => '<class>'; | ||
|
||
@override | ||
BeizeClassValue get kClass => this; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export 'class.dart'; | ||
export 'class_class.dart'; | ||
export 'native_class.dart'; | ||
export 'vm_class.dart'; |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import '../exports.dart'; | ||
|
||
abstract class BeizeNativeClassValue extends BeizeClassValue { | ||
@override | ||
final BeizeValueKind kind = BeizeValueKind.nativeClazz; | ||
|
||
@override | ||
String kToString() => '<native class>'; | ||
|
||
@override | ||
bool get isTruthy => true; | ||
|
||
@override | ||
int get kHashCode => hashCode; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import '../../bytecode.dart'; | ||
import '../exports.dart'; | ||
|
||
class BeizeVMClassValue extends BeizeClassValue { | ||
BeizeVMClassValue(this.constant); | ||
|
||
final BeizeClassConstant constant; | ||
|
||
@override | ||
final BeizeValueKind kind = BeizeValueKind.clazz; | ||
|
||
@override | ||
BeizeObjectValue kInstantiate(final BeizeCallableCall call) { | ||
throw UnimplementedError(); | ||
} | ||
|
||
@override | ||
BeizeVMClassValue kClone() => BeizeVMClassValue(constant); | ||
|
||
@override | ||
String kToString() => '<class>'; | ||
|
||
@override | ||
bool get isTruthy => true; | ||
|
||
@override | ||
int get kHashCode => constant.hashCode; | ||
} |
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
27 changes: 27 additions & 0 deletions
27
packages/beize_vm/lib/values/exception/exception_class.dart
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import '../exports.dart'; | ||
|
||
class BeizeExceptionClassValue extends BeizeNativeClassValue { | ||
@override | ||
BeizeExceptionValue kInstantiate(final BeizeCallableCall call) { | ||
final BeizeStringValue message = call.argumentAt(0); | ||
final BeizeValue stackTrace = call.argumentAt(1); | ||
return BeizeExceptionValue( | ||
message.value, | ||
stackTrace is BeizeNullValue | ||
? call.frame.getStackTrace() | ||
: stackTrace.kToString(), | ||
); | ||
} | ||
|
||
@override | ||
BeizeExceptionClassValue kClone() => this; | ||
|
||
@override | ||
String kToString() => '<exception class>'; | ||
|
||
@override | ||
bool get isTruthy => true; | ||
|
||
@override | ||
int get kHashCode => hashCode; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'exception.dart'; | ||
export 'exception_class.dart'; |
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,15 @@ | ||
export 'boolean.dart'; | ||
export 'exception.dart'; | ||
export 'boolean/exports.dart'; | ||
export 'callable/exports.dart'; | ||
export 'class/exports.dart'; | ||
export 'exception/exports.dart'; | ||
export 'function/exports.dart'; | ||
export 'kind.dart'; | ||
export 'list.dart'; | ||
export 'module.dart'; | ||
export 'list/exports.dart'; | ||
export 'map/exports.dart'; | ||
export 'module/exports.dart'; | ||
export 'null.dart'; | ||
export 'number.dart'; | ||
export 'object.dart'; | ||
export 'primitive_object.dart'; | ||
export 'string.dart'; | ||
export 'number/exports.dart'; | ||
export 'object/exports.dart'; | ||
export 'string/exports.dart'; | ||
export 'unawaited/exports.dart'; | ||
export 'value.dart'; |
This file was deleted.
Oops, something went wrong.
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,6 +1,4 @@ | ||
export 'call.dart'; | ||
export 'callable.dart'; | ||
export 'function.dart'; | ||
export 'native_function.dart'; | ||
export 'unawaited.dart'; | ||
export 'function_class.dart'; | ||
export 'native/exports.dart'; | ||
export 'utils.dart'; |
Oops, something went wrong.