getter/setter for variables
This commit is contained in:
+5
-2
@@ -65,6 +65,9 @@ enum abstract ScriptObjectType(UInt8) {
|
||||
class DeclaredVar {
|
||||
public var r:Dynamic;
|
||||
public var depth:Int;
|
||||
// TODO: getter/setter for variables
|
||||
public var getter:FieldPropertyAccess = null;
|
||||
public var setter:FieldPropertyAccess = null;
|
||||
}
|
||||
|
||||
@:structInit
|
||||
@@ -878,7 +881,7 @@ class Interp {
|
||||
};
|
||||
|
||||
customClassFields.push(fd);
|
||||
case EVar(n, t, e, isPublic, isStatic, isPrivate, isFinal, isInline, getter, setter):
|
||||
case EVar(n, t, e, isPublic, isStatic, _, isFinal, _, getter, setter):
|
||||
var varAcc:Array<FieldAccess> = [];
|
||||
if (isPublic) varAcc.push(APublic);
|
||||
if (isStatic) varAcc.push(AStatic);
|
||||
@@ -1020,7 +1023,7 @@ class Interp {
|
||||
}
|
||||
case EIdent(id):
|
||||
return resolve(id);
|
||||
case EVar(n, _, e, isPublic, isStatic):
|
||||
case EVar(n, _, e, isPublic, isStatic, _, isFinal, _, getter, setter):
|
||||
declared.push({n: n, old: locals.get(n), depth: depth});
|
||||
locals.set(n, {r: (e == null) ? null : expr(e), depth: depth});
|
||||
if (depth == 0) {
|
||||
|
||||
+1
-1
@@ -902,7 +902,7 @@ class Parser {
|
||||
error(ECustom("Property requires type-hint or initialization"), p1, tokenMax);
|
||||
|
||||
nextType = null;
|
||||
mk(EVar(ident, t, e, nextIsPublic, nextIsStatic, nextIsPrivate, id == "final", nextIsInline), p1, (e == null) ? tokenMax : pmax(e));
|
||||
mk(EVar(ident, t, e, nextIsPublic, nextIsStatic, nextIsPrivate, id == "final", nextIsInline, get, set), p1, (e == null) ? tokenMax : pmax(e));
|
||||
case "while":
|
||||
var econd = parseExpr();
|
||||
var e = parseExpr();
|
||||
|
||||
Reference in New Issue
Block a user