mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-04-11 20:37:40 +00:00
Added start of code for switch
This commit is contained in:
parent
88cc028285
commit
46b88d8cf0
src/main/java/dk/camelot64/kickc
@ -116,6 +116,12 @@ public class StatementSource implements Serializable {
|
||||
return new StatementSource(nodeStart, nodeStop);
|
||||
}
|
||||
|
||||
public static StatementSource switchExpr(KickCParser.StmtSwitchContext ctx) {
|
||||
ParseTree nodeStart = ctx;
|
||||
ParseTree nodeStop = ctx.getChild(ctx.getChildCount() - 4);
|
||||
return new StatementSource(nodeStart, nodeStop);
|
||||
}
|
||||
|
||||
public static StatementSource procedureEnd(KickCParser.DeclFunctionContext ctx) {
|
||||
ParseTree nodeStart = ctx.getChild(ctx.getChildCount() - 1);
|
||||
ParseTree nodeStop = ctx;
|
||||
|
@ -975,6 +975,26 @@ public class Pass0GenerateStatementSequence extends KickCBaseVisitor<Object> {
|
||||
|
||||
@Override
|
||||
public Object visitStmtSwitch(KickCParser.StmtSwitchContext ctx) {
|
||||
/*
|
||||
// Create a block scope - to keep all statements of the loop inside it
|
||||
BlockScope blockScope = getCurrentScope().addBlockScope();
|
||||
scopeStack.push(blockScope);
|
||||
loopStack.push(new Loop(blockScope));
|
||||
List<Comment> comments = ensureUnusedComments(getCommentsSymbol(ctx));
|
||||
// TODO: Add comments to next stmt
|
||||
// Evaluate the switch-expression
|
||||
PrePostModifierHandler.addPreModifiers(this, ctx.commaExpr(), StatementSource.switchExpr(ctx));
|
||||
RValue rValue = (RValue) this.visit(ctx.commaExpr());
|
||||
PrePostModifierHandler.addPostModifiers(this, ctx.commaExpr(), StatementSource.switchExpr(ctx));
|
||||
|
||||
// TODO: Iterate cases
|
||||
// TODO: Handle default
|
||||
|
||||
// TODO: Do something to handle continue!
|
||||
addLoopBreakLabel(loopStack.pop(), ctx);
|
||||
scopeStack.pop();
|
||||
return null;
|
||||
*/
|
||||
throw new InternalError("switch() is not supported in this version of the compiler.");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user