public void Write(string name, string output, ast.Line root, ast.NameDict nameDict) { this.nameDict = nameDict; try { html.Open(output + ".html"); js.Open(output + ".js"); html.Put(html.body); html.Put(name); js.Write(js.require); foreach (var line in root.childList) { CreateBody(line); } html.Close(); js.Close(); } catch (Exception exception) { html.Delete(); js.Delete(); parser.SemErr(exception.Message + "\nStack Trace:\n" + exception.StackTrace); } finally { html.Dispose(); js.Dispose(); } }
public void Indentation(int indentation) { if (this.indentation + 1 < indentation) { parser.SemErr("Inconsistent indentation (\\t ...)"); } this.indentation = indentation; }
void CreateCode(MethodDefinition parent, ast.Line line) { for (int i = line.expr.itemList.Count - 2; i >= 0; i--) { var itemL = line.expr.itemList[i]; var itemR = line.expr.itemList[i + 1]; if (itemL is ast.Const) { parser.SemErr("Constant cannot evaluate"); } else if (itemL is ast.Call) { var callL = itemL as ast.Call; var nameL = callL.path.partList[0].name; if (itemR is ast.Const) { var cnst = itemR as ast.Const; var type = assembly.ConstType(cnst); if (assembly.IsCtor(parent)) { var field = assembly.CreateField(nameL, type, parent); assembly.LoadConst(cnst, parent); assembly.StoreField(field, parent); } else { var variable = assembly.CreateVariable(nameL, type, parent); assembly.LoadConst(cnst, parent); assembly.StoreVariable(variable, parent); } } else if (itemR is ast.Call) { var callR = itemR as ast.Call; var type = assembly.BasicType(callR.path.partList[0].name); } } } }