GithubHelp home page GithubHelp logo

Create vm service models about webdev HOT 7 CLOSED

jakemac53 avatar jakemac53 commented on May 30, 2024
Create vm service models

from webdev.

Comments (7)

jakemac53 avatar jakemac53 commented on May 30, 2024 2

Actually, it looks like https://github.com/dart-lang/vm_service_drivers already has a parser for the markdown file, and we could likely just add serialization logic to that generator and use that package instead of maintaining our own yaml file.

from webdev.

jakemac53 avatar jakemac53 commented on May 30, 2024

Example yaml file for all the models up to and including the Event type:

classes:
  BoundField:
    fields:
      decl:
        type: '@Field'
      value:
        type: '@Instance|Sentinel'
  BoundVariable:
    fields:
      name:
        type: string
      value:
        type: '@Instance|@TypeArguments|Sentinel'
      declarationTokenPos:
        type: int
      scopeStartTokenPos:
        type: int
      scopeEndTokenPos:
        type: int
  Breakpoint:
    extends: Object
    fields:
      breakpointNumber:
        type: int
      resolved:
        type: bool
      isSyntheticAsyncContinuation:
        type: bool
        optional: true
      location:
        type: SourceLocation|UnresolvedSourceLocation
  '@Class':
    extends: '@Object'
    fields:
      name:
        type: string
  Class:
    extends: Object
    fields:
      name:
        type: string
      error:
        type: '@Error'
        optional: true
      abstract:
        type: bool
      const:
        type: bool
      library:
        type: '@Library'
      location:
        type: SourceLocation
        optional: true
      super:
        type: '@Class'
        optional: true
      superType:
        type: '@Instance'
        optional: true
      interfaces:
        type: '@Instance[]'
      mixin:
        type: '@Instance'
        optional: true
      fields:
        type: '@Field[]'
      functions:
        type: '@Function[]'
      subclasses:
        type: '@Class[]'
  ClassList:
    extends: Response
    fields:
      classes: '@Class[]'
  '@Code':
    extends: '@Object'
    fields:
      name:
        type: string
      kind:
        type: CodeKind
  Code:
    extends: '@Object'
    fields:
      name:
        type: string
      kind:
        type: CodeKind
  '@Context':
    extends: '@Object'
    fields:
      length:
        type: int
  Context:
    extends: Object
    fields:
      length:
        type: int
      parent:
        type: Context
        optional: true
      variables:
        type: 'ContextElement[]'
  ContextElement:
    fields:
      value:
        type: '@Instance|Sentinel'
  '@Error':
    extends: '@Object'
    fields:
      kind:
        type: ErrorKind
      message:
        type: string
  Error:
    extends: Object
    fields:
      kind:
        type: ErrorKind
      message:
        type: string
      exception:
        type: '@Instance'
        optional: true
      stacktrace:
        type: '@Instance'
        optional: true
  Event:
    extends: Response
    fields:
      kind:
        type: EventKind
      isolate:
        type: '@Isolate'
        optional: true
      vm:
        type: '@VM'
        optional: true
      timestamp:
        type: int
      breakpoint:
        type: Breakpoint
        optional: true
      pauseBreakpoints:
        type: Breakpoint[]
        optional: true
      topFrame:
        type: Frame
        optional: true
      exception:
        type: '@Instance'
        optional: true
      bytes:
        type: string
        optional: true
      inspectee:
        type: '@Instance'
        optional: true
      extensionRPC:
        type: string
        optional: true
      extensionKind:
        type: string
        optional: true
      extensionData:
        type: ExtensionData
        optional: true
      timelineEvents:
        type: TimelineEvent[]
        optional: true
      atAsyncSuspension:
        type: bool
        optional: true
      status:
        type: String
        optional: true

enums:
  CodeKind:
    - Dart
    - Native
    - Stub
    - Tag
    - Collected
  ErrorKind:
    - UnhandledException
    - LanguageError
    - InternalError
    - TerminationError

from webdev.

natebosch avatar natebosch commented on May 30, 2024

When we say "extends" here does that translate to an extends in the generated Dart code? That precludes generating correct equals implementations if subclasses add fields...

from webdev.

jakemac53 avatar jakemac53 commented on May 30, 2024

When we say "extends" here does that translate to an extends in the generated Dart code?

Yes

That precludes generating correct equals implementations if subclasses add fields...

how so? also i don't think this is a requirement for us in any case (I wasn't planning on implementing equals or hashCode)

from webdev.

jakemac53 avatar jakemac53 commented on May 30, 2024

fwiw, it seems like you can do:

bool operator==(other) => other is ThisType && other.someField == someField && super == other;

a bit bizarre, but it appears to work

from webdev.

natebosch avatar natebosch commented on May 30, 2024

how so?

In Dart (as in many other OO languages) you cannot use extends with an instantiable super class and implement operator== on both that follows the contract and the Liskov Substitution Principle.

The docs say that the operator must be symmetric.

If the implementation of SuperType.operator== checks other is SuperType, and the SubType.operator== checks other is SubType, then this property is not held.

var a = SuperType();
var b = SubType();
a == b; // true, b is SuperType holds
b == a; // false, a is SubType does not hold

If you try to get around this problem by using other.runtimeType == SuperType then you can fix the symmetry, but fail Liskov Substitution because an instance of SubType is no longer indistinguishable from a SuperType when used as such.

I think you can get around the problem if you ignore the extra fields in SubType when it comes to equality, but that ends up being a pretty lame implementation.
You can also get around the problem if only the leaf classes are instantiable and the super types are abstract.

from webdev.

jakemac53 avatar jakemac53 commented on May 30, 2024

Ah ya good point, we can just ignore equals for now.

from webdev.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.