コード例 #1
0
ファイル: mjclass.py プロジェクト: chiiph/compilor
    def __init__(self, name, ext_name, decls, ts, localts=None):
        super(mjClass, self).__init__()
        self.name = name
        self.ext_name = ext_name
        self.ext_class = None  # no resuelto todavia
        self.decls = decls
        self.long = 0
        self.vtable = "VT_%s" % self.name.get_lexeme()
        self.cr = "CR_%s" % self.name.get_lexeme()
        self.preconstruct = "%s_spreconstr" % self.name.get_lexeme()
        self.ipreconstruct = "%s_ipreconstr" % self.name.get_lexeme()

        if not ts is None:
            (redef, other) = ts.classExists(self)
            if redef:
                raise SemanticError(other.name.get_line(), other.name.get_col(), "Clase ya definida")

            ts.addClass(self)
        self.ts = localts
        if localts is None:
            self.ts = mjTS(ts)

        self.ts.set_owner(self)

        self.gen_default_construct()

        if self.ext_name is None and self.name.get_lexeme() != "Object":
            e = Token()
            e._lexeme = "Object"
            e._type = IDENTIFIER
            e._line = 0
            e._col = 0
            self.ext_name = e
コード例 #2
0
ファイル: mjclass.py プロジェクト: chiiph/compilor
    def gen_default_construct(self):
        for d in self.decls:
            if isMethod(d) and d.is_constructor():
                return

        p = Token()
        p._lexeme = "public"
        p._type = PUBLIC
        modifs = [p]

        m = mjMethod(modifs, None, self.name, [], mjBlock(), self.ts)
        self.decls.append(m)
コード例 #3
0
    def gen_default_construct(self):
        for d in self.decls:
            if isMethod(d) and d.is_constructor():
                return

        p = Token()
        p._lexeme = "public"
        p._type = PUBLIC
        modifs = [p]

        m = mjMethod(modifs, None, self.name, [], mjBlock(), self.ts)
        self.decls.append(m)
コード例 #4
0
    def __init__(self, name, ext_name, decls, ts, localts=None):
        super(mjClass, self).__init__()
        self.name = name
        self.ext_name = ext_name
        self.ext_class = None  # no resuelto todavia
        self.decls = decls
        self.long = 0
        self.vtable = "VT_%s" % self.name.get_lexeme()
        self.cr = "CR_%s" % self.name.get_lexeme()
        self.preconstruct = "%s_spreconstr" % self.name.get_lexeme()
        self.ipreconstruct = "%s_ipreconstr" % self.name.get_lexeme()

        if not ts is None:
            (redef, other) = ts.classExists(self)
            if redef:
                raise SemanticError(other.name.get_line(),
                                    other.name.get_col(), "Clase ya definida")

            ts.addClass(self)
        self.ts = localts
        if localts is None:
            self.ts = mjTS(ts)

        self.ts.set_owner(self)

        self.gen_default_construct()

        if self.ext_name is None and self.name.get_lexeme() != "Object":
            e = Token()
            e._lexeme = "Object"
            e._type = IDENTIFIER
            e._line = 0
            e._col = 0
            self.ext_name = e
コード例 #5
0
  def create_predefs(self):
    o = Token()
    o._lexeme = "Object"
    o._type = IDENTIFIER
    o._line = 0
    o._col = 0

    cl = mjc.mjClass(o, None, [], self)