Class Class¶
- Defined in File quack_class.h
Nested Relationships¶
Inheritance Relationships¶
Derived Types¶
public Quack::NothingClass(Struct NothingClass)public Quack::ObjectClass(Struct ObjectClass)public Quack::PrimitiveClass(Struct PrimitiveClass)
Class Documentation¶
-
class
Class¶ Subclassed by Quack::NothingClass, Quack::ObjectClass, Quack::PrimitiveClass
Public Functions
-
Class(char *name, char *super_type, Param::Container *params, AST::Block *constructor, Method::Container *methods)¶
-
virtual
~Class()¶ Clear all dynamic memory in the object.
-
bool
has_field(const std::string &name)¶ Checks whether this class (or any of its super classes) has a field with the specified name.
- Return
- True if the field exists
- Parameters
name: Field name
-
bool
has_method(const std::string &name)¶ Checks if this class (or any of its super classes) has the specified method.
- Return
- True if the class has a method with the specified name
- Parameters
name: Name of the method to check
-
Class *
has_no_cyclic_inheritance(std::vector<Class *> &all_super)¶ Used to check for cyclical class inheritance. When classes are correctly configured, each class eventually points back (through the Object class) back to a single common class. If there is a cyclic dependency, the current class dependency will eventually appear in the
all_superlist built via recursive calls.- Return
- true if the class has no cyclic dependencies.
- Parameters
all_super: All super classes observed so far.
-
Class *
least_common_ancestor(Class *other)¶ Perform least common ancestor determination on the implicit class and the
otherclass.- Return
- Parameters
other: Another
-
bool
is_type(const std::string &name)¶ Check if the class is of the specified type.
- Return
- True if the class is of the specified type.
- Parameters
name: Name of the type
-
bool
is_subtype(Class *other_type)¶ Determines if the implicit class is a subtype of the specified type.
- Return
- True if this class is a subtype of
other_type. - Parameters
other_type: Type to check whether this class is a subtype
-
void
initial_type_check()¶ Performs an initial type check and configuration for the class’s super class as well as for the method parameters, return types, and constructor parameters.
-
void
print_original_src(unsigned int indent_depth)¶ Accessor for all the methods in the class.
- Return
- Methods in the class. Debug function used to print a representation of the original quack source code used to visualize the AST.
- Parameters
indent_depth: Depth to indent the generated code. Used for improved readability.
-
virtual bool
is_user_class() const¶ Base classes are built into the Quack language and include Boolean, Integer, String, and Object. User classes are NOT built into the Quack language by default and are defined by the user..
- Return
- True if the class is abase class.
-
const std::string
generated_object_type_name() const¶ Type name for generated objects of this type
- Return
-
const std::string
generated_clazz_type_name() const¶ Type used to for the clazz field of objects of this type.
- Return
- Class name for object
-
const std::string
generated_struct_clazz_name() const¶ Used to define the struct that stores the class information.
- Return
- Class struct information
-
const std::string
generated_constructor_name() const¶ Gets the name used for constructors of this class.
- Return
- Constructor function name
-
const std::string
generated_clazz_obj_struct_name() const¶ Gets the name of the struct object used to store the clazz information include super class. This function is used in typecase statements and in the generated class definitions.
- Return
- Name of the struct clazz struct const object
Public Members
-
const std::string
name_¶ Name of the class
Public Static Functions
-
static void
check_well_formed_hierarchy()¶ Checks all classes for any cyclical inheritance.
Protected Functions
-
void
add_binop_method(const std::string &method_name, const std::string &return_type, const std::string ¶m_type)¶ Used to add binary operation methods to the a class. Only used for base classes like Obj, Boolean, Integer, etc.
- Parameters
method_name: Name of the binary operation methodreturn_type: Return type of binary operationparam_type: Type of the other parameter’s type
-
void
add_unary_op_method(const std::string &method_name, const std::string &return_type)¶
Protected Attributes
-
GenObjContainer<Method> *
gen_methods_¶ Generated methods for the class in order
-
GenObjContainer<Field> *
gen_fields_¶ Generated fields for the class in order
Friends
-
friend
Quack::Class::CodeGen::Gen
-
class
Container: public MapContainer<Class>¶ Public Functions
-
const void
print_original_src(unsigned int indent_depth)¶ Prints the user defined classes only.
- Parameters
indent_depth: Depth to tab the contents.
-
const void
-