Exemplo n.º 1
0
def parseASInterface(s, location, tokens):
    if _isTracing:
        print('parseASInterface[{0}] @ loc({1})'.format(tokens.name, location))
    cls = ASClass(tokens.name)
    cls.isInterface = True
    # methods
    for method in tokens.methods:
        method = method[0]
        cls.methods[method.name] = method
    cls.setTokens(tokens)
    return ParseResults(cls)
Exemplo n.º 2
0
def parseASClass(s, location, tokens):
    if _isTracing:
        print('parseASClass[{0}] @ loc({1})'.format(tokens.name, location))
    cls = ASClass(tokens.name)
    # 基类 & 接口
    cls.extends = tokens.extends
    if tokens.implements:
        cls.implements = tokens.implements.asList()
    # 可见性
    if tokens.visibility == '':
        cls.visibility = 'internal'
    else:
        cls.visibility = tokens.visibility
    # 其他属性
    if tokens.dynamic == 'dynamic':
        cls.isDynamic = True
    if tokens.final == 'final':
        cls.isFinal = True
    # metatag
    if tokens.metatag:
        cls.metadata = tokens.metatag.asList()
    for variable in tokens.variables:
        variable = variable[0]
        cls.variables[variable.name] = variable
    # methods
    for method in tokens.methods:
        method = method[0]
        if not method.accessor:
            cls.methods[method.name] = method
        else:
            # getter/setter 对相关变量属性进行设置
            # if method.name not in cls.variables:
            #     cls.variables[method.name] = ASVariable(method.name)
            # v = cls.variables[method.name]
            if method.accessor == 'get':
                cls.getter_methods[method.name] = method
                # v.readable = True
                # v.type_ = method.return_type
            elif method.accessor == 'set':
                cls.setter_methods[method.name] = method
                # v.writable = True
                # v.type_ = method.arguments.values()[0].type_
            # v.visibility = method.visibility
            # v.isProperty = True
    cls.setTokens(tokens)
    return ParseResults(cls)