SPPCompiler.SemanticAnalysis.Asts.FunctionPrototypeAst module¶
- class SPPCompiler.SemanticAnalysis.Asts.FunctionPrototypeAst.FunctionPrototypeAst(pos=0, annotations=<factory>, tok_fun=None, name=None, generic_parameter_group=None, function_parameter_group=None, tok_arrow=None, return_type=None, where_block=None, body=None, *, _visibility=(Visibility.Private, None), _ctx=None, _scope=None, is_type_ast=False, _orig=None, _abstract=None, _virtual=None, _non_implemented=None, _cold=None, _hot=None, _inline=None, _generic_impls=<factory>)¶
Bases:
Ast
,VisibilityEnabledAst
- annotations: list[Asts.AnnotationAst]¶
- tok_fun: Asts.TokenAst¶
- name: Asts.IdentifierAst¶
- generic_parameter_group: Asts.GenericParameterGroupAst¶
- function_parameter_group: Asts.FunctionParameterGroupAst¶
- tok_arrow: Asts.TokenAst¶
- return_type: Asts.TypeAst¶
- where_block: Asts.WhereBlockAst¶
- body: Asts.FunctionImplementationAst¶
- print(printer)¶
Print an AST with indentation for inner scopes. The decorator and AstPrinter object “printer” work together to auto-format the output. This function will result in almost identical code to the source code being parsed and generated; the only difference will be the preprocessing applications, which mainly focus on function generation. Some ASTs will be re-ordered, with no effect on code execution.
- Parameters:
printer (
AstPrinter
) – The auto-formatting AstPrinter object. It can be created inline, and the top-most AST it is created in will be the most un-tabbed AST.- Return type:
str
- Returns:
The output string to be printed, fully formatted and pre-processed.
- print_signature(printer, owner=None)¶
- property pos_end: int¶
The
pos_end
property gets the final index spanned to by this AST. Implementations recursively choose the final AST from their attributes and get that AST’s end position. This will end up with either an identifier of token’s end position, and for either AST this is its start position + length of identifier/token.- Returns:
The final index spanned by this AST.
- pre_process(ctx)¶
The default AST steps for pre-processing is to save the context into an attribute. This is used in later analysis stages.
- Parameters:
ctx (
TypeAliasType
) – The pre-processing context.- Return type:
None
- Returns:
None.
- generate_top_level_scopes(sm)¶
The default AST steps for generating top level scopes is to save the scope into an attribute. This is used in later analysis stages.
- Parameters:
sm (
ScopeManager
) – The scope manager.- Return type:
None
- Returns:
None.
- generate_top_level_aliases(sm, **kwargs)¶
! The generate top-level aliases stage generates all aliases at the module/sup level. This must come after the symbol generation stage, as it requires symbol knowledge to attach the correct “old types”. It must also come before the load sup scopes stage, because superimposing over aliases requires the alias to exist beforehand, in any order of compilation. :param sm The scope manager. :param kwargs Additional keyword arguments.
- Return type:
None
- qualify_types(sm, **kwargs)¶
… :type sm:
ScopeManager
:param sm: :type kwargs: :param kwargs: :rtype:None
:return:
- load_super_scopes(sm, **kwargs)¶
- Return type:
None
- pre_analyse_semantics(sm, **kwargs)¶
- Return type:
None
- analyse_semantics(sm, **kwargs)¶
The semantic analysis stage is the most complex, and final analysis, stage of the semantic pipeline. This stage performs all the semantic checks, type inference, and type checking. This stage requires all symbols to be generated, and all types to be aliased, loaded, and post-processed. All functions scopes are inspected. :param sm The scope manager. :param kwargs Additional keyword arguments.
- Return type:
None
- check_memory(sm, **kwargs)¶
The check memory stage is the final stage of the semantic pipeline. This stage performs all the memory checks, and has to happen after, and not during semantic analysis, because sometimes the ASTs are analysed out of order to allow for type-inference. This messes up the strict order of memory checks, so the additional stage enforces the order of memory checks. :type sm:
ScopeManager
:param sm: The scope manager. :type kwargs: :param kwargs: Additional keyword arguments.- Return type:
None
- code_gen_pass_1(sm, llvm_module, **kwargs)¶
The first pass of the code generation handles declarations. This includes type declarations (no memory layout set), and function declarations (no body set). This is because for class attributes, the types need to have already been created :type sm:
ScopeManager
:param sm: The scope manager. :type llvm_module:Module
:param llvm_module: The LLVM module to generate code for. :type kwargs: :param kwargs: Additional keyword arguments.- Return type:
None