-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added RecordTypeInfo#setGlobalDefaultValue, few more JSTypeInfos
- Loading branch information
1 parent
21d3510
commit 933a978
Showing
5 changed files
with
83 additions
and
3 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
24 changes: 24 additions & 0 deletions
24
src/main/java/dev/latvian/mods/rhino/type/JSBasicConstantTypeInfo.java
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,24 @@ | ||
package dev.latvian.mods.rhino.type; | ||
|
||
// null, undefined, true, false | ||
public record JSBasicConstantTypeInfo(String value) implements TypeInfo { | ||
public static final JSBasicConstantTypeInfo NULL = new JSBasicConstantTypeInfo("null"); | ||
public static final JSBasicConstantTypeInfo UNDEFINED = new JSBasicConstantTypeInfo("undefined"); | ||
public static final JSBasicConstantTypeInfo TRUE = new JSBasicConstantTypeInfo("true"); | ||
public static final JSBasicConstantTypeInfo FALSE = new JSBasicConstantTypeInfo("false"); | ||
|
||
@Override | ||
public Class<?> asClass() { | ||
return TypeInfo.class; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public void append(TypeStringContext ctx, StringBuilder sb) { | ||
sb.append(value); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/dev/latvian/mods/rhino/type/JSNumberConstantTypeInfo.java
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,19 @@ | ||
package dev.latvian.mods.rhino.type; | ||
|
||
// 10, -402.01 | ||
public record JSNumberConstantTypeInfo(Number number) implements TypeInfo { | ||
@Override | ||
public Class<?> asClass() { | ||
return TypeInfo.class; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return number.toString(); | ||
} | ||
|
||
@Override | ||
public void append(TypeStringContext ctx, StringBuilder sb) { | ||
sb.append(number); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/dev/latvian/mods/rhino/type/JSStringConstantTypeInfo.java
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 @@ | ||
package dev.latvian.mods.rhino.type; | ||
|
||
import dev.latvian.mods.rhino.ScriptRuntime; | ||
|
||
// "abc" | ||
public record JSStringConstantTypeInfo(String constant) implements TypeInfo { | ||
public static final JSStringConstantTypeInfo EMPTY = new JSStringConstantTypeInfo(""); | ||
|
||
@Override | ||
public Class<?> asClass() { | ||
return TypeInfo.class; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return ScriptRuntime.escapeAndWrapString(constant); | ||
} | ||
|
||
@Override | ||
public void append(TypeStringContext ctx, StringBuilder sb) { | ||
sb.append(ScriptRuntime.escapeAndWrapString(constant)); | ||
} | ||
} |
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