• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) Barefoot Networks, Inc.
2# Licensed under the Apache License, Version 2.0 (the "License")
3
4from compilationException import CompilationException
5
6class EbpfType(object):
7    __doc__ = "Base class for representing a P4 type"
8
9    def __init__(self, hlirType):
10        self.hlirType = hlirType
11
12    # Methods to override
13
14    def serialize(self, serializer):
15        # the type itself
16        raise CompilationException(True, "Method must be overridden")
17
18    def declare(self, serializer, identifier, asPointer):
19        # declaration of an identifier with this type
20        # asPointer is a boolean;
21        # if true, the identifier is declared as a pointer
22        raise CompilationException(True, "Method must be overridden")
23
24    def emitInitializer(self, serializer):
25        # A default initializer suitable for this type
26        raise CompilationException(True, "Method must be overridden")
27
28    def declareArray(self, serializer, identifier, size):
29        # Declare an identifier with an array type with the specified size
30        raise CompilationException(True, "Method must be overridden")
31