public object VisitCaseAST([NotNull] CaseASTContext context) { if (context.NUM() != null) { context.typeString = "num"; } else if (context.CHARCONST() != null) { context.typeString = "char"; } else if (context.STRING() != null) { context.typeString = "string"; } else if (context.boolean() != null) { Visit(context.boolean()); context.typeString = "bool"; } List <Pair <string, IToken> > returnedTypes = new List <Pair <string, IToken> >(); if (context.statement() != null) { var list = Visit(context.statement()) as List <Pair <string, IToken> >; if (list != null) { returnedTypes.AddRange(list); } } return(returnedTypes); }
public object VisitCaseAST([NotNull] CaseASTContext context) { if (context.typeString != "bool") { var value = context.NUM() ?? context.CHARCONST() ?? context.STRING(); AddLine($"LOAD_CONST {value.GetText()}"); } else { var value = Visit(context.boolean()) as string; AddLine($"LOAD_CONST {value}"); } AddLine("COMPARE_OP =="); int jumpIfFalsePosition = LineCount; AddLine("JUMP_IF_FALSE"); if (context.statement() != null) { Visit(context.statement()); } SetLineOnRealIndexOf(jumpIfFalsePosition, $"JUMP_IF_FALSE {LineCount}"); return(null); }