Changeset 857 for proto


Ignore:
Timestamp:
Jan 1, 2011, 8:50:14 AM (9 years ago)
Author:
cameron
Message:

Add StreamStructGen? parameter to select type or instance generation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/pablo.py

    r850 r857  
    312312  }
    313313  """
    314   def __init__(self):
    315     pass
     314  def __init__(self, asType=False):
     315    self.asType = asType
    316316  def gen(self, tree):
    317317    self.Ccode=""
     
    319319    return self.Ccode
    320320  def visit_ClassDef(self, node):
    321 #    self.Ccode += "typedef struct {\n"
    322     self.Ccode += "struct {\n"
     321    class_name = node.name[0].upper() + node.name[1:]
     322    instance_name = node.name[0].lower() + node.name[1:]
     323    self.Ccode += "struct " + class_name + " {\n"
    323324    for stmt in node.body:
    324325      if isinstance(stmt, ast.Assign):
     
    326327          if isinstance(v, ast.Name):
    327328            self.Ccode += "  BitBlock " + v.id + ";\n"
    328     self.Ccode += "} " + node.name + ";\n\n"
     329    self.Ccode += "}"
     330    if not self.asType: self.Ccode += " " + instance_name
     331    self.Ccode += ";\n\n"
    329332 
    330333class StreamFunctionDecl(ast.NodeVisitor):
Note: See TracChangeset for help on using the changeset viewer.