• Home
  • Raw
  • Download

Lines Matching refs:serializer

144     def toC(self, serializer):  argument
145 assert isinstance(serializer, programSerializer.ProgramSerializer)
147 self.generateIncludes(serializer)
148 self.generatePreamble(serializer)
149 self.generateTypes(serializer)
150 self.generateTables(serializer)
152 serializer.newline()
153 serializer.emitIndent()
154 self.config.serializeCodeSection(serializer)
155 serializer.newline()
156 serializer.emitIndent()
157 serializer.appendFormat("int {0}(struct __sk_buff* {1}) ",
159 serializer.blockStart()
161 self.generateHeaderInstance(serializer)
162 serializer.append(" = ")
163 self.generateInitializeHeaders(serializer)
164 serializer.endOfStatement(True)
166 self.generateMetadataInstance(serializer)
167 serializer.append(" = ")
168 self.generateInitializeMetadata(serializer)
169 serializer.endOfStatement(True)
171 self.createLocalVariables(serializer)
172 serializer.newline()
174 serializer.emitIndent()
175 serializer.appendLine("goto start;")
177 self.generateParser(serializer)
178 self.generatePipeline(serializer)
180 self.generateDeparser(serializer)
182 serializer.emitIndent()
183 serializer.appendLine("end:")
184 serializer.emitIndent()
187 serializer.appendFormat("return {0};", self.dropBit)
188 serializer.newline()
191 serializer.appendFormat("if (!{0})", self.dropBit)
192 serializer.newline()
193 serializer.increaseIndent()
194 serializer.emitIndent()
195 serializer.appendFormat(
199 serializer.newline()
200 serializer.decreaseIndent()
202 serializer.emitIndent()
203 serializer.appendLine(
206 serializer.appendFormat(
209 serializer.newline()
214 serializer.blockEnd(True)
216 self.generateLicense(serializer)
218 serializer.append(self.config.postamble)
220 def generateLicense(self, serializer): argument
221 self.config.serializeLicense(serializer, self.license)
224 def generateIncludes(self, serializer): argument
225 assert isinstance(serializer, programSerializer.ProgramSerializer)
226 serializer.append(self.config.getIncludes())
241 def generatePreamble(self, serializer): argument
242 assert isinstance(serializer, programSerializer.ProgramSerializer)
244 serializer.emitIndent()
245 serializer.append("enum ErrorCode ")
246 serializer.blockStart()
248 serializer.emitIndent()
249 serializer.appendFormat("{0},", error)
250 serializer.newline()
251 serializer.blockEnd(False)
252 serializer.endOfStatement(True)
253 serializer.newline()
255 serializer.appendLine(
257 serializer.appendLine("#define BYTES(w) ((w + 7) / 8)")
259 self.config.generateDword(serializer)
271 def generateTypes(self, serializer): argument
272 assert isinstance(serializer, programSerializer.ProgramSerializer)
275 t.serialize(serializer)
278 serializer.appendFormat("struct {0} ", self.headersStructTypeName)
279 serializer.blockStart()
281 serializer.emitIndent()
282 h.declare(serializer)
283 serializer.endOfStatement(True)
288 serializer.emitIndent()
289 h.declare(serializer)
290 serializer.endOfStatement(True)
292 serializer.blockEnd(False)
293 serializer.endOfStatement(True)
296 serializer.appendFormat("struct {0} ", self.metadataStructTypeName)
297 serializer.blockStart()
301 serializer.emitIndent()
302 h.declare(serializer)
303 serializer.endOfStatement(True)
304 serializer.blockEnd(False)
305 serializer.endOfStatement(True)
307 def generateTables(self, serializer): argument
308 assert isinstance(serializer, programSerializer.ProgramSerializer)
311 t.serialize(serializer, self)
314 c.serialize(serializer, self)
316 def generateHeaderInstance(self, serializer): argument
317 assert isinstance(serializer, programSerializer.ProgramSerializer)
319 serializer.emitIndent()
320 serializer.appendFormat(
323 def generateInitializeHeaders(self, serializer): argument
324 assert isinstance(serializer, programSerializer.ProgramSerializer)
326 serializer.blockStart()
328 serializer.emitIndent()
329 serializer.appendFormat(".{0} = ", h.name)
330 h.type.emitInitializer(serializer)
331 serializer.appendLine(",")
332 serializer.blockEnd(False)
334 def generateMetadataInstance(self, serializer): argument
335 assert isinstance(serializer, programSerializer.ProgramSerializer)
337 serializer.emitIndent()
338 serializer.appendFormat(
343 def generateDeparser(self, serializer): argument
344 self.deparser.serialize(serializer, self)
346 def generateInitializeMetadata(self, serializer): argument
347 assert isinstance(serializer, programSerializer.ProgramSerializer)
349 serializer.blockStart()
351 serializer.emitIndent()
352 serializer.appendFormat(".{0} = ", h.name)
353 h.emitInitializer(serializer)
354 serializer.appendLine(",")
355 serializer.blockEnd(False)
357 def createLocalVariables(self, serializer): argument
358 assert isinstance(serializer, programSerializer.ProgramSerializer)
360 serializer.emitIndent()
361 serializer.appendFormat("unsigned {0} = 0;", self.offsetVariableName)
362 serializer.newline()
364 serializer.emitIndent()
365 serializer.appendFormat(
367 serializer.newline()
369 serializer.emitIndent()
370 serializer.appendFormat(
372 serializer.newline()
374 serializer.emitIndent()
375 serializer.appendFormat(
377 serializer.newline()
380 serializer.emitIndent()
381 serializer.appendFormat(
383 serializer.newline()
451 def generateParser(self, serializer): argument
452 assert isinstance(serializer, programSerializer.ProgramSerializer)
454 p.serialize(serializer, self)
456 def generateIngressPipeline(self, serializer): argument
457 assert isinstance(serializer, programSerializer.ProgramSerializer)
460 serializer.emitIndent()
461 serializer.appendFormat("{0}:", t.name)
462 serializer.newline()
464 def generateControlFlowNode(self, serializer, node, nextEntryPoint): argument
470 table.serializeCode(serializer, self, nextEntryPoint)
474 conditional.generateCode(serializer, self, nextEntryPoint)
479 def generatePipelineInternal(self, serializer, nodestoadd, nextEntryPoint): argument
480 assert isinstance(serializer, programSerializer.ProgramSerializer)
494 self.generateControlFlowNode(serializer, todo, nextEntryPoint)
499 def generatePipeline(self, serializer): argument
503 self.generatePipelineInternal(serializer, todo, self.egressEntry)
506 self.generatePipelineInternal(serializer, todo, None)