public static IProgram Transform(IProgram p) { TypeMap globalMap = StaticTypeCheck.Typing(p.Globals()); Functions funcs = p.functions(); foreach (Function f in p.functions().Values.ToList()) { TypeMap newMap = new TypeMap(); newMap.PutAll(globalMap); newMap.PutAll(StaticTypeCheck.Typing(f.Param())); newMap.PutAll(StaticTypeCheck.Typing(f.Locals())); Block transformedBody = (Block)Transform(f.Body(), funcs, newMap); if (!funcs.ContainsKey(f.Id())) { funcs.Add(f.Id(), new Function(f.type(), f.Id(), f.Param(), f.Locals(), transformedBody)); } else { funcs[f.Id()] = new Function(f.type(), f.Id(), f.Param(), f.Locals(), transformedBody); } } return(new IProgram(p.Globals(), funcs)); }
public static void Validate(IProgram p) { Check(p.functions().ContainsKey("main"), "Error! Main function not found!"); Validate(p.functions(), Typing(p.Globals())); }
public static State Interpret(IProgram p) { return(interpret(p.functions().get("main").body(), p.functions(), initialState(p.globals()))); }
public static State Interpret(IProgram p) { return(Interpret(p.functions()["main"].Body(), p.functions(), InitialState(p.Globals()))); }