Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. def attachParents(prog: Program, glob: GlobalScope): Unit = {
  2. for (c <- prog.classes){
  3. c.parent match{
  4. case Some(cc) => {
  5. if (!(glob.classes contains cc.value)){
  6. fatal("Class "+ cc.value +" inherited from "+ c.id.value +" does not exists at "+c.posString)
  7. }
  8. glob.classes.get(c.id.value).get.parent= glob.classes.get(cc.value)
  9. }
  10. case _ => {/*no parent*/}
  11. }
  12. }
  13. }
  14.  
  15. def attachParents(prog: Program, glob: GlobalScope): Unit = {
  16. for (c <- prog.classes) c match {
  17. case ClassDecl(Identifier(id), Some(Identifier(parent)), _, _) => {
  18. if ((glob.classes contains parent)){
  19. glob.classes.get(id).get.parent = glob.classes.get(parent)
  20. }
  21. else fatal("Class "+ parent +" inherited from "+ id +" does not exists at " + c.posString)
  22. }
  23. case _ =>
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement