public override BasicBlock code() { block = bb(); IRBuilder builder = new IRBuilder(block); Value alloc; if (var is SimpleNumericVariable) { SimpleNumericVariable simpleVar = (SimpleNumericVariable)var; if (Parser.variables.numbers.ContainsKey(simpleVar.name)) { alloc = Parser.variables.numbers[simpleVar.name]; } else { Parser.variables.numbers[simpleVar.name] = builder.CreateAlloca(Parser.dbl, simpleVar.name); alloc = Parser.variables.numbers[simpleVar.name]; } } else { NumericArrayElement arrayElement = (NumericArrayElement)var; alloc = Parser.variables.arrayItem(builder, arrayElement.numericarrayname, arrayElement.index.code(builder)); } Value exprVal = value.code(builder); builder.CreateStore(exprVal, alloc); return(block); }
public void ExitSimplenumericvariable(BASICParser.SimplenumericvariableContext context) { currentSimpleNumericVariable = new SimpleNumericVariable(context.GetText()); wasArray = false; if (!varFound) { letNumericVar = currentSimpleNumericVariable; varFound = true; } }
public void ExitControlvariable(BASICParser.ControlvariableContext context) { currentControlVariable = currentSimpleNumericVariable; }