Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2182)

Unified Diff: mojom/mojom_parser/mojom/types.go

Issue 1805743003: Mojom frontend: Compute, validate and populate struct field version info (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rename ComputeDataForGenerators to ComputeFinalData Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojom/mojom_parser/mojom/computed_data.go ('k') | mojom/mojom_parser/mojom/types_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/mojom_parser/mojom/types.go
diff --git a/mojom/mojom_parser/mojom/types.go b/mojom/mojom_parser/mojom/types.go
index b2589fec3706d83f8f9916a57a3b039a13027469..fd22392feda2368103aae2c914d578d9aa985a2a 100644
--- a/mojom/mojom_parser/mojom/types.go
+++ b/mojom/mojom_parser/mojom/types.go
@@ -55,6 +55,7 @@ const (
// A LiteralType is a |ConcreteType|.
type LiteralType interface {
ConcreteType
+ LiteralTypeKind() TypeKind
}
// ConcreteType represents the type of a concrete value. These are the types
@@ -106,8 +107,9 @@ type TypeRef interface {
// or MapTypeRefs because those types are never validated after resolution.
IsAssignmentCompatible(assignedValue ConcreteValue) bool
- // TypeName() returns a string appropriate for using-facing messages
- // that names a type. For UserDefinedTypes it will return the fully-qualified
+ // TypeName() returns a string appropriate for user-facing messages
+ // that names a type, including markers for interface requests and nullability.
+ // For UserDefinedTypes it will return the fully-qualified
// name of the resolved type, if the identifier has already been resolved.
// Otherwise it will return the identifier.
TypeName() string
@@ -121,6 +123,9 @@ type TypeRef interface {
// type and for MapTypes this method returns the union of the set of UserDefined
// types of the key type and the value type.
ReferencedUserDefinedTypes() UserDefinedTypeSet
+
+ // Returns true just in case the type referene is nullable.
+ Nullable() bool
}
/////////////////////////////////////////////////////////////
@@ -185,12 +190,14 @@ func (SimpleType) MarkUsedAsMapKey() bool {
return true
}
-// From interface TypeRef:
-
func (SimpleType) MarkUsedAsConstantType() bool {
return true
}
+func (SimpleType) Nullable() bool {
+ return false
+}
+
// A SimpleType does not reference any UserDefinedTypes.
func (SimpleType) ReferencedUserDefinedTypes() UserDefinedTypeSet {
return MakeUserDefinedTypeSet()
@@ -1217,6 +1224,19 @@ func int32Value(literalValue LiteralValue) (int32Value int32, ok bool) {
return
}
+// uint32Value returns the value of |literalValue| as an uint32.
+// If the type of |literalValue| is not an integer type then |ok|
+// will be false and |int32Value| will be zero. If the type of
+// |literalValue| is any of the integer types then |uint32Value| will
+// be the integer value cast to an uint32 and |ok| will indicate whether
+// or not the pre-cast value is between 0 and math.MaxUInt32.
+func uint32Value(literalValue LiteralValue) (int32Value uint32, ok bool) {
+ int64Value, ok := int64Value(literalValue)
+ ok = ok && int64Value <= math.MaxUint32 && int64Value >= 0
+ int32Value = uint32(int64Value)
+ return
+}
+
func MakeStringLiteralValue(text string, token *lexer.Token) LiteralValue {
return LiteralValue{StringLiteralType, text, false, token}
}
« no previous file with comments | « mojom/mojom_parser/mojom/computed_data.go ('k') | mojom/mojom_parser/mojom/types_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698