Minor cleanup.
This commit is contained in:
@@ -14,26 +14,22 @@ class ClassBuilder {
|
|||||||
var memberList:Array<Member>;
|
var memberList:Array<Member>;
|
||||||
var macros:Map<String,Field>;
|
var macros:Map<String,Field>;
|
||||||
var constructor:Null<Constructor>;
|
var constructor:Null<Constructor>;
|
||||||
public var target(default, null):ClassType;//TODO: this could be lazy
|
public var target(default, null):ClassType;
|
||||||
var superFields:Map<String,Bool>;
|
var superFields:Map<String,Bool>;
|
||||||
var keepers:Array<Expr>;//hack to force field generation
|
|
||||||
public function new() {
|
public function new(?target, ?fields) {
|
||||||
|
if (target == null)
|
||||||
|
target = Context.getLocalClass().get();
|
||||||
|
|
||||||
|
if (fields == null)
|
||||||
|
fields = Context.getBuildFields();
|
||||||
|
|
||||||
this.memberMap = new Map();
|
this.memberMap = new Map();
|
||||||
this.memberList = [];
|
this.memberList = [];
|
||||||
this.macros = new Map();
|
this.macros = new Map();
|
||||||
this.target = Context.getLocalClass().get();
|
this.target = target;
|
||||||
|
|
||||||
switch (target.kind) {
|
for (field in fields)
|
||||||
case KAbstractImpl(a):
|
|
||||||
//TODO: remove this whole workaround
|
|
||||||
var meta = target.meta;
|
|
||||||
for (tag in a.get().meta.get())
|
|
||||||
if (!meta.has(tag.name))
|
|
||||||
meta.add(tag.name, tag.params, tag.pos);
|
|
||||||
default:
|
|
||||||
}
|
|
||||||
|
|
||||||
for (field in Context.getBuildFields())
|
|
||||||
if (field.access.has(AMacro))
|
if (field.access.has(AMacro))
|
||||||
macros.set(field.name, field)
|
macros.set(field.name, field)
|
||||||
else if (field.name == 'new') {
|
else if (field.name == 'new') {
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ class Constructor {
|
|||||||
var onGenerateHooks:Array<Function->Void>;
|
var onGenerateHooks:Array<Function->Void>;
|
||||||
var superCall:Expr;
|
var superCall:Expr;
|
||||||
var owner:ClassBuilder;
|
var owner:ClassBuilder;
|
||||||
var keepers:Array<Expr>;//hack to force field generation
|
|
||||||
public var isPublic:Null<Bool>;
|
public var isPublic:Null<Bool>;
|
||||||
|
|
||||||
public function new(owner:ClassBuilder, f:Function, ?isPublic:Null<Bool> = null, ?pos:Position, ?meta:Metadata) {
|
public function new(owner:ClassBuilder, f:Function, ?isPublic:Null<Bool> = null, ?pos:Position, ?meta:Metadata) {
|
||||||
@@ -34,7 +33,6 @@ class Constructor {
|
|||||||
this.args = [];
|
this.args = [];
|
||||||
this.beforeArgs = [];
|
this.beforeArgs = [];
|
||||||
this.afterArgs = [];
|
this.afterArgs = [];
|
||||||
this.keepers = [];
|
|
||||||
|
|
||||||
this.oldStatements =
|
this.oldStatements =
|
||||||
if (f == null) [];
|
if (f == null) [];
|
||||||
@@ -97,11 +95,6 @@ class Constructor {
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Context.defined('js') && Context.defined('dce') && Context.definedValue('dce') == 'full') {
|
|
||||||
if (keepers.length == 0)
|
|
||||||
keepers.push(macro return);
|
|
||||||
keepers.push(macro this.$name = $e);
|
|
||||||
}
|
|
||||||
addStatement(macro @:pos(pos) if (false) { var $tmp = this.$name; $i{tmp} = $e; }, true);
|
addStatement(macro @:pos(pos) if (false) { var $tmp = this.$name; $i{tmp} = $e; }, true);
|
||||||
addStatement(macro @:pos(pos) (cast this).$name = $e, options.prepend);
|
addStatement(macro @:pos(pos) (cast this).$name = $e, options.prepend);
|
||||||
}
|
}
|
||||||
@@ -116,7 +109,6 @@ class Constructor {
|
|||||||
return [superCall]
|
return [superCall]
|
||||||
.concat(nuStatements)
|
.concat(nuStatements)
|
||||||
.concat(oldStatements)
|
.concat(oldStatements)
|
||||||
.concat(keepers)
|
|
||||||
.toBlock(pos);
|
.toBlock(pos);
|
||||||
|
|
||||||
public function onGenerate(hook)
|
public function onGenerate(hook)
|
||||||
|
|||||||
Reference in New Issue
Block a user