/// /** * Some util function to determinate or extract properties of AST node. * */ import { ClassDeclaration, CommonFlags, DeclarationStatement, DecoratorNode, DiagnosticEmitter, FieldDeclaration, FunctionDeclaration, MethodDeclaration, NamedTypeNode, ObjectLiteralExpression, Node, StringLiteralExpression, Range } from "assemblyscript"; import { ContractDecoratorKind } from "./ast"; export declare function removeExported(node: { flags: CommonFlags; }): void; export declare function isEntry(node: Node): boolean; export declare function mustBeVoidReturn(emitter: DiagnosticEmitter, node: FunctionDeclaration): boolean; export declare function mustBeLegalStorageField(emitter: DiagnosticEmitter, node: FieldDeclaration): boolean; /** * check if decorator have params * @param emitter emit warning if return false * @param decorator pending checked decorator * @returns */ export declare function shouldBeNoParamDecorator(emitter: DiagnosticEmitter, decorator: DecoratorNode): boolean; /** * check if contract method is public * @param emitter emit error if return false * @param node contract method * @returns */ export declare function mustBePublicMethod(emitter: DiagnosticEmitter, node: MethodDeclaration): boolean; /** * check if contract method is non-static * @param emitter emit error if return false * @param node contract method * @param kind contract kind info * @returns */ export declare function mustBeNonStaticMethod(emitter: DiagnosticEmitter, node: MethodDeclaration, kind: ContractDecoratorKind): boolean; /** * return true if class have not a parent * @param emitter emit error if return false * @param node * @returns */ export declare function mustBeNoExtends(emitter: DiagnosticEmitter, node: ClassDeclaration): boolean; export declare function namedTypeNodeToString(node: NamedTypeNode): string; /** * * @param decorators a group decorators * @param name a decorator name * @returns return true if has the decorator */ export declare function hasDecorator(decorators: DecoratorNode[] | null, name: string): boolean; /** * Return the first matched decorator * @param decorators a group decorators * @param name a decorator name * @returns */ export declare function getDecorator(decorators: DecoratorNode[] | null, name: string): DecoratorNode | null; /** * * @param decorators * @param pred a filter function for decorators * @returns */ export declare function filterDecorators(decorators: DecoratorNode[] | null, pred: (node: DecoratorNode) => bool): DecoratorNode[]; /** * return the last decorator of method or null if have not * @param node contract constructor method */ export declare function extractDecorator(emitter: DiagnosticEmitter, node: DeclarationStatement, kind: ContractDecoratorKind): DecoratorNode | null; /** * A general format config for decorator. * * It's no-nested json which value must be string. */ export declare class DecoratorConfig extends Map { readonly decorator: DecoratorNode; constructor(decorator: DecoratorNode); static extractFrom(emitter: DiagnosticEmitter, decorator: DecoratorNode): DecoratorConfig; } /** * Extract the config map from decorator params * @param decorator * @returns */ export declare function extractConfigFromDecorator(emitter: DiagnosticEmitter, decorator: DecoratorNode): DecoratorConfig; /** * return the first literal object for decorator or null if have not * @param emitter * @param decorator * @returns */ export declare function extractLiteralObject(emitter: DiagnosticEmitter, decorator: DecoratorNode): ObjectLiteralExpression | null; /** * return the first literal string for decorator or null if have not * @param emitter * @param decorator * @returns */ export declare function extractLiteralString(emitter: DiagnosticEmitter, decorator: DecoratorNode, range: Range): StringLiteralExpression | null; /** * Extract a config map from JS object literal. * @param emitter * @param node * @returns */ export declare function extractConfigFromLiteral(emitter: DiagnosticEmitter, decorator: DecoratorNode, node: ObjectLiteralExpression | null): DecoratorConfig;