"Fossies" - the Fresh Open Source Software Archive

Member "ponyc-0.33.0/src/libponyc/type/matchtype.h" (1 Nov 2019, 1472 Bytes) of package /linux/misc/ponyc-0.33.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "matchtype.h" see the Fossies "Dox" file reference documentation.

    1 #ifndef MATCHTYPE_H
    2 #define MATCHTYPE_H
    3 
    4 #include <platform.h>
    5 #include "../ast/ast.h"
    6 #include "../pass/pass.h"
    7 
    8 PONY_EXTERN_C_BEGIN
    9 
   10 /// See comment for is_matchtype() for a description of these values
   11 typedef enum
   12 {
   13   MATCHTYPE_ACCEPT,
   14   MATCHTYPE_REJECT,
   15   MATCHTYPE_DENY
   16 } matchtype_t;
   17 
   18 /**
   19  * Determine if we can match on operand_type and extract a pattern_type.
   20  *
   21  * Return ACCEPT if there exists a type which is all of:
   22  * 1. A subtype of operand_type.
   23  * 2. A type that an object of type operand_type can be safely used as. This is
   24  *    an important restriction to maintain capability safety. If operand_type
   25  *    is "Foo box" then "Foo ref" is a subtype of that, but not one that we can
   26  *    safely use.
   27  *    This complication exists because capabilities cannot be recovered at
   28  *    runtime and must be handled entirely at compile time.
   29  * 3. A subtype of pattern_type.
   30  *
   31  * Return DENY if no such type can exist, but one could if capabilities were
   32  * ignored. For example an operand_type of "Foo box" and a pattern_type of
   33  * "Foo ref". This is to prevent a match that could be detected with runtime
   34  * information but would actually violate the capability guarantees.
   35  * When DENY is returned, no matching is allowed, even if some other
   36  * is_matchtype() relationship exists.
   37  *
   38  * Return REJECT if no such type can exist.
   39  */
   40 matchtype_t is_matchtype(ast_t* operand, ast_t* pattern, errorframe_t* errorf,
   41   pass_opt_t* opt);
   42 
   43 PONY_EXTERN_C_END
   44 
   45 #endif