WIP Class Parsing
This commit is contained in:
@@ -142,6 +142,8 @@ class Bytes {
|
||||
switch( e ) {
|
||||
case EImport(c):
|
||||
// TODO
|
||||
case EClass(_, _, _, _):
|
||||
// TODO
|
||||
case EConst(c):
|
||||
doEncodeConst(c);
|
||||
case EIdent(v):
|
||||
|
||||
@@ -24,6 +24,7 @@ class ClassExtendMacro {
|
||||
}
|
||||
|
||||
public static function init() {
|
||||
//Compiler.addGlobalMetadata('funkin', '@:build(hscript.ClassExtendMacro.build())');
|
||||
Compiler.addGlobalMetadata('flixel', '@:build(hscript.ClassExtendMacro.build())');
|
||||
//Compiler.addGlobalMetadata('openfl.display.BlendMode', '@:build(hscript.UsingHandler.build())');
|
||||
trace("TEST");
|
||||
@@ -35,7 +36,7 @@ class ClassExtendMacro {
|
||||
if (clRef == null) return fields;
|
||||
var cl = clRef.get();
|
||||
|
||||
if (!cl.name.endsWith("_Impl_") && !cl.name.endsWith(CLASS_SUFFIX)) {//(/* cl.name.startsWith("Flx") && */ cl.name.endsWith("_Impl_") && cl.params.length <= 0 && !cl.meta.has(":multiType")) {
|
||||
if (!cl.name.endsWith("_Impl_") && !cl.name.endsWith(CLASS_SUFFIX) && !cl.name.endsWith("__Softcoded")) {//(/* cl.name.startsWith("Flx") && */ cl.name.endsWith("_Impl_") && cl.params.length <= 0 && !cl.meta.has(":multiType")) {
|
||||
var metas = cl.meta.get();
|
||||
|
||||
if(cl.params.length > 0) {
|
||||
@@ -74,6 +75,7 @@ class ClassExtendMacro {
|
||||
switch(f.kind) {
|
||||
case FFun(fun):
|
||||
if (!f.access.contains(AStatic) && f.name != "new" && !f.access.contains(ADynamic)) { /* || !cl.name.endsWith(CLASS_SUFFIX)*/
|
||||
if (fun.params.length > 0) continue;
|
||||
if (fun.expr != null) {
|
||||
//trace(fun.expr);
|
||||
var newFuncName = FUNC_PREFIX + f.name;
|
||||
|
||||
+3
-1
@@ -57,7 +57,7 @@ enum Expr {
|
||||
EFor( v : String, it : Expr, e : Expr );
|
||||
EBreak;
|
||||
EContinue;
|
||||
EFunction( args : Array<Argument>, e : Expr, ?name : String, ?ret : CType, ?isPublic : Bool, ?isStatic : Bool);
|
||||
EFunction( args : Array<Argument>, e : Expr, ?name : String, ?ret : CType, ?isPublic : Bool, ?isStatic : Bool, ?isOverride : Bool);
|
||||
EReturn( ?e : Expr );
|
||||
EArray( e : Expr, index : Expr );
|
||||
EArrayDecl( e : Array<Expr>, ?wantedType: CType);
|
||||
@@ -70,7 +70,9 @@ enum Expr {
|
||||
EDoWhile( cond : Expr, e : Expr);
|
||||
EMeta( name : String, args : Array<Expr>, e : Expr );
|
||||
ECheckType( e : Expr, t : CType );
|
||||
|
||||
EImport( c : String );
|
||||
EClass(name:String, fields:Array<Expr>, ?extend:String, interfaces:Array<String>);
|
||||
}
|
||||
|
||||
typedef Argument = { name : String, ?t : CType, ?opt : Bool, ?value : Expr };
|
||||
|
||||
+4
-1
@@ -446,6 +446,9 @@ class Interp {
|
||||
var e = e.e;
|
||||
#end
|
||||
switch (e) {
|
||||
case EClass(name, fields, extend, interfaces):
|
||||
trace(fields);
|
||||
//trace(Printer.toString(fields));
|
||||
case EImport(c):
|
||||
if (!importEnabled)
|
||||
return null;
|
||||
@@ -570,7 +573,7 @@ class Interp {
|
||||
case EReturn(e):
|
||||
returnValue = e == null ? null : expr(e);
|
||||
throw SReturn;
|
||||
case EFunction(params, fexpr, name, _, isPublic, isStatic):
|
||||
case EFunction(params, fexpr, name, _, isPublic, isStatic, isOverride):
|
||||
var __capturedLocals = duplicate(locals);
|
||||
var capturedLocals:Map<String, {r:Dynamic, depth:Int}> = [];
|
||||
for(k=>e in __capturedLocals)
|
||||
|
||||
+546
-409
File diff suppressed because it is too large
Load Diff
+17
-2
@@ -116,6 +116,21 @@ class Printer {
|
||||
switch( #if hscriptPos e.e #else e #end ) {
|
||||
case EImport(c):
|
||||
add("import " + c);
|
||||
case EClass(name, fields, extend, interfaces):
|
||||
add('class $name');
|
||||
if (extend != null)
|
||||
add(' extends $extend');
|
||||
for(_interface in interfaces) {
|
||||
add(' implements $_interface');
|
||||
}
|
||||
add(' {\n');
|
||||
tabs += "\t";
|
||||
//for(field in fields) {
|
||||
// expr(field);
|
||||
//}
|
||||
|
||||
tabs = tabs.substr(1);
|
||||
add("}");
|
||||
case EConst(c):
|
||||
switch( c ) {
|
||||
case CInt(i): add(i);
|
||||
@@ -124,7 +139,7 @@ class Printer {
|
||||
}
|
||||
case EIdent(v):
|
||||
add(v);
|
||||
case EVar(n, t, e):
|
||||
case EVar(n, t, e): // TODO: static, public, override
|
||||
add("var " + n);
|
||||
addType(t);
|
||||
if( e != null ) {
|
||||
@@ -209,7 +224,7 @@ class Printer {
|
||||
add("break");
|
||||
case EContinue:
|
||||
add("continue");
|
||||
case EFunction(params, e, name, ret):
|
||||
case EFunction(params, e, name, ret): // TODO: static, public, override
|
||||
add("function");
|
||||
if( name != null )
|
||||
add(" " + name);
|
||||
|
||||
@@ -28,6 +28,7 @@ class Tools {
|
||||
switch( expr(e) ) {
|
||||
case EConst(_), EIdent(_):
|
||||
case EImport(c): f(e);
|
||||
case EClass(_, e, _, _): for( a in e ) f(a);
|
||||
case EVar(_, _, e): if( e != null ) f(e);
|
||||
case EParent(e): f(e);
|
||||
case EBlock(el): for( e in el ) f(e);
|
||||
@@ -89,6 +90,7 @@ class Tools {
|
||||
case EMeta(name, args, e): EMeta(name, args == null ? null : [for( a in args ) f(a)], f(e));
|
||||
case ECheckType(e,t): ECheckType(f(e), t);
|
||||
case EImport(c): EImport(c);
|
||||
case EClass(name, el, extend, interfaces): EClass(name, [for( e in el ) f(e)], extend, interfaces);
|
||||
}
|
||||
return mk(edef, e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user