
1 // 2 // Copyright (c) 2006, Brian Frank and Andy Frank 3 // Licensed under the Academic Free License version 3.0 4 // 5 // History: 6 // 4 Feb 06 Brian Frank Creation 7 // 11 Sep 06 Brian Frank Ported from Java to Fan 8 // 9 10 ** 11 ** MethodVar is a variable used in a method - either param or local. 12 ** 13 class MethodVar 14 { 15 16 new make(Int register, CType ctype, Str name, Int flags := 0, Block scope := null) 17 { 18 this.register = register 19 this.ctype = ctype 20 this.name = name 21 this.flags = flags 22 this.scope = scope 23 this.usedInClosure = false 24 } 25 26 new makeForParam(Int register, ParamDef p) 27 : this.make(register, p.paramType, p.name, FConst.Param, null) 28 { 29 this.paramDef = p 30 } 31 32 Bool isParam() 33 { 34 return (flags & FConst.Param) != 0 35 } 36 37 override Str toStr() 38 { 39 return "$register $name: $ctype" 40 } 41 42 Int register // register number 43 CType ctype // variable type 44 Str name // variable name 45 Int flags // Param 46 Block scope // block which scopes this variable 47 ParamDef paramDef // if param 48 Bool usedInClosure // local used by closure within containing method 49 CField cvarsField // if mapped into a field of closure variable class 50 51 }