Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement object types #23

Open
JoaaoVerona opened this issue May 29, 2016 · 0 comments
Open

Implement object types #23

JoaaoVerona opened this issue May 29, 2016 · 0 comments

Comments

@JoaaoVerona
Copy link
Owner

Object types are the first - and more important - step for finally implementing object-oriented features.
Script should be able to create new object types, instantiate object types, call definitions inside object types and change attributes of object types.
Not only that, but object types can overload operators, define constructors, define attributes and create definitions.
It is not important for now to have inheritance, nor overriding polymorphism. Overloading polymorphism is already handled by the current function-finding system.

Definition:

new keyword to create a constructor
object keyword to create a new object type
opr keyword to overload an operator

Example usage:

object SomeObjectName {
  int size
  array elements
  bool enabled
  AnotherType child

  new(array elements, bool enabled) {
    this.enabled = enabled
    someFunction(elements)
  }

  opr +(SomeObjectName other) {
    return size + other.size
  }

  opr &&(SomeObjectName other) {
    return enabled && other.enabled
  }

  def someFunction(array elements) {
    this.elements = elements
    this.size = size(elements)
  }
}
@JoaaoVerona JoaaoVerona self-assigned this May 29, 2016
JoaaoVerona added a commit that referenced this issue May 29, 2016
JoaaoVerona added a commit that referenced this issue May 29, 2016
JoaaoVerona added a commit that referenced this issue May 29, 2016
JoaaoVerona added a commit that referenced this issue May 29, 2016
JoaaoVerona added a commit that referenced this issue May 29, 2016
JoaaoVerona added a commit that referenced this issue May 29, 2016
JoaaoVerona added a commit that referenced this issue May 29, 2016
JoaaoVerona added a commit that referenced this issue May 29, 2016
JoaaoVerona added a commit that referenced this issue May 29, 2016
JoaaoVerona added a commit that referenced this issue May 29, 2016
JoaaoVerona added a commit that referenced this issue May 29, 2016
JoaaoVerona added a commit that referenced this issue May 29, 2016
…o variable references but also to object's attributes default values, constructors, etc) (part of #23)
JoaaoVerona added a commit that referenced this issue May 29, 2016
…ls resultor::addInContext when needed, and detects/parses 'new' statements (part of #23)
JoaaoVerona added a commit that referenced this issue Jun 5, 2016
…object's definitions from accessing script variables); also added Attribute::hasDefaultExpression (shortcut to getDefaultExpression != null) (part of #23)
JoaaoVerona added a commit that referenced this issue Jun 5, 2016
…hen calling it, the context will be modified (part of #23)
JoaaoVerona added a commit that referenced this issue Jun 5, 2016
…y are dynamic); also updated parser to afford this (part of #23)
JoaaoVerona added a commit that referenced this issue Jun 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant