Documentation
¶
Index ¶
- Constants
- Variables
- func GetNormalizedKeywordName(value string) string
- func GetNormalizedReservedLiteral(value string) string
- func GetNormalizedTypeName(value string) string
- func IsBuiltinTypeName(value string) bool
- func IsKeywordName(value string) bool
- func IsReservedLiteral(value string) bool
- type AttributeUsageInfo
- type AttributesCollection
- type CCLCodeContext
- func (c *CCLCodeContext) CacheTypeDefinition(typeDef *CCLTypeDefinition)
- func (c *CCLCodeContext) GetGlobalVariable(name string) *VariableDefinition
- func (c *CCLCodeContext) GetTypeDefinition(name *SimpleTypeName) *CCLTypeDefinition
- func (c *CCLCodeContext) NewArrayTypeUsage(elementType *CCLTypeUsage, arrayLength int) *CCLTypeUsage
- func (c *CCLCodeContext) NewBuiltinTypeUsage(name string) *CCLTypeUsage
- func (c *CCLCodeContext) NewCustomTypeDefinition(name *SimpleTypeName, flags cclTypeFlag) (*CCLTypeDefinition, error)
- func (c *CCLCodeContext) NewCustomTypeUsage(name *SimpleTypeName) *CCLTypeUsage
- func (c *CCLCodeContext) NewModelTypeDefinition(name *SimpleTypeName, modelDef *ModelDefinition) (*CCLTypeDefinition, error)
- func (c *CCLCodeContext) NewPointerTypeUsage(targetType *CCLTypeUsage) *CCLTypeUsage
- func (c *CCLCodeContext) NewTypeDefinition(name *SimpleTypeName, flags cclTypeFlag, tLength int) *CCLTypeDefinition
- type CCLReservedLiteral
- type CCLTypeDefinition
- func (t *CCLTypeDefinition) AddGenericParam(targetType *CCLTypeDefinition) error
- func (t *CCLTypeDefinition) GetFullName() string
- func (t *CCLTypeDefinition) GetLength() int
- func (t *CCLTypeDefinition) GetModelDefinition() *ModelDefinition
- func (t *CCLTypeDefinition) GetName() string
- func (t *CCLTypeDefinition) GetNamespace() string
- func (t *CCLTypeDefinition) GetShortModelName() string
- func (t *CCLTypeDefinition) HasModelField() bool
- func (t *CCLTypeDefinition) IsArray() bool
- func (t *CCLTypeDefinition) IsBuiltIn() bool
- func (t *CCLTypeDefinition) IsCustomModel() bool
- func (t *CCLTypeDefinition) IsCustomType() bool
- func (t *CCLTypeDefinition) IsImmutable() bool
- func (t *CCLTypeDefinition) IsIncomplete() bool
- func (t *CCLTypeDefinition) IsMap() bool
- func (t *CCLTypeDefinition) String() string
- type CCLTypeUsage
- func (u *CCLTypeUsage) GetDefinition() *CCLTypeDefinition
- func (u *CCLTypeUsage) GetGenericArgs() []*CCLTypeUsage
- func (u *CCLTypeUsage) GetName() string
- func (u *CCLTypeUsage) GetUnderlyingType() *CCLTypeUsage
- func (u *CCLTypeUsage) IsArray() bool
- func (u *CCLTypeUsage) IsBuiltIn() bool
- func (u *CCLTypeUsage) IsCustomTypeModel() bool
- func (u *CCLTypeUsage) IsImmutable() bool
- func (u *CCLTypeUsage) SetDefinition(definition *CCLTypeDefinition)
- func (u *CCLTypeUsage) String() string
- type ModelDefinition
- func (m *ModelDefinition) DoesAliasMatch(targetAlias string) bool
- func (m *ModelDefinition) FindAttribute(name string) *AttributeUsageInfo
- func (m *ModelDefinition) FindAttributes(targetLang gValues.LanguageType, name string) []*AttributeUsageInfo
- func (m *ModelDefinition) GetFieldByName(name string) *ModelFieldDefinition
- func (m *ModelDefinition) GetFullName() string
- func (m *ModelDefinition) GetNamespace() string
- func (m *ModelDefinition) HasAttribute(attributeName ...string) bool
- func (m *ModelDefinition) String() string
- type ModelFieldDefinition
- func (p *ModelFieldDefinition) ChangeValue(value any)
- func (p *ModelFieldDefinition) ChangeValueType(typeInfo *CCLTypeUsage)
- func (f *ModelFieldDefinition) GetFullTypeName() string
- func (f *ModelFieldDefinition) HasNoType() bool
- func (f *ModelFieldDefinition) IsArray() bool
- func (f *ModelFieldDefinition) IsCustomTypeModel() bool
- func (c *ModelFieldDefinition) IsNullable() bool
- type ParameterInstance
- func (p *ParameterInstance) ChangeValue(value any)
- func (p *ParameterInstance) ChangeValueType(typeUsage *CCLTypeUsage)
- func (p *ParameterInstance) CompareValue(value any) bool
- func (p *ParameterInstance) GetAsBool() bool
- func (p *ParameterInstance) GetAsString() string
- func (p *ParameterInstance) GetInt() int
- func (p *ParameterInstance) GetString() string
- func (p *ParameterInstance) GetValue() any
- func (p *ParameterInstance) IsBuiltInType() bool
- func (p *ParameterInstance) String() string
- type SimpleTypeName
- type SourceCodeDefinition
- func (d *SourceCodeDefinition) FindGlobalAttribute(targetLang gValues.LanguageType, name string) *AttributeUsageInfo
- func (d *SourceCodeDefinition) FindGlobalAttributes(targetLang gValues.LanguageType, name string) []*AttributeUsageInfo
- func (d *SourceCodeDefinition) GetAllModels() []*ModelDefinition
- func (d *SourceCodeDefinition) GetModelByName(name string) *ModelDefinition
- func (d *SourceCodeDefinition) GetNextModelId() int64
- func (d *SourceCodeDefinition) HasGlobalAttribute(attributeName ...string) bool
- func (d *SourceCodeDefinition) IsCustomType(typeName string) bool
- type SpecificCCLTypeUsageGenerator
- type VariableDefinition
- type VariableUsageInstance
Constants ¶
const ( TypeNameString = "string" TypeNameBytes = "bytes" TypeNameInt = "int" TypeNameInt8 = "int8" TypeNameInt16 = "int16" TypeNameInt32 = "int32" TypeNameInt64 = "int64" TypeNameUint = "uint" TypeNameUint8 = "uint8" TypeNameUint16 = "uint16" TypeNameUint32 = "uint32" TypeNameUint64 = "uint64" TypeNameFloat = "float" TypeNameFloat32 = "float32" TypeNameFloat64 = "float64" TypeNameBool = "bool" TypeNameDateTime = "datetime" TypeNamePointer = "pointer" TypeNameArray = "array" )
general ccl type names
const ( TypeFlagBuiltIn cclTypeFlag = 1 << iota TypeFlagArray TypeFlagMap TypeFlagPointer TypeFlagAlias TypeFlagImmutable TypeFlagCustomModel )
ccl type flags.
const ( ReservedLiteralTrue = "true" ReservedLiteralFalse = "false" ReservedLiteralNull = "null" ReservedLiteralNil = "nil" ReservedLiteralNone = "None" ReservedLiteralSelf = "self" ReservedLiteralSuper = "super" ReservedLiteralThis = "this" ReservedLiteralNaN = "NaN" ReservedLiteralInfinity = "Infinity" )
const ( StrErrCannotOverrideBuiltInType = "cannot override built-in type: %s in namespace %s" StrErrTypeAlreadyDefined = "type already defined: %s in namespace %s" )
const (
KeywordNameModel = "model"
)
general ccl keyword names
const (
NamespaceBuiltin = "builtin"
)
ccl default namespace values
Variables ¶
var ( ErrGenericParamCantBeNil = errors.New("generic-param cannot be nil") ErrCircularGenericType = errors.New("generic-param type can't be same as current type") )
Functions ¶
func GetNormalizedKeywordName ¶
GetNormalizedKeywordName returns the normalized value of the given keyword name. If the given value is not a valid keyword name, an empty string will be returned.
func GetNormalizedReservedLiteral ¶ added in v0.0.3
GetNormalizedReservedLiteral returns the normalized value of the given reserved literal.
func GetNormalizedTypeName ¶
GetNormalizedTypeName returns the normalized value of the given type name. If the given value is not a valid type name, an empty string will be returned.
func IsBuiltinTypeName ¶
IsBuiltinTypeName checks if the given value is a valid type name. Please note that this function only checks if the type is a valid built-in type name, this package has no responsibility for checking custom type names.
func IsKeywordName ¶
IsKeywordName checks if the given value is a valid keyword name.
func IsReservedLiteral ¶ added in v0.0.3
IsReservedLiteral checks if the given value is a reserved literal. Reserved literals include: null, true, false, nil, self, super, this.
Types ¶
type AttributeUsageInfo ¶
type AttributeUsageInfo struct {
// Name is the name of the attribute.
Name string
// Languages specifies which languages this attribute should
// get applied to.
// it can be an empty string to indicate all languages.
Languages []gValues.LanguageType
// Parameters is the list of parameters for the attribute.
Parameters []*ParameterInstance
// SourcePosition is the position of the attribute in the source code.
SourcePosition *cclUtils.SourceCodePosition
}
AttributeUsageInfo is a struct that represents an attribute definition in the source code with its parameters.
func (*AttributeUsageInfo) GetParamAt ¶
func (a *AttributeUsageInfo) GetParamAt(index int) *ParameterInstance
GetParamAt returns the parameter at the specified index.
func (*AttributeUsageInfo) IsForLanguage ¶
func (a *AttributeUsageInfo) IsForLanguage(lang gValues.LanguageType) bool
IsForLanguage checks if the attribute usage info is for the given language.
func (*AttributeUsageInfo) IsForLanguageStr ¶
func (a *AttributeUsageInfo) IsForLanguageStr(lang string) bool
IsForLanguageStr checks if the attribute usage info is for the given language.
type AttributesCollection ¶
type AttributesCollection struct {
Attrs []*AttributeUsageInfo
}
AttributesCollection is a collection of attributes that holds some attributes usage info under itself and has some useful methods for manipulating them.
func NewAttrsCollection ¶
func NewAttrsCollection(attrs []*AttributeUsageInfo) *AttributesCollection
NewAttrsCollection returns collection
func (*AttributesCollection) GetParamsAt ¶
func (c *AttributesCollection) GetParamsAt(index int) []*ParameterInstance
GetParamsAt returns all parameters at the specified index from all attributes in the collection.
func (*AttributesCollection) GetParamsAtAsStrings ¶
func (c *AttributesCollection) GetParamsAtAsStrings(index int) []string
GetParamsAtAsStrings returns all parameters at the specified index from all attributes in the collection as strings.
func (*AttributesCollection) IsEmpty ¶ added in v0.0.3
func (c *AttributesCollection) IsEmpty() bool
IsEmpty returns true if the attributes collection is empty.
type CCLCodeContext ¶
type CCLCodeContext struct {
// contains filtered or unexported fields
}
func NewCCLCodeContext ¶
func NewCCLCodeContext() *CCLCodeContext
func (*CCLCodeContext) CacheTypeDefinition ¶
func (c *CCLCodeContext) CacheTypeDefinition(typeDef *CCLTypeDefinition)
CacheTypeDefinition caches the given type definition with its full name.
func (*CCLCodeContext) GetGlobalVariable ¶
func (c *CCLCodeContext) GetGlobalVariable(name string) *VariableDefinition
GetGlobalVariable returns the global variable with the given name.
func (*CCLCodeContext) GetTypeDefinition ¶
func (c *CCLCodeContext) GetTypeDefinition(name *SimpleTypeName) *CCLTypeDefinition
GetTypeDefinition returns the type definition with the given full name from the cache.
func (*CCLCodeContext) NewArrayTypeUsage ¶
func (c *CCLCodeContext) NewArrayTypeUsage(elementType *CCLTypeUsage, arrayLength int) *CCLTypeUsage
NewArrayTypeUsage creates a new array type usage that holds elements of the given element type.
func (*CCLCodeContext) NewBuiltinTypeUsage ¶
func (c *CCLCodeContext) NewBuiltinTypeUsage(name string) *CCLTypeUsage
NewBuiltinTypeUsage returns a built-in type usage for the given type name in the current code context. If the name is not a built-in type name, it returns nil.
func (*CCLCodeContext) NewCustomTypeDefinition ¶
func (c *CCLCodeContext) NewCustomTypeDefinition( name *SimpleTypeName, flags cclTypeFlag, ) (*CCLTypeDefinition, error)
NewCustomTypeDefinition creates a new custom type definition.
func (*CCLCodeContext) NewCustomTypeUsage ¶
func (c *CCLCodeContext) NewCustomTypeUsage(name *SimpleTypeName) *CCLTypeUsage
NewCustomTypeUsage returns a custom type usage for the given full type name.
func (*CCLCodeContext) NewModelTypeDefinition ¶
func (c *CCLCodeContext) NewModelTypeDefinition( name *SimpleTypeName, modelDef *ModelDefinition, ) (*CCLTypeDefinition, error)
NewModelTypeDefinition creates a new model type definition.
func (*CCLCodeContext) NewPointerTypeUsage ¶
func (c *CCLCodeContext) NewPointerTypeUsage(targetType *CCLTypeUsage) *CCLTypeUsage
NewPointerTypeUsage creates a new pointer type usage that points to the given target type.
func (*CCLCodeContext) NewTypeDefinition ¶
func (c *CCLCodeContext) NewTypeDefinition( name *SimpleTypeName, flags cclTypeFlag, tLength int, ) *CCLTypeDefinition
NewTypeDefinition creates a new type info.
type CCLReservedLiteral ¶ added in v0.0.3
type CCLReservedLiteral = string
CCLReservedLiteral is a type alias for reserved literals in CCL. These include: null, true, false, nil, self, super, this, etc...
type CCLTypeDefinition ¶
type CCLTypeDefinition struct {
// SourcePosition is the position of the type in the source code.
// Please note that for built-in types, this field is nil.
SourcePosition *cclUtils.SourceCodePosition
// contains filtered or unexported fields
}
CCLTypeDefinition is a struct that represents a CCL *type*. Now this type can be a built-in type or a custom type defined by the user. NOTE: This struct only holds general info about a type, NOT its values, etc. A type definition for a specific type HAS to be cached and reused throughout the codebase to ensure type equality checks work as expected. e.g. if you have two type definitions for "int", they MUST point to the same CCLTypeDefinition instance.
func NewTypeInfoWithOperators_OLD ¶
func NewTypeInfoWithOperators_OLD(name string, operators ...string) *CCLTypeDefinition
NewTypeInfoWithOperators_OLD creates a new type info with operators. TODO: refactor this to handle operators in a better way.
func (*CCLTypeDefinition) AddGenericParam ¶
func (t *CCLTypeDefinition) AddGenericParam(targetType *CCLTypeDefinition) error
func (*CCLTypeDefinition) GetFullName ¶
func (t *CCLTypeDefinition) GetFullName() string
GetFullName returns the full name of the type, including its namespace. This should be the one used for type comparisons and lookups.
func (*CCLTypeDefinition) GetLength ¶
func (t *CCLTypeDefinition) GetLength() int
GetLength returns the length field of the type definition. The meaning of this field depends on the type. For example, for array types, it represents the length of the array. If the type does not use length, it returns 0. If the length is dynamic or not supposed to be considered, it returns -1.
func (*CCLTypeDefinition) GetModelDefinition ¶
func (t *CCLTypeDefinition) GetModelDefinition() *ModelDefinition
GetModelDefinition returns the model definition of the type. It returns nil if the type is not a custom model type.
func (*CCLTypeDefinition) GetName ¶
func (t *CCLTypeDefinition) GetName() string
GetName returns the name of the type.
func (*CCLTypeDefinition) GetNamespace ¶
func (t *CCLTypeDefinition) GetNamespace() string
GetNamespace returns a non-empty namespace for the type. If the type is built-in, it returns "builtin". If the type has no namespace, it returns "main". Otherwise, it returns the assigned namespace.
func (*CCLTypeDefinition) GetShortModelName ¶ added in v0.0.3
func (t *CCLTypeDefinition) GetShortModelName() string
GetShortModelName returns the short name of the model type.
func (*CCLTypeDefinition) HasModelField ¶
func (t *CCLTypeDefinition) HasModelField() bool
func (*CCLTypeDefinition) IsArray ¶
func (t *CCLTypeDefinition) IsArray() bool
IsArray returns true if the type is an array.
func (*CCLTypeDefinition) IsBuiltIn ¶
func (t *CCLTypeDefinition) IsBuiltIn() bool
IsBuiltIn returns true if the type is a built-in type.
func (*CCLTypeDefinition) IsCustomModel ¶
func (t *CCLTypeDefinition) IsCustomModel() bool
IsCustomModel returns true if the type is a custom model. It does NOT necessarily check that model field is set.
func (*CCLTypeDefinition) IsCustomType ¶
func (t *CCLTypeDefinition) IsCustomType() bool
IsCustomType simply calls IsCustomModel (for now).
func (*CCLTypeDefinition) IsImmutable ¶
func (t *CCLTypeDefinition) IsImmutable() bool
func (*CCLTypeDefinition) IsIncomplete ¶
func (t *CCLTypeDefinition) IsIncomplete() bool
func (*CCLTypeDefinition) IsMap ¶
func (t *CCLTypeDefinition) IsMap() bool
IsMap returns true if the type is a map.
func (*CCLTypeDefinition) String ¶
func (t *CCLTypeDefinition) String() string
String returns the string representation of the type info.
type CCLTypeUsage ¶
type CCLTypeUsage struct {
// contains filtered or unexported fields
}
CCLTypeUsage is a struct that represents a CCL type usage instance. This type is for when the user is using a type in the source code, such as in variable definitions, function parameters, etc.
func NewTypeUsage ¶
func NewTypeUsage(definition *CCLTypeDefinition) *CCLTypeUsage
NewTypeUsage creates a new type usage for the given type definition.
func (*CCLTypeUsage) GetDefinition ¶
func (u *CCLTypeUsage) GetDefinition() *CCLTypeDefinition
GetDefinition returns the type definition of the type usage.
func (*CCLTypeUsage) GetGenericArgs ¶
func (u *CCLTypeUsage) GetGenericArgs() []*CCLTypeUsage
GetGenericArgs returns the generic arguments of the type usage.
func (*CCLTypeUsage) GetName ¶
func (u *CCLTypeUsage) GetName() string
GetName returns the name of the type usage.
func (*CCLTypeUsage) GetUnderlyingType ¶
func (u *CCLTypeUsage) GetUnderlyingType() *CCLTypeUsage
GetUnderlyingType returns the underlying type of the type usage.
func (*CCLTypeUsage) IsArray ¶
func (u *CCLTypeUsage) IsArray() bool
IsArray returns true if the type usage is of an array type.
func (*CCLTypeUsage) IsBuiltIn ¶
func (u *CCLTypeUsage) IsBuiltIn() bool
IsBuiltIn returns true if the type usage is of a built-in type.
func (*CCLTypeUsage) IsCustomTypeModel ¶ added in v0.0.3
func (u *CCLTypeUsage) IsCustomTypeModel() bool
IsCustomTypeModel returns true if the type usage is of a custom model type.
func (*CCLTypeUsage) IsImmutable ¶
func (u *CCLTypeUsage) IsImmutable() bool
IsImmutable returns true if the type usage is of an immutable type.
func (*CCLTypeUsage) SetDefinition ¶
func (u *CCLTypeUsage) SetDefinition(definition *CCLTypeDefinition)
SetDefinition sets the type definition of the type usage.
func (*CCLTypeUsage) String ¶
func (u *CCLTypeUsage) String() string
String returns a string representation of the CCLTypeUsage.
type ModelDefinition ¶
type ModelDefinition struct {
// ModelId is the unique identifier of the model.
ModelId int64
// Name is the name of the model.
Name string
// Namespace is the namespace of the model.
Namespace string
// Fields is an array of field definitions.
Fields []*ModelFieldDefinition
// Attributes is an array of attribute definitions which are applied
// to the model.
Attributes []*AttributeUsageInfo
// SourcePosition is the position of the model in the source code.
SourcePosition *cclUtils.SourceCodePosition
}
ModelDefinition is a struct that represents a model definition.
func (*ModelDefinition) DoesAliasMatch ¶
func (m *ModelDefinition) DoesAliasMatch(targetAlias string) bool
func (*ModelDefinition) FindAttribute ¶
func (m *ModelDefinition) FindAttribute(name string) *AttributeUsageInfo
FindAttribute returns the first attribute with the given name.
func (*ModelDefinition) FindAttributes ¶
func (m *ModelDefinition) FindAttributes( targetLang gValues.LanguageType, name string, ) []*AttributeUsageInfo
FindAttributes returns all attributes with the given name.
func (*ModelDefinition) GetFieldByName ¶
func (m *ModelDefinition) GetFieldByName(name string) *ModelFieldDefinition
GetFieldByName returns the field definition by the given name.
func (*ModelDefinition) GetFullName ¶ added in v0.0.3
func (m *ModelDefinition) GetFullName() string
GetFullName returns the full name of the model, including its namespace.
func (*ModelDefinition) GetNamespace ¶ added in v0.0.3
func (m *ModelDefinition) GetNamespace() string
GetNamespace returns a non-empty namespace for the model.
func (*ModelDefinition) HasAttribute ¶
func (m *ModelDefinition) HasAttribute(attributeName ...string) bool
HasAttribute returns true if the model definition has at least one of the given attributes.
func (*ModelDefinition) String ¶
func (m *ModelDefinition) String() string
type ModelFieldDefinition ¶
type ModelFieldDefinition struct {
// OwnedBy is a reference to the model that owns the field.
OwnedBy *ModelDefinition
// Name is the name of the field.
Name string
// Type is the type of the field.
Type *CCLTypeUsage
// Attributes is an array of attribute definitions which are applied
// to this field.
Attributes []*AttributeUsageInfo
// contains filtered or unexported fields
}
ModelFieldDefinition is a struct that represents a field definition.
func (*ModelFieldDefinition) ChangeValue ¶
func (p *ModelFieldDefinition) ChangeValue(value any)
ChangeValue sets the value of the parameter.
func (*ModelFieldDefinition) ChangeValueType ¶
func (p *ModelFieldDefinition) ChangeValueType(typeInfo *CCLTypeUsage)
ChangeValueType changes the value type of the parameter.
func (*ModelFieldDefinition) GetFullTypeName ¶ added in v0.0.3
func (f *ModelFieldDefinition) GetFullTypeName() string
GetFullTypeName returns the full type name of the field's type.
func (*ModelFieldDefinition) HasNoType ¶
func (f *ModelFieldDefinition) HasNoType() bool
HasNoType returns true when the field's type field is not assigned to any value.
func (*ModelFieldDefinition) IsArray ¶
func (f *ModelFieldDefinition) IsArray() bool
IsArray returns true if the field is an array. If the field does not have any type field assigned to it, it will result in a panic. So be careful before using this method.
func (*ModelFieldDefinition) IsCustomTypeModel ¶ added in v0.0.3
func (f *ModelFieldDefinition) IsCustomTypeModel() bool
IsCustomTypeModel returns true if the field's type is a custom model.
func (*ModelFieldDefinition) IsNullable ¶ added in v0.0.3
func (c *ModelFieldDefinition) IsNullable() bool
IsNullable returns true if the field's type is nullable.
type ParameterInstance ¶
type ParameterInstance struct {
// Name is the name of the parameter.
// Please note that this field might be empty, if the programmer is
// passing a parameter without specifying its name; such as in
// functionName(1, 2, 3) or [AttrName(1, 2, 3)]
Name string
// ValueType is the type of the parameter.
ValueType *CCLTypeUsage
// SourcePosition is the position of the attribute in the source code.
SourcePosition *cclUtils.SourceCodePosition
// contains filtered or unexported fields
}
ParameterInstance is a struct that represents a passed parameter instance. This parameter is for when the user is passing a parameter to a function or any other place in the source code, such as attributes. The difference between this struct and VariableUsageInstance is that this struct must be used when passing a value directly, such as in functionName(1, 2, 3) or [AttrName(1, 2, 3)], while VariableUsageInstance is used when passing a variable by its name, such as in functionName(var1, var2, var3) or [AttrName(var1, var2, var3)].
func (*ParameterInstance) ChangeValue ¶
func (p *ParameterInstance) ChangeValue(value any)
ChangeValue sets the value of the parameter.
func (*ParameterInstance) ChangeValueType ¶
func (p *ParameterInstance) ChangeValueType(typeUsage *CCLTypeUsage)
ChangeValueType changes the value type of the parameter.
func (*ParameterInstance) CompareValue ¶
func (p *ParameterInstance) CompareValue(value any) bool
CompareValue compares the value of the parameter with the given value. It returns true if both values are equal, otherwise false.
func (*ParameterInstance) GetAsBool ¶
func (p *ParameterInstance) GetAsBool() bool
GetAsBool tries to convert the parameter value to a boolean. It supports bool, int, and string types for conversion. For int, any non-zero value is considered true. For string, "true" and "1" are considered true; all other values are false.
func (*ParameterInstance) GetAsString ¶
func (p *ParameterInstance) GetAsString() string
GetAsString tries to convert the parameter value to a string. It supports string types and types implementing the fmt.Stringer interface. For other types, it uses fmt.Sprintf to convert the value to a string.
func (*ParameterInstance) GetInt ¶
func (p *ParameterInstance) GetInt() int
GetInt returns the integer value of the parameter. If the parameter is not an integer, it returns 0. Before using this method, it's highly recommended to get the value type and making sure the value of this parameter is in fact an integer.
func (*ParameterInstance) GetString ¶
func (p *ParameterInstance) GetString() string
GetString returns the string value of the parameter. If the parameter is not a string, it returns an empty string. Before using this method, it's highly recommended to get the value type and making sure the value of this parameter is in fact a string.
func (*ParameterInstance) GetValue ¶
func (p *ParameterInstance) GetValue() any
GetValue returns the raw value of the parameter.
func (*ParameterInstance) IsBuiltInType ¶
func (p *ParameterInstance) IsBuiltInType() bool
HasBuiltInType returns true if the parameter is a built-in type.
func (*ParameterInstance) String ¶
func (p *ParameterInstance) String() string
type SimpleTypeName ¶
type SimpleTypeName struct {
// TypeName is the normalized type name.
TypeName string
// Namespace is the namespace of the type.
Namespace string
}
SimpleTypeName is a struct that represents a simple type name with its namespace.
func (*SimpleTypeName) FullName ¶
func (n *SimpleTypeName) FullName() string
type SourceCodeDefinition ¶
type SourceCodeDefinition struct {
// TypeDefinitions is an array of all *custom* type definitions
// defined in the source code.
// NOTE: built-in types are NOT included in this array.
// NOTE: this array can include various different kinds of types,
// but for now, only "models" are the supported types.
TypeDefinitions []*CCLTypeDefinition
// GlobalAttributes is an array of attribute definitions which are applied
// to the whole source code.
GlobalAttributes []*AttributeUsageInfo
// contains filtered or unexported fields
}
SourceCodeDefinition is a struct that represents a source code definition and all the information about a cll source file. This struct is NOT thread-safe.
func (*SourceCodeDefinition) FindGlobalAttribute ¶
func (d *SourceCodeDefinition) FindGlobalAttribute( targetLang gValues.LanguageType, name string, ) *AttributeUsageInfo
FindGlobalAttributes returns the first global attribute with the given name.
func (*SourceCodeDefinition) FindGlobalAttributes ¶
func (d *SourceCodeDefinition) FindGlobalAttributes( targetLang gValues.LanguageType, name string, ) []*AttributeUsageInfo
FindGlobalAttributes returns all global attributes with the given name.
func (*SourceCodeDefinition) GetAllModels ¶
func (d *SourceCodeDefinition) GetAllModels() []*ModelDefinition
GetAllModels returns all model definitions defined in the source code.
func (*SourceCodeDefinition) GetModelByName ¶
func (d *SourceCodeDefinition) GetModelByName(name string) *ModelDefinition
GetModelByName returns the model definition by the given name.
func (*SourceCodeDefinition) GetNextModelId ¶
func (d *SourceCodeDefinition) GetNextModelId() int64
GetNextModelId returns the next model ID.
func (*SourceCodeDefinition) HasGlobalAttribute ¶
func (d *SourceCodeDefinition) HasGlobalAttribute(attributeName ...string) bool
HasGlobalAttribute returns true if the source code definition has at least one of the given global attributes.
func (*SourceCodeDefinition) IsCustomType ¶
func (d *SourceCodeDefinition) IsCustomType(typeName string) bool
IsCustomType returns true if the given type name is a custom type defined in the source code.
type SpecificCCLTypeUsageGenerator ¶
type SpecificCCLTypeUsageGenerator func(c *CCLCodeContext) *CCLTypeUsage
SpecificCCLTypeUsageGenerator is a function type that generates a specific CCLTypeUsage given a CCLCodeContext.
type VariableDefinition ¶
type VariableDefinition struct {
// Name is the name of the variable that is being defined.
Name string
// Type is the type of the variable.
Type *CCLTypeUsage
// SourcePosition is the position of the variable in the source code.
SourcePosition *cclUtils.SourceCodePosition
// contains filtered or unexported fields
}
VariableDefinition is a struct that represents a variable definition. e.g. global variables, local variables, etc. for example, in the following code: var myVar int = 10 the variable definition would be: Name: "myVar" Type: CCLTypeDefinition for "int" Value: 10
func (*VariableDefinition) GetValue ¶
func (d *VariableDefinition) GetValue() any
func (*VariableDefinition) HasImmutableType ¶
func (d *VariableDefinition) HasImmutableType() bool
HasImmutableType returns true if the variable's type is immutable. Immutable types are types that their value cannot be changed after being initialized. Such types include:
- Built-in types like int, float, string, bool
- User-defined models that are marked as immutable (if such feature is implemented)
func (*VariableDefinition) IsAutomatic ¶
func (v *VariableDefinition) IsAutomatic() bool
func (*VariableDefinition) SetValue ¶
func (d *VariableDefinition) SetValue(value any)
func (*VariableDefinition) String ¶
func (d *VariableDefinition) String() string
type VariableUsageInstance ¶
type VariableUsageInstance struct {
// Name is the name of the variable that is being used
Name string
// Definition points to the specified variable definition.
// This could be a global variable or a local variable, or
// could be set to nil, so always validate it before using it.
Definition *VariableDefinition
}
VariableUsageInstance is a struct that represents a variable usage instance. This type is for when the user is using a variable in the source code, such as in function calls, attribute calls, etc.
Source Files
¶
- constants.go
- errors.go
- helpers.go
- helpers_attr.go
- helpers_builtin.go
- helpers_ctx.go
- methods.go
- methods_attr.go
- methods_ctx.go
- methods_ctx_def.go
- methods_ctx_global.go
- methods_ctx_usage.go
- methods_def.go
- methods_usage.go
- types.go
- types_attr.go
- types_ctx.go
- types_def.go
- types_usage.go
- vars.go
- vars_builtin.go
- vars_def.go
- vars_global.go