Skip to content

Commit

Permalink
first iteration on FClosure and FEnum field access
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyfa committed Mar 16, 2024
1 parent d54b8d9 commit 9df8f30
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
32 changes: 23 additions & 9 deletions src/cscompiler/components/CSCompiler_Expr.hx
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ class CSCompiler_Expr extends CSCompiler_Base {
Implementation of `CSCompiler.compileExpressionImpl`.
**/
public function compile(expr: TypedExpr, topLevel: Bool): Null<CSStatement> {
return null;
var result = null;
/*
switch(expr.expr) {
return switch(expr.expr) {
case TConst(constant): {
haxeExpr: expr,
def: CSExprStatement({
Expand Down Expand Up @@ -139,12 +136,26 @@ class CSCompiler_Expr extends CSCompiler_Base {
case FDynamic(s):
compileDynamicGetField(expr, s);
case FClosure(c, cf):
CSConst(CSNull); // TODO
case FEnum(e, ef):
CSConst(CSNull); // TODO
// TODO: do we need to generate different code than FInstance?
CSField(
csStatementToExpr(_compileExpression(e)),
CSFInstance(
c?.c != null ? compiler.typeComp.compileClassType(c.c.get()) : 'object', // TODO: Should it be 'object' if we don't have any class type there?
c?.params != null ? compiler.typeComp.compileTypeParams(c.params) : [],
cf.get().name
)
);
case FEnum(en, ef):
CSField(
csStatementToExpr(_compileExpression(e)),
CSFInstance(
compiler.typeComp.compileEnumType(en.get()),
[],
ef.name
)
);
}
})
//result = fieldAccessToCS(e, fa);
}
/*
case TTypeExpr(m): {
Expand Down Expand Up @@ -301,8 +312,11 @@ class CSCompiler_Expr extends CSCompiler_Base {
// Given an expression that is an instance of an enum,
// generate the C# code to extract its index.
}
*/
case _:
null;
}
/* return */ result;
///* return */ result;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/cscompiler/components/CSCompiler_Type.hx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class CSCompiler_Type extends CSCompiler_Base {
}
}

function compileEnumType(enumType:EnumType):CSTypePath {
public function compileEnumType(enumType:EnumType):CSTypePath {

return compileEnumName(enumType, true);

Expand Down

0 comments on commit 9df8f30

Please sign in to comment.