Beispiel #1
0
    def enterAssign(self, ctx):
        if self.blk == "model":
            deplist = self.getList(ctx)
            print(ctx.getText())
            print(deplist)
            if self.alldefined(deplist):
                if ctx.ID() is not None:
                    self.defined.append(ctx.ID().getText())
                else:
                    self.defined.append(ctx.expr(0).ID().getText())
                self.reordered_code += (self.stream.getText(
                    Interval(ctx.start.tokenIndex,
                             ctx.stop.tokenIndex))) + "\n"
                self.reassess()
            else:
                self.dependency_map[ctx] = deplist
                self.backlog.append(ctx)
        elif self.blk == "transformeddata" or (self.blk == "transformedparam"
                                               and self.unblocked):

            if ctx.ID() is not None:
                self.defined.append(ctx.ID().getText())
            else:
                arr_id = ctx.expr(0).ID().getText()
                if arr_id not in self.defined:
                    self.defined.append(arr_id)
Beispiel #2
0
 def enterIf_stmt(self, ctx):
     deplist = self.getList(ctx)
     if self.alldefined(deplist):
         self.reordered_code += (self.stream.getText(
             Interval(ctx.start.tokenIndex, ctx.stop.tokenIndex))) + "\n"
     else:
         self.dependency_map[ctx] = deplist
         self.backlog.append(ctx)
Beispiel #3
0
 def enterFor_loop(self, ctx):
     if self.blk == "model":
         deplist = self.getList(ctx)
         if self.alldefined(deplist):
             defines = self.getList(ctx, True)
             self.defined = self.defined + list(defines)
             self.reordered_code += (self.stream.getText(
                 Interval(ctx.start.tokenIndex,
                          ctx.stop.tokenIndex))) + "\n"
         else:
             self.dependency_map[ctx] = deplist
             self.backlog.append(ctx)
             self.blk = "loop"
Beispiel #4
0
 def reassess(self):
     allelements = self.backlog[:]
     unbacklogged = True
     while unbacklogged:
         unbacklogged = False
         for x in self.backlog:
             if self.alldefined(self.dependency_map[x]):
                 self.reordered_code += (self.stream.getText(
                     Interval(x.start.tokenIndex,
                              x.stop.tokenIndex))) + "\n"
                 if isinstance(x, Template2Parser.PriorContext):
                     self.defined.append(x.expr().ID().getText())
                 elif isinstance(x, Template2Parser.AssignContext):
                     if x.ID() is not None:
                         self.defined.append(x.ID().getText())
                     else:
                         self.defined.append(x.expr(0).ID().getText())
                 if isinstance(x, Template2Parser.TransformedparamContext):
                     self.defined = self.defined + list(
                         self.getList(x, True))
                 self.backlog.remove(x)
                 unbacklogged = True
Beispiel #5
0
 def enterData(self, ctx):
     self.reordered_code += (self.stream.getText(
         Interval(ctx.start.tokenIndex, ctx.stop.tokenIndex))) + "\n"
     self.defined.append(ctx.ID().getText())