1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-08 17:54:40 +00:00

Added start of code for switch

This commit is contained in:
jespergravgaard 2019-08-12 00:18:48 +02:00
parent 88cc028285
commit 46b88d8cf0
2 changed files with 26 additions and 0 deletions

View File

@ -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;

View File

@ -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.");
}