How to use the assemblyscript.NodeKind.CLASSDECLARATION function in assemblyscript

To help you get started, we’ve selected a few assemblyscript examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holochain / hdk-assemblyscript / transforms / decorator-deserializable.js View on Github external
entrySrc.statements.forEach(s => {
    if (
      s.kind === NodeKind.CLASSDECLARATION &&
      s.decorators &&
      s.decorators.length &&
      s.decorators.some(d => d.name.text === "deserializable")
    ) {
      const name = s.name.text
      const marshalCode = buildMarshal(name, deserializableClasses[name])
      console.log(marshalCode)
      const marshalStmt = parseStatements(entrySrc, marshalCode)[0]
      const method = Node.createMethodDeclaration(
        marshalStmt.name,
        null,
        marshalStmt.signature,
        marshalStmt.body,
        null,
        CommonFlags.STATIC,
        entrySrc.range  // TODO
github holochain / hdk-assemblyscript / transforms / decorator-deserializable.js View on Github external
entrySrc.statements.forEach(s => {
    if (
      s.kind === NodeKind.CLASSDECLARATION &&
      s.decorators &&
      s.decorators.length &&
      s.decorators.some(d => d.name.text === "deserializable")
    ) {
      if (s.isGeneric) {
        throw Error("Generic classes are not currently @deserializable")
      }

      const fields = []
      s.members.forEach(m => {
        if (m.kind === NodeKind.FIELDDECLARATION) {
          const name = m.name.text
          const type = m.type.name.text
          const typeArgs = m.type.typeArguments.map(t => t.name.text)
          fields.push([m.name.text, type, ...typeArgs])
        }