Transpiled version (10093L) is out of date.
// TODO: Store Class AND Type // Describes a value during script optimization/type inference. // In the best case, the exact value is known. // Next best case is we're knowing its precise type (value of object.getClass()). // Third best case is we're knowing it's castable to a certain type. // A completely unknown value is described simply by "new LASValueDescriptor". persistable sclass LASValueDescriptor { bool knownValue() { false; } O value() { null; } Type type() { ret javaClass(); } Class javaClass() { null; } bool javaClassIsExact() { false; } bool canBeNull() { true; } bool canFail() { false; } bool willFail() { false; } srecord Exact(Class c, bool canBeNull) > LASValueDescriptor { Class javaClass() { ret c; } bool javaClassIsExact() { true; } bool canBeNull() { ret canBeNull; } } srecord NonExact(Class c, bool canBeNull) > LASValueDescriptor { Class javaClass() { ret c; } bool javaClassIsExact() { false; } bool canBeNull() { ret canBeNull; } } // only returns a type(), not a javaClass() // (e.g. for LAS classes still being defined) srecord NonExactType(Type type, bool canBeNull) > LASValueDescriptor { Type type() { ret type; } bool javaClassIsExact() { false; } bool canBeNull() { ret canBeNull; } } static LASValueDescriptor nonExactCanBeNull(Type c) { ret new NonExact(typeToClass(c), true); } srecord KnownValue(O value) > LASValueDescriptor { bool knownValue() { true; } O value() { ret value; } Class javaClass() { ret value?.getClass(); } bool javaClassIsExact() { ret value != null; } bool canBeNull() { ret value == null; } } // Indicates an exception can be thrown instead of returning a value. // Probably we don't need this. sclass WillFail > LASValueDescriptor { bool canFail() { true; } bool willFail() { true; } } static LASValueDescriptor fromClass(Class c) { ret new NonExact(c, true); } static LASValueDescriptor fromType(Type type) { ret new NonExact(typeToClass(type), true); } toString { ret "LASValueDescriptor " + javaClass(); } }
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034290 |
Snippet name: | LASValueDescriptor |
Eternal ID of this version: | #1034290/19 |
Text MD5: | b88c281fd5eed2c177f01b2442f65e02 |
Author: | stefan |
Category: | javax / left arrow script |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-03-12 17:32:04 |
Source code size: | 2233 bytes / 74 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 279 / 416 |
Version history: | 18 change(s) |
Referenced in: | [show references] |