Cody

Solution 1111211

Submitted on 27 Jan 2017 by Alexander Levedahl
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
x = 153; y_correct = 1; assert(isequal(armno(x),y_correct))

a = /opt/mlsedu/matlab/R2016b/toolbox/matlab/codetools/@mtree/mtree.m classdef mtree %MTREE Create and manipulate M parse trees % This is an experimental program whose behavior and interface is likely % to change in the future. % Copyright 2006-2016 The MathWorks, Inc. properties (SetAccess='protected', GetAccess='protected', Hidden) T % parse tree array % column 1: kind of node % column 2: index of left child % column 3: index of right child % column 4: index of next node % column 5: position of node % column 6: size of node % column 7: symbol table index (V)R/ % column 8: string table index % column 9: index of parent node % column 10: setting node % column 11: lefttreepos % column 12: righttreepos % column 13: true parent % column 14: righttreeindex % column 15: rightfullindex S % symbol table C % character strings IX % index set (default is true for everything) n % number of nodes m % sum(IX) lnos % line number translation str % input string that created the tree end properties (SetAccess='private', GetAccess='public') % The type of the code file represented by the tree % This will be one of the values of the mtree.Type % enum, such as mtree.Type.ScriptFile, etc. FileType end properties (GetAccess='public', Constant, Hidden) N = mtree_info(1) % node names K = mtree_info(2) % node key KK = mtree_info(3) % the internal names (for debugging) Uop = mtree_info(4) % true if node is a unary op Bop = mtree_info(5) % true if node is a binary op Stmt = mtree_info(6) % true if node is a statement Linkno = mtree_info(7) % maps link to index Lmap = mtree_info(8) % link map Linkok = mtree_info(9) % is link OK for a given node PTval = mtree_info(10) % array of nodes whose V is a position value V = { '2.50', '2.50' }; % version array end methods [v1,v2] = version(o) end methods (Access='protected') % housekeeping methods L = linelookup( o, P ) end methods % CONSTRUCTOR function o = mtree( text, varargin ) %MTREE o = MTREE( text, options ) constructs an mtree object % % Options include: % -file: the text argument is treated as a filename % -comments: comments are included in the tree % -cell: cell markers are included in the tree if nargin == 0 || ~ischar( text ) error(message('MATLAB:mtree:usage')); end opts = {}; for i=1:nargin-1 if strcmp( varargin{i}, '-file' ) try fname = text; text = matlab.internal.getCode(text); catch x error(message('MATLAB:mtree:input', fname)); end else switch varargin{i} case '-comments' opts{end+1} = '-com'; %#ok<AGROW> otherwise opts{end+1} = varargin{i}; %#ok<AGROW> end end end o.str = text; [o.T,o.S,o.C, o.FileType] = mtreemex( text, opts{:} ); % this code needs to be clever about old MAC files L1 = text==char(10); if sum(L1)==0 % there are no newlines in the file L1 = text==char(13); end o.lnos = [ 0 find(L1) length(text) ]'; o = wholetree( o ); end o = wholetree( o ) end methods (Hidden) b = eq( o, oo ) b = ne( o, oo ) b = le( o, oo ) o = subtree(o) % Deprecated. o = fullsubtree( o ) % Deprecated. function o = list(o) %LIST list is deprecated -- use List o = List(o); end function o = full(o) %full full is deprecated -- use wholetree o = wholetree(o); end b = isfull(o) % Deprecated. end methods m = count( o ) oo = root( o ) oo = null( o ) end methods (Access='protected',Hidden) oo = makeAttrib( o, I ) [I,ipath,flag,rest] = pathit( o, I, ipath ) a = restrict( o, ipath, s ) end methods a = path(o, pth ) % Deprecated since it interferes with the builtin. a = mtpath(o, pth ) c = strings( o ) c = stringvals( o ) s = string( o ) s = stringval( o ) a = find( o, varargin ) % Deprecated. a = mtfind( o, varargin ) o = sets( o ) end methods % methods for following paths... o = Left(o) o = Arg(o) o = Try(o) o = Attr(o) o = Right(o) o = Body(o) o = Catch(o) o = CatchID(o) o = Next(o) o = Parent(o) o = Outs(o) o = Index(o) o = Cattr(o) o = Vector(o) o = Cexpr(o) o = Ins(o) o = Fname(o) o = lhs( o ) o = previous( o ) oo = first( o ) o = last( o ) end properties(Dependent) VarName; VarType; VarDimensions; VarValidators; end methods function name = get.VarName(o) name = varName(o); end function type = get.VarType(o) type = varType(o); end function dims = get.VarDimensions(o) dims = varDimensions(o); end function vals = get.VarValidators(o) vals = varValidators(o); end end methods(Access=private, Hidden) function o = varName(o) %VARNAME returns the Name node of a typed variable. % fast for single nodes... lix = o.Linkno.VarName; J = o.T( o.IX, 2 ); % go to name node KKK = o.Linkok( lix, o.T( o.IX, 1 ) ) & (J~=0)'; J = J(KKK); o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varType(o) %VARTYPE returns the Type node of a typed variable. % fast for single nodes... lix = o.Linkno.VarType; J = o.T( o.IX, 3 ); % go to ETC node KKK = o.Linkok( lix, o.T( o.IX, 1 ) ) & (J~=0)'; J = J(KKK); J = o.T( J, 2 ); % go to type node J = J(J~=0); o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varDimensions(o) %VARDIMENSIONS returns the Size node of a typed variable. % fast for single nodes... lix = o.Linkno.VarDimensions; J = o.T(o.IX, 3); % go to first ETC KKK = o.Linkok(lix, o.T(o.IX, 1)) & (J ~= 0)'; J = J(KKK); for next = [3 2] % then ETC -> Size J = o.T(J, next); J = J(J ~= 0); end o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varValidators(o) %VARVALIDATOR returns the Validators node of a typed variable. % fast for single nodes... lix = o.Linkno.VarDimensions; J = o.T(o.IX, 3); % go to ETC KKK = o.Linkok(lix, o.T(o.IX, 1)) & (J ~= 0)'; J = J(KKK); for next = [3 3 2] % then ETC -> ETC -> Validators J = o.T(J, next); J = J(J ~= 0); end o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end end methods oo = setter( o ) end methods (Hidden) % Low-level methods that are used for testing or special purposes % and will not be documented. b = sametree( o, oo ) oo = rawset( o ) T = newtree( o, varargin ) s = getpath( o, r ) function o = L(o) %L o = L(o) Raw Left operation % fast for single nodes... J = o.T( o.IX, 2 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = R(o) %R o = R(o) Raw Right operation J = o.T( o.IX, 3 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = P(o) %P o = P(o) Raw Parent operation J = o.T( o.IX, 9 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = X(o) %X o = X(o) Raw Next operation J = o.T( o.IX, 4 ); o.m = o.m - sum( J==0 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; end o = or( o, o2 ) o = and( o, o2 ) o = not( o ) o = minus( o, o2 ) end methods oo = allsetter( o, o2 ) % Deprecated. oo = anysetter( o, o2 ) % Deprecated. disp(o) show(o) dump(o) % Deprecated. dumptree(o) rawdump(o) o = List( o ) o = Full( o ) o = Tree( o ) oo = asgvars( o ) oo = geteq( o ) oo = dominator( o ) ooo = dominates( oo, o ) b = isbop( o ) b = isuop( o ) b = isop( o ) b = isstmt( o ) o = ops( o ) o = bops( o ) o =...

2   Pass
x = 143; y_correct = 0; assert(isequal(armno(x),y_correct))

a = /opt/mlsedu/matlab/R2016b/toolbox/matlab/codetools/@mtree/mtree.m classdef mtree %MTREE Create and manipulate M parse trees % This is an experimental program whose behavior and interface is likely % to change in the future. % Copyright 2006-2016 The MathWorks, Inc. properties (SetAccess='protected', GetAccess='protected', Hidden) T % parse tree array % column 1: kind of node % column 2: index of left child % column 3: index of right child % column 4: index of next node % column 5: position of node % column 6: size of node % column 7: symbol table index (V)R/ % column 8: string table index % column 9: index of parent node % column 10: setting node % column 11: lefttreepos % column 12: righttreepos % column 13: true parent % column 14: righttreeindex % column 15: rightfullindex S % symbol table C % character strings IX % index set (default is true for everything) n % number of nodes m % sum(IX) lnos % line number translation str % input string that created the tree end properties (SetAccess='private', GetAccess='public') % The type of the code file represented by the tree % This will be one of the values of the mtree.Type % enum, such as mtree.Type.ScriptFile, etc. FileType end properties (GetAccess='public', Constant, Hidden) N = mtree_info(1) % node names K = mtree_info(2) % node key KK = mtree_info(3) % the internal names (for debugging) Uop = mtree_info(4) % true if node is a unary op Bop = mtree_info(5) % true if node is a binary op Stmt = mtree_info(6) % true if node is a statement Linkno = mtree_info(7) % maps link to index Lmap = mtree_info(8) % link map Linkok = mtree_info(9) % is link OK for a given node PTval = mtree_info(10) % array of nodes whose V is a position value V = { '2.50', '2.50' }; % version array end methods [v1,v2] = version(o) end methods (Access='protected') % housekeeping methods L = linelookup( o, P ) end methods % CONSTRUCTOR function o = mtree( text, varargin ) %MTREE o = MTREE( text, options ) constructs an mtree object % % Options include: % -file: the text argument is treated as a filename % -comments: comments are included in the tree % -cell: cell markers are included in the tree if nargin == 0 || ~ischar( text ) error(message('MATLAB:mtree:usage')); end opts = {}; for i=1:nargin-1 if strcmp( varargin{i}, '-file' ) try fname = text; text = matlab.internal.getCode(text); catch x error(message('MATLAB:mtree:input', fname)); end else switch varargin{i} case '-comments' opts{end+1} = '-com'; %#ok<AGROW> otherwise opts{end+1} = varargin{i}; %#ok<AGROW> end end end o.str = text; [o.T,o.S,o.C, o.FileType] = mtreemex( text, opts{:} ); % this code needs to be clever about old MAC files L1 = text==char(10); if sum(L1)==0 % there are no newlines in the file L1 = text==char(13); end o.lnos = [ 0 find(L1) length(text) ]'; o = wholetree( o ); end o = wholetree( o ) end methods (Hidden) b = eq( o, oo ) b = ne( o, oo ) b = le( o, oo ) o = subtree(o) % Deprecated. o = fullsubtree( o ) % Deprecated. function o = list(o) %LIST list is deprecated -- use List o = List(o); end function o = full(o) %full full is deprecated -- use wholetree o = wholetree(o); end b = isfull(o) % Deprecated. end methods m = count( o ) oo = root( o ) oo = null( o ) end methods (Access='protected',Hidden) oo = makeAttrib( o, I ) [I,ipath,flag,rest] = pathit( o, I, ipath ) a = restrict( o, ipath, s ) end methods a = path(o, pth ) % Deprecated since it interferes with the builtin. a = mtpath(o, pth ) c = strings( o ) c = stringvals( o ) s = string( o ) s = stringval( o ) a = find( o, varargin ) % Deprecated. a = mtfind( o, varargin ) o = sets( o ) end methods % methods for following paths... o = Left(o) o = Arg(o) o = Try(o) o = Attr(o) o = Right(o) o = Body(o) o = Catch(o) o = CatchID(o) o = Next(o) o = Parent(o) o = Outs(o) o = Index(o) o = Cattr(o) o = Vector(o) o = Cexpr(o) o = Ins(o) o = Fname(o) o = lhs( o ) o = previous( o ) oo = first( o ) o = last( o ) end properties(Dependent) VarName; VarType; VarDimensions; VarValidators; end methods function name = get.VarName(o) name = varName(o); end function type = get.VarType(o) type = varType(o); end function dims = get.VarDimensions(o) dims = varDimensions(o); end function vals = get.VarValidators(o) vals = varValidators(o); end end methods(Access=private, Hidden) function o = varName(o) %VARNAME returns the Name node of a typed variable. % fast for single nodes... lix = o.Linkno.VarName; J = o.T( o.IX, 2 ); % go to name node KKK = o.Linkok( lix, o.T( o.IX, 1 ) ) & (J~=0)'; J = J(KKK); o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varType(o) %VARTYPE returns the Type node of a typed variable. % fast for single nodes... lix = o.Linkno.VarType; J = o.T( o.IX, 3 ); % go to ETC node KKK = o.Linkok( lix, o.T( o.IX, 1 ) ) & (J~=0)'; J = J(KKK); J = o.T( J, 2 ); % go to type node J = J(J~=0); o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varDimensions(o) %VARDIMENSIONS returns the Size node of a typed variable. % fast for single nodes... lix = o.Linkno.VarDimensions; J = o.T(o.IX, 3); % go to first ETC KKK = o.Linkok(lix, o.T(o.IX, 1)) & (J ~= 0)'; J = J(KKK); for next = [3 2] % then ETC -> Size J = o.T(J, next); J = J(J ~= 0); end o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varValidators(o) %VARVALIDATOR returns the Validators node of a typed variable. % fast for single nodes... lix = o.Linkno.VarDimensions; J = o.T(o.IX, 3); % go to ETC KKK = o.Linkok(lix, o.T(o.IX, 1)) & (J ~= 0)'; J = J(KKK); for next = [3 3 2] % then ETC -> ETC -> Validators J = o.T(J, next); J = J(J ~= 0); end o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end end methods oo = setter( o ) end methods (Hidden) % Low-level methods that are used for testing or special purposes % and will not be documented. b = sametree( o, oo ) oo = rawset( o ) T = newtree( o, varargin ) s = getpath( o, r ) function o = L(o) %L o = L(o) Raw Left operation % fast for single nodes... J = o.T( o.IX, 2 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = R(o) %R o = R(o) Raw Right operation J = o.T( o.IX, 3 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = P(o) %P o = P(o) Raw Parent operation J = o.T( o.IX, 9 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = X(o) %X o = X(o) Raw Next operation J = o.T( o.IX, 4 ); o.m = o.m - sum( J==0 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; end o = or( o, o2 ) o = and( o, o2 ) o = not( o ) o = minus( o, o2 ) end methods oo = allsetter( o, o2 ) % Deprecated. oo = anysetter( o, o2 ) % Deprecated. disp(o) show(o) dump(o) % Deprecated. dumptree(o) rawdump(o) o = List( o ) o = Full( o ) o = Tree( o ) oo = asgvars( o ) oo = geteq( o ) oo = dominator( o ) ooo = dominates( oo, o ) b = isbop( o ) b = isuop( o ) b = isop( o ) b = isstmt( o ) o = ops( o ) o = bops( o ) o =...

3   Pass
x = 370; y_correct = 1; assert(isequal(armno(x),y_correct))

a = /opt/mlsedu/matlab/R2016b/toolbox/matlab/codetools/@mtree/mtree.m classdef mtree %MTREE Create and manipulate M parse trees % This is an experimental program whose behavior and interface is likely % to change in the future. % Copyright 2006-2016 The MathWorks, Inc. properties (SetAccess='protected', GetAccess='protected', Hidden) T % parse tree array % column 1: kind of node % column 2: index of left child % column 3: index of right child % column 4: index of next node % column 5: position of node % column 6: size of node % column 7: symbol table index (V)R/ % column 8: string table index % column 9: index of parent node % column 10: setting node % column 11: lefttreepos % column 12: righttreepos % column 13: true parent % column 14: righttreeindex % column 15: rightfullindex S % symbol table C % character strings IX % index set (default is true for everything) n % number of nodes m % sum(IX) lnos % line number translation str % input string that created the tree end properties (SetAccess='private', GetAccess='public') % The type of the code file represented by the tree % This will be one of the values of the mtree.Type % enum, such as mtree.Type.ScriptFile, etc. FileType end properties (GetAccess='public', Constant, Hidden) N = mtree_info(1) % node names K = mtree_info(2) % node key KK = mtree_info(3) % the internal names (for debugging) Uop = mtree_info(4) % true if node is a unary op Bop = mtree_info(5) % true if node is a binary op Stmt = mtree_info(6) % true if node is a statement Linkno = mtree_info(7) % maps link to index Lmap = mtree_info(8) % link map Linkok = mtree_info(9) % is link OK for a given node PTval = mtree_info(10) % array of nodes whose V is a position value V = { '2.50', '2.50' }; % version array end methods [v1,v2] = version(o) end methods (Access='protected') % housekeeping methods L = linelookup( o, P ) end methods % CONSTRUCTOR function o = mtree( text, varargin ) %MTREE o = MTREE( text, options ) constructs an mtree object % % Options include: % -file: the text argument is treated as a filename % -comments: comments are included in the tree % -cell: cell markers are included in the tree if nargin == 0 || ~ischar( text ) error(message('MATLAB:mtree:usage')); end opts = {}; for i=1:nargin-1 if strcmp( varargin{i}, '-file' ) try fname = text; text = matlab.internal.getCode(text); catch x error(message('MATLAB:mtree:input', fname)); end else switch varargin{i} case '-comments' opts{end+1} = '-com'; %#ok<AGROW> otherwise opts{end+1} = varargin{i}; %#ok<AGROW> end end end o.str = text; [o.T,o.S,o.C, o.FileType] = mtreemex( text, opts{:} ); % this code needs to be clever about old MAC files L1 = text==char(10); if sum(L1)==0 % there are no newlines in the file L1 = text==char(13); end o.lnos = [ 0 find(L1) length(text) ]'; o = wholetree( o ); end o = wholetree( o ) end methods (Hidden) b = eq( o, oo ) b = ne( o, oo ) b = le( o, oo ) o = subtree(o) % Deprecated. o = fullsubtree( o ) % Deprecated. function o = list(o) %LIST list is deprecated -- use List o = List(o); end function o = full(o) %full full is deprecated -- use wholetree o = wholetree(o); end b = isfull(o) % Deprecated. end methods m = count( o ) oo = root( o ) oo = null( o ) end methods (Access='protected',Hidden) oo = makeAttrib( o, I ) [I,ipath,flag,rest] = pathit( o, I, ipath ) a = restrict( o, ipath, s ) end methods a = path(o, pth ) % Deprecated since it interferes with the builtin. a = mtpath(o, pth ) c = strings( o ) c = stringvals( o ) s = string( o ) s = stringval( o ) a = find( o, varargin ) % Deprecated. a = mtfind( o, varargin ) o = sets( o ) end methods % methods for following paths... o = Left(o) o = Arg(o) o = Try(o) o = Attr(o) o = Right(o) o = Body(o) o = Catch(o) o = CatchID(o) o = Next(o) o = Parent(o) o = Outs(o) o = Index(o) o = Cattr(o) o = Vector(o) o = Cexpr(o) o = Ins(o) o = Fname(o) o = lhs( o ) o = previous( o ) oo = first( o ) o = last( o ) end properties(Dependent) VarName; VarType; VarDimensions; VarValidators; end methods function name = get.VarName(o) name = varName(o); end function type = get.VarType(o) type = varType(o); end function dims = get.VarDimensions(o) dims = varDimensions(o); end function vals = get.VarValidators(o) vals = varValidators(o); end end methods(Access=private, Hidden) function o = varName(o) %VARNAME returns the Name node of a typed variable. % fast for single nodes... lix = o.Linkno.VarName; J = o.T( o.IX, 2 ); % go to name node KKK = o.Linkok( lix, o.T( o.IX, 1 ) ) & (J~=0)'; J = J(KKK); o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varType(o) %VARTYPE returns the Type node of a typed variable. % fast for single nodes... lix = o.Linkno.VarType; J = o.T( o.IX, 3 ); % go to ETC node KKK = o.Linkok( lix, o.T( o.IX, 1 ) ) & (J~=0)'; J = J(KKK); J = o.T( J, 2 ); % go to type node J = J(J~=0); o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varDimensions(o) %VARDIMENSIONS returns the Size node of a typed variable. % fast for single nodes... lix = o.Linkno.VarDimensions; J = o.T(o.IX, 3); % go to first ETC KKK = o.Linkok(lix, o.T(o.IX, 1)) & (J ~= 0)'; J = J(KKK); for next = [3 2] % then ETC -> Size J = o.T(J, next); J = J(J ~= 0); end o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varValidators(o) %VARVALIDATOR returns the Validators node of a typed variable. % fast for single nodes... lix = o.Linkno.VarDimensions; J = o.T(o.IX, 3); % go to ETC KKK = o.Linkok(lix, o.T(o.IX, 1)) & (J ~= 0)'; J = J(KKK); for next = [3 3 2] % then ETC -> ETC -> Validators J = o.T(J, next); J = J(J ~= 0); end o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end end methods oo = setter( o ) end methods (Hidden) % Low-level methods that are used for testing or special purposes % and will not be documented. b = sametree( o, oo ) oo = rawset( o ) T = newtree( o, varargin ) s = getpath( o, r ) function o = L(o) %L o = L(o) Raw Left operation % fast for single nodes... J = o.T( o.IX, 2 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = R(o) %R o = R(o) Raw Right operation J = o.T( o.IX, 3 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = P(o) %P o = P(o) Raw Parent operation J = o.T( o.IX, 9 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = X(o) %X o = X(o) Raw Next operation J = o.T( o.IX, 4 ); o.m = o.m - sum( J==0 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; end o = or( o, o2 ) o = and( o, o2 ) o = not( o ) o = minus( o, o2 ) end methods oo = allsetter( o, o2 ) % Deprecated. oo = anysetter( o, o2 ) % Deprecated. disp(o) show(o) dump(o) % Deprecated. dumptree(o) rawdump(o) o = List( o ) o = Full( o ) o = Tree( o ) oo = asgvars( o ) oo = geteq( o ) oo = dominator( o ) ooo = dominates( oo, o ) b = isbop( o ) b = isuop( o ) b = isop( o ) b = isstmt( o ) o = ops( o ) o = bops( o ) o =...

4   Pass
x = 371; y_correct = 1; assert(isequal(armno(x),y_correct))

a = /opt/mlsedu/matlab/R2016b/toolbox/matlab/codetools/@mtree/mtree.m classdef mtree %MTREE Create and manipulate M parse trees % This is an experimental program whose behavior and interface is likely % to change in the future. % Copyright 2006-2016 The MathWorks, Inc. properties (SetAccess='protected', GetAccess='protected', Hidden) T % parse tree array % column 1: kind of node % column 2: index of left child % column 3: index of right child % column 4: index of next node % column 5: position of node % column 6: size of node % column 7: symbol table index (V)R/ % column 8: string table index % column 9: index of parent node % column 10: setting node % column 11: lefttreepos % column 12: righttreepos % column 13: true parent % column 14: righttreeindex % column 15: rightfullindex S % symbol table C % character strings IX % index set (default is true for everything) n % number of nodes m % sum(IX) lnos % line number translation str % input string that created the tree end properties (SetAccess='private', GetAccess='public') % The type of the code file represented by the tree % This will be one of the values of the mtree.Type % enum, such as mtree.Type.ScriptFile, etc. FileType end properties (GetAccess='public', Constant, Hidden) N = mtree_info(1) % node names K = mtree_info(2) % node key KK = mtree_info(3) % the internal names (for debugging) Uop = mtree_info(4) % true if node is a unary op Bop = mtree_info(5) % true if node is a binary op Stmt = mtree_info(6) % true if node is a statement Linkno = mtree_info(7) % maps link to index Lmap = mtree_info(8) % link map Linkok = mtree_info(9) % is link OK for a given node PTval = mtree_info(10) % array of nodes whose V is a position value V = { '2.50', '2.50' }; % version array end methods [v1,v2] = version(o) end methods (Access='protected') % housekeeping methods L = linelookup( o, P ) end methods % CONSTRUCTOR function o = mtree( text, varargin ) %MTREE o = MTREE( text, options ) constructs an mtree object % % Options include: % -file: the text argument is treated as a filename % -comments: comments are included in the tree % -cell: cell markers are included in the tree if nargin == 0 || ~ischar( text ) error(message('MATLAB:mtree:usage')); end opts = {}; for i=1:nargin-1 if strcmp( varargin{i}, '-file' ) try fname = text; text = matlab.internal.getCode(text); catch x error(message('MATLAB:mtree:input', fname)); end else switch varargin{i} case '-comments' opts{end+1} = '-com'; %#ok<AGROW> otherwise opts{end+1} = varargin{i}; %#ok<AGROW> end end end o.str = text; [o.T,o.S,o.C, o.FileType] = mtreemex( text, opts{:} ); % this code needs to be clever about old MAC files L1 = text==char(10); if sum(L1)==0 % there are no newlines in the file L1 = text==char(13); end o.lnos = [ 0 find(L1) length(text) ]'; o = wholetree( o ); end o = wholetree( o ) end methods (Hidden) b = eq( o, oo ) b = ne( o, oo ) b = le( o, oo ) o = subtree(o) % Deprecated. o = fullsubtree( o ) % Deprecated. function o = list(o) %LIST list is deprecated -- use List o = List(o); end function o = full(o) %full full is deprecated -- use wholetree o = wholetree(o); end b = isfull(o) % Deprecated. end methods m = count( o ) oo = root( o ) oo = null( o ) end methods (Access='protected',Hidden) oo = makeAttrib( o, I ) [I,ipath,flag,rest] = pathit( o, I, ipath ) a = restrict( o, ipath, s ) end methods a = path(o, pth ) % Deprecated since it interferes with the builtin. a = mtpath(o, pth ) c = strings( o ) c = stringvals( o ) s = string( o ) s = stringval( o ) a = find( o, varargin ) % Deprecated. a = mtfind( o, varargin ) o = sets( o ) end methods % methods for following paths... o = Left(o) o = Arg(o) o = Try(o) o = Attr(o) o = Right(o) o = Body(o) o = Catch(o) o = CatchID(o) o = Next(o) o = Parent(o) o = Outs(o) o = Index(o) o = Cattr(o) o = Vector(o) o = Cexpr(o) o = Ins(o) o = Fname(o) o = lhs( o ) o = previous( o ) oo = first( o ) o = last( o ) end properties(Dependent) VarName; VarType; VarDimensions; VarValidators; end methods function name = get.VarName(o) name = varName(o); end function type = get.VarType(o) type = varType(o); end function dims = get.VarDimensions(o) dims = varDimensions(o); end function vals = get.VarValidators(o) vals = varValidators(o); end end methods(Access=private, Hidden) function o = varName(o) %VARNAME returns the Name node of a typed variable. % fast for single nodes... lix = o.Linkno.VarName; J = o.T( o.IX, 2 ); % go to name node KKK = o.Linkok( lix, o.T( o.IX, 1 ) ) & (J~=0)'; J = J(KKK); o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varType(o) %VARTYPE returns the Type node of a typed variable. % fast for single nodes... lix = o.Linkno.VarType; J = o.T( o.IX, 3 ); % go to ETC node KKK = o.Linkok( lix, o.T( o.IX, 1 ) ) & (J~=0)'; J = J(KKK); J = o.T( J, 2 ); % go to type node J = J(J~=0); o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varDimensions(o) %VARDIMENSIONS returns the Size node of a typed variable. % fast for single nodes... lix = o.Linkno.VarDimensions; J = o.T(o.IX, 3); % go to first ETC KKK = o.Linkok(lix, o.T(o.IX, 1)) & (J ~= 0)'; J = J(KKK); for next = [3 2] % then ETC -> Size J = o.T(J, next); J = J(J ~= 0); end o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varValidators(o) %VARVALIDATOR returns the Validators node of a typed variable. % fast for single nodes... lix = o.Linkno.VarDimensions; J = o.T(o.IX, 3); % go to ETC KKK = o.Linkok(lix, o.T(o.IX, 1)) & (J ~= 0)'; J = J(KKK); for next = [3 3 2] % then ETC -> ETC -> Validators J = o.T(J, next); J = J(J ~= 0); end o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end end methods oo = setter( o ) end methods (Hidden) % Low-level methods that are used for testing or special purposes % and will not be documented. b = sametree( o, oo ) oo = rawset( o ) T = newtree( o, varargin ) s = getpath( o, r ) function o = L(o) %L o = L(o) Raw Left operation % fast for single nodes... J = o.T( o.IX, 2 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = R(o) %R o = R(o) Raw Right operation J = o.T( o.IX, 3 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = P(o) %P o = P(o) Raw Parent operation J = o.T( o.IX, 9 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = X(o) %X o = X(o) Raw Next operation J = o.T( o.IX, 4 ); o.m = o.m - sum( J==0 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; end o = or( o, o2 ) o = and( o, o2 ) o = not( o ) o = minus( o, o2 ) end methods oo = allsetter( o, o2 ) % Deprecated. oo = anysetter( o, o2 ) % Deprecated. disp(o) show(o) dump(o) % Deprecated. dumptree(o) rawdump(o) o = List( o ) o = Full( o ) o = Tree( o ) oo = asgvars( o ) oo = geteq( o ) oo = dominator( o ) ooo = dominates( oo, o ) b = isbop( o ) b = isuop( o ) b = isop( o ) b = isstmt( o ) o = ops( o ) o = bops( o ) o =...

5   Pass
x = 145; y_correct = 0; assert(isequal(armno(x),y_correct))

a = /opt/mlsedu/matlab/R2016b/toolbox/matlab/codetools/@mtree/mtree.m classdef mtree %MTREE Create and manipulate M parse trees % This is an experimental program whose behavior and interface is likely % to change in the future. % Copyright 2006-2016 The MathWorks, Inc. properties (SetAccess='protected', GetAccess='protected', Hidden) T % parse tree array % column 1: kind of node % column 2: index of left child % column 3: index of right child % column 4: index of next node % column 5: position of node % column 6: size of node % column 7: symbol table index (V)R/ % column 8: string table index % column 9: index of parent node % column 10: setting node % column 11: lefttreepos % column 12: righttreepos % column 13: true parent % column 14: righttreeindex % column 15: rightfullindex S % symbol table C % character strings IX % index set (default is true for everything) n % number of nodes m % sum(IX) lnos % line number translation str % input string that created the tree end properties (SetAccess='private', GetAccess='public') % The type of the code file represented by the tree % This will be one of the values of the mtree.Type % enum, such as mtree.Type.ScriptFile, etc. FileType end properties (GetAccess='public', Constant, Hidden) N = mtree_info(1) % node names K = mtree_info(2) % node key KK = mtree_info(3) % the internal names (for debugging) Uop = mtree_info(4) % true if node is a unary op Bop = mtree_info(5) % true if node is a binary op Stmt = mtree_info(6) % true if node is a statement Linkno = mtree_info(7) % maps link to index Lmap = mtree_info(8) % link map Linkok = mtree_info(9) % is link OK for a given node PTval = mtree_info(10) % array of nodes whose V is a position value V = { '2.50', '2.50' }; % version array end methods [v1,v2] = version(o) end methods (Access='protected') % housekeeping methods L = linelookup( o, P ) end methods % CONSTRUCTOR function o = mtree( text, varargin ) %MTREE o = MTREE( text, options ) constructs an mtree object % % Options include: % -file: the text argument is treated as a filename % -comments: comments are included in the tree % -cell: cell markers are included in the tree if nargin == 0 || ~ischar( text ) error(message('MATLAB:mtree:usage')); end opts = {}; for i=1:nargin-1 if strcmp( varargin{i}, '-file' ) try fname = text; text = matlab.internal.getCode(text); catch x error(message('MATLAB:mtree:input', fname)); end else switch varargin{i} case '-comments' opts{end+1} = '-com'; %#ok<AGROW> otherwise opts{end+1} = varargin{i}; %#ok<AGROW> end end end o.str = text; [o.T,o.S,o.C, o.FileType] = mtreemex( text, opts{:} ); % this code needs to be clever about old MAC files L1 = text==char(10); if sum(L1)==0 % there are no newlines in the file L1 = text==char(13); end o.lnos = [ 0 find(L1) length(text) ]'; o = wholetree( o ); end o = wholetree( o ) end methods (Hidden) b = eq( o, oo ) b = ne( o, oo ) b = le( o, oo ) o = subtree(o) % Deprecated. o = fullsubtree( o ) % Deprecated. function o = list(o) %LIST list is deprecated -- use List o = List(o); end function o = full(o) %full full is deprecated -- use wholetree o = wholetree(o); end b = isfull(o) % Deprecated. end methods m = count( o ) oo = root( o ) oo = null( o ) end methods (Access='protected',Hidden) oo = makeAttrib( o, I ) [I,ipath,flag,rest] = pathit( o, I, ipath ) a = restrict( o, ipath, s ) end methods a = path(o, pth ) % Deprecated since it interferes with the builtin. a = mtpath(o, pth ) c = strings( o ) c = stringvals( o ) s = string( o ) s = stringval( o ) a = find( o, varargin ) % Deprecated. a = mtfind( o, varargin ) o = sets( o ) end methods % methods for following paths... o = Left(o) o = Arg(o) o = Try(o) o = Attr(o) o = Right(o) o = Body(o) o = Catch(o) o = CatchID(o) o = Next(o) o = Parent(o) o = Outs(o) o = Index(o) o = Cattr(o) o = Vector(o) o = Cexpr(o) o = Ins(o) o = Fname(o) o = lhs( o ) o = previous( o ) oo = first( o ) o = last( o ) end properties(Dependent) VarName; VarType; VarDimensions; VarValidators; end methods function name = get.VarName(o) name = varName(o); end function type = get.VarType(o) type = varType(o); end function dims = get.VarDimensions(o) dims = varDimensions(o); end function vals = get.VarValidators(o) vals = varValidators(o); end end methods(Access=private, Hidden) function o = varName(o) %VARNAME returns the Name node of a typed variable. % fast for single nodes... lix = o.Linkno.VarName; J = o.T( o.IX, 2 ); % go to name node KKK = o.Linkok( lix, o.T( o.IX, 1 ) ) & (J~=0)'; J = J(KKK); o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varType(o) %VARTYPE returns the Type node of a typed variable. % fast for single nodes... lix = o.Linkno.VarType; J = o.T( o.IX, 3 ); % go to ETC node KKK = o.Linkok( lix, o.T( o.IX, 1 ) ) & (J~=0)'; J = J(KKK); J = o.T( J, 2 ); % go to type node J = J(J~=0); o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varDimensions(o) %VARDIMENSIONS returns the Size node of a typed variable. % fast for single nodes... lix = o.Linkno.VarDimensions; J = o.T(o.IX, 3); % go to first ETC KKK = o.Linkok(lix, o.T(o.IX, 1)) & (J ~= 0)'; J = J(KKK); for next = [3 2] % then ETC -> Size J = o.T(J, next); J = J(J ~= 0); end o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varValidators(o) %VARVALIDATOR returns the Validators node of a typed variable. % fast for single nodes... lix = o.Linkno.VarDimensions; J = o.T(o.IX, 3); % go to ETC KKK = o.Linkok(lix, o.T(o.IX, 1)) & (J ~= 0)'; J = J(KKK); for next = [3 3 2] % then ETC -> ETC -> Validators J = o.T(J, next); J = J(J ~= 0); end o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end end methods oo = setter( o ) end methods (Hidden) % Low-level methods that are used for testing or special purposes % and will not be documented. b = sametree( o, oo ) oo = rawset( o ) T = newtree( o, varargin ) s = getpath( o, r ) function o = L(o) %L o = L(o) Raw Left operation % fast for single nodes... J = o.T( o.IX, 2 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = R(o) %R o = R(o) Raw Right operation J = o.T( o.IX, 3 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = P(o) %P o = P(o) Raw Parent operation J = o.T( o.IX, 9 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = X(o) %X o = X(o) Raw Next operation J = o.T( o.IX, 4 ); o.m = o.m - sum( J==0 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; end o = or( o, o2 ) o = and( o, o2 ) o = not( o ) o = minus( o, o2 ) end methods oo = allsetter( o, o2 ) % Deprecated. oo = anysetter( o, o2 ) % Deprecated. disp(o) show(o) dump(o) % Deprecated. dumptree(o) rawdump(o) o = List( o ) o = Full( o ) o = Tree( o ) oo = asgvars( o ) oo = geteq( o ) oo = dominator( o ) ooo = dominates( oo, o ) b = isbop( o ) b = isuop( o ) b = isop( o ) b = isstmt( o ) o = ops( o ) o = bops( o ) o =...

6   Pass
x = 407; y_correct = 1; assert(isequal(armno(x),y_correct))

a = /opt/mlsedu/matlab/R2016b/toolbox/matlab/codetools/@mtree/mtree.m classdef mtree %MTREE Create and manipulate M parse trees % This is an experimental program whose behavior and interface is likely % to change in the future. % Copyright 2006-2016 The MathWorks, Inc. properties (SetAccess='protected', GetAccess='protected', Hidden) T % parse tree array % column 1: kind of node % column 2: index of left child % column 3: index of right child % column 4: index of next node % column 5: position of node % column 6: size of node % column 7: symbol table index (V)R/ % column 8: string table index % column 9: index of parent node % column 10: setting node % column 11: lefttreepos % column 12: righttreepos % column 13: true parent % column 14: righttreeindex % column 15: rightfullindex S % symbol table C % character strings IX % index set (default is true for everything) n % number of nodes m % sum(IX) lnos % line number translation str % input string that created the tree end properties (SetAccess='private', GetAccess='public') % The type of the code file represented by the tree % This will be one of the values of the mtree.Type % enum, such as mtree.Type.ScriptFile, etc. FileType end properties (GetAccess='public', Constant, Hidden) N = mtree_info(1) % node names K = mtree_info(2) % node key KK = mtree_info(3) % the internal names (for debugging) Uop = mtree_info(4) % true if node is a unary op Bop = mtree_info(5) % true if node is a binary op Stmt = mtree_info(6) % true if node is a statement Linkno = mtree_info(7) % maps link to index Lmap = mtree_info(8) % link map Linkok = mtree_info(9) % is link OK for a given node PTval = mtree_info(10) % array of nodes whose V is a position value V = { '2.50', '2.50' }; % version array end methods [v1,v2] = version(o) end methods (Access='protected') % housekeeping methods L = linelookup( o, P ) end methods % CONSTRUCTOR function o = mtree( text, varargin ) %MTREE o = MTREE( text, options ) constructs an mtree object % % Options include: % -file: the text argument is treated as a filename % -comments: comments are included in the tree % -cell: cell markers are included in the tree if nargin == 0 || ~ischar( text ) error(message('MATLAB:mtree:usage')); end opts = {}; for i=1:nargin-1 if strcmp( varargin{i}, '-file' ) try fname = text; text = matlab.internal.getCode(text); catch x error(message('MATLAB:mtree:input', fname)); end else switch varargin{i} case '-comments' opts{end+1} = '-com'; %#ok<AGROW> otherwise opts{end+1} = varargin{i}; %#ok<AGROW> end end end o.str = text; [o.T,o.S,o.C, o.FileType] = mtreemex( text, opts{:} ); % this code needs to be clever about old MAC files L1 = text==char(10); if sum(L1)==0 % there are no newlines in the file L1 = text==char(13); end o.lnos = [ 0 find(L1) length(text) ]'; o = wholetree( o ); end o = wholetree( o ) end methods (Hidden) b = eq( o, oo ) b = ne( o, oo ) b = le( o, oo ) o = subtree(o) % Deprecated. o = fullsubtree( o ) % Deprecated. function o = list(o) %LIST list is deprecated -- use List o = List(o); end function o = full(o) %full full is deprecated -- use wholetree o = wholetree(o); end b = isfull(o) % Deprecated. end methods m = count( o ) oo = root( o ) oo = null( o ) end methods (Access='protected',Hidden) oo = makeAttrib( o, I ) [I,ipath,flag,rest] = pathit( o, I, ipath ) a = restrict( o, ipath, s ) end methods a = path(o, pth ) % Deprecated since it interferes with the builtin. a = mtpath(o, pth ) c = strings( o ) c = stringvals( o ) s = string( o ) s = stringval( o ) a = find( o, varargin ) % Deprecated. a = mtfind( o, varargin ) o = sets( o ) end methods % methods for following paths... o = Left(o) o = Arg(o) o = Try(o) o = Attr(o) o = Right(o) o = Body(o) o = Catch(o) o = CatchID(o) o = Next(o) o = Parent(o) o = Outs(o) o = Index(o) o = Cattr(o) o = Vector(o) o = Cexpr(o) o = Ins(o) o = Fname(o) o = lhs( o ) o = previous( o ) oo = first( o ) o = last( o ) end properties(Dependent) VarName; VarType; VarDimensions; VarValidators; end methods function name = get.VarName(o) name = varName(o); end function type = get.VarType(o) type = varType(o); end function dims = get.VarDimensions(o) dims = varDimensions(o); end function vals = get.VarValidators(o) vals = varValidators(o); end end methods(Access=private, Hidden) function o = varName(o) %VARNAME returns the Name node of a typed variable. % fast for single nodes... lix = o.Linkno.VarName; J = o.T( o.IX, 2 ); % go to name node KKK = o.Linkok( lix, o.T( o.IX, 1 ) ) & (J~=0)'; J = J(KKK); o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varType(o) %VARTYPE returns the Type node of a typed variable. % fast for single nodes... lix = o.Linkno.VarType; J = o.T( o.IX, 3 ); % go to ETC node KKK = o.Linkok( lix, o.T( o.IX, 1 ) ) & (J~=0)'; J = J(KKK); J = o.T( J, 2 ); % go to type node J = J(J~=0); o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varDimensions(o) %VARDIMENSIONS returns the Size node of a typed variable. % fast for single nodes... lix = o.Linkno.VarDimensions; J = o.T(o.IX, 3); % go to first ETC KKK = o.Linkok(lix, o.T(o.IX, 1)) & (J ~= 0)'; J = J(KKK); for next = [3 2] % then ETC -> Size J = o.T(J, next); J = J(J ~= 0); end o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varValidators(o) %VARVALIDATOR returns the Validators node of a typed variable. % fast for single nodes... lix = o.Linkno.VarDimensions; J = o.T(o.IX, 3); % go to ETC KKK = o.Linkok(lix, o.T(o.IX, 1)) & (J ~= 0)'; J = J(KKK); for next = [3 3 2] % then ETC -> ETC -> Validators J = o.T(J, next); J = J(J ~= 0); end o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end end methods oo = setter( o ) end methods (Hidden) % Low-level methods that are used for testing or special purposes % and will not be documented. b = sametree( o, oo ) oo = rawset( o ) T = newtree( o, varargin ) s = getpath( o, r ) function o = L(o) %L o = L(o) Raw Left operation % fast for single nodes... J = o.T( o.IX, 2 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = R(o) %R o = R(o) Raw Right operation J = o.T( o.IX, 3 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = P(o) %P o = P(o) Raw Parent operation J = o.T( o.IX, 9 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = X(o) %X o = X(o) Raw Next operation J = o.T( o.IX, 4 ); o.m = o.m - sum( J==0 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; end o = or( o, o2 ) o = and( o, o2 ) o = not( o ) o = minus( o, o2 ) end methods oo = allsetter( o, o2 ) % Deprecated. oo = anysetter( o, o2 ) % Deprecated. disp(o) show(o) dump(o) % Deprecated. dumptree(o) rawdump(o) o = List( o ) o = Full( o ) o = Tree( o ) oo = asgvars( o ) oo = geteq( o ) oo = dominator( o ) ooo = dominates( oo, o ) b = isbop( o ) b = isuop( o ) b = isop( o ) b = isstmt( o ) o = ops( o ) o = bops( o ) o =...

7   Pass
x = 136; y_correct = 0; assert(isequal(armno(x),y_correct))

a = /opt/mlsedu/matlab/R2016b/toolbox/matlab/codetools/@mtree/mtree.m classdef mtree %MTREE Create and manipulate M parse trees % This is an experimental program whose behavior and interface is likely % to change in the future. % Copyright 2006-2016 The MathWorks, Inc. properties (SetAccess='protected', GetAccess='protected', Hidden) T % parse tree array % column 1: kind of node % column 2: index of left child % column 3: index of right child % column 4: index of next node % column 5: position of node % column 6: size of node % column 7: symbol table index (V)R/ % column 8: string table index % column 9: index of parent node % column 10: setting node % column 11: lefttreepos % column 12: righttreepos % column 13: true parent % column 14: righttreeindex % column 15: rightfullindex S % symbol table C % character strings IX % index set (default is true for everything) n % number of nodes m % sum(IX) lnos % line number translation str % input string that created the tree end properties (SetAccess='private', GetAccess='public') % The type of the code file represented by the tree % This will be one of the values of the mtree.Type % enum, such as mtree.Type.ScriptFile, etc. FileType end properties (GetAccess='public', Constant, Hidden) N = mtree_info(1) % node names K = mtree_info(2) % node key KK = mtree_info(3) % the internal names (for debugging) Uop = mtree_info(4) % true if node is a unary op Bop = mtree_info(5) % true if node is a binary op Stmt = mtree_info(6) % true if node is a statement Linkno = mtree_info(7) % maps link to index Lmap = mtree_info(8) % link map Linkok = mtree_info(9) % is link OK for a given node PTval = mtree_info(10) % array of nodes whose V is a position value V = { '2.50', '2.50' }; % version array end methods [v1,v2] = version(o) end methods (Access='protected') % housekeeping methods L = linelookup( o, P ) end methods % CONSTRUCTOR function o = mtree( text, varargin ) %MTREE o = MTREE( text, options ) constructs an mtree object % % Options include: % -file: the text argument is treated as a filename % -comments: comments are included in the tree % -cell: cell markers are included in the tree if nargin == 0 || ~ischar( text ) error(message('MATLAB:mtree:usage')); end opts = {}; for i=1:nargin-1 if strcmp( varargin{i}, '-file' ) try fname = text; text = matlab.internal.getCode(text); catch x error(message('MATLAB:mtree:input', fname)); end else switch varargin{i} case '-comments' opts{end+1} = '-com'; %#ok<AGROW> otherwise opts{end+1} = varargin{i}; %#ok<AGROW> end end end o.str = text; [o.T,o.S,o.C, o.FileType] = mtreemex( text, opts{:} ); % this code needs to be clever about old MAC files L1 = text==char(10); if sum(L1)==0 % there are no newlines in the file L1 = text==char(13); end o.lnos = [ 0 find(L1) length(text) ]'; o = wholetree( o ); end o = wholetree( o ) end methods (Hidden) b = eq( o, oo ) b = ne( o, oo ) b = le( o, oo ) o = subtree(o) % Deprecated. o = fullsubtree( o ) % Deprecated. function o = list(o) %LIST list is deprecated -- use List o = List(o); end function o = full(o) %full full is deprecated -- use wholetree o = wholetree(o); end b = isfull(o) % Deprecated. end methods m = count( o ) oo = root( o ) oo = null( o ) end methods (Access='protected',Hidden) oo = makeAttrib( o, I ) [I,ipath,flag,rest] = pathit( o, I, ipath ) a = restrict( o, ipath, s ) end methods a = path(o, pth ) % Deprecated since it interferes with the builtin. a = mtpath(o, pth ) c = strings( o ) c = stringvals( o ) s = string( o ) s = stringval( o ) a = find( o, varargin ) % Deprecated. a = mtfind( o, varargin ) o = sets( o ) end methods % methods for following paths... o = Left(o) o = Arg(o) o = Try(o) o = Attr(o) o = Right(o) o = Body(o) o = Catch(o) o = CatchID(o) o = Next(o) o = Parent(o) o = Outs(o) o = Index(o) o = Cattr(o) o = Vector(o) o = Cexpr(o) o = Ins(o) o = Fname(o) o = lhs( o ) o = previous( o ) oo = first( o ) o = last( o ) end properties(Dependent) VarName; VarType; VarDimensions; VarValidators; end methods function name = get.VarName(o) name = varName(o); end function type = get.VarType(o) type = varType(o); end function dims = get.VarDimensions(o) dims = varDimensions(o); end function vals = get.VarValidators(o) vals = varValidators(o); end end methods(Access=private, Hidden) function o = varName(o) %VARNAME returns the Name node of a typed variable. % fast for single nodes... lix = o.Linkno.VarName; J = o.T( o.IX, 2 ); % go to name node KKK = o.Linkok( lix, o.T( o.IX, 1 ) ) & (J~=0)'; J = J(KKK); o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varType(o) %VARTYPE returns the Type node of a typed variable. % fast for single nodes... lix = o.Linkno.VarType; J = o.T( o.IX, 3 ); % go to ETC node KKK = o.Linkok( lix, o.T( o.IX, 1 ) ) & (J~=0)'; J = J(KKK); J = o.T( J, 2 ); % go to type node J = J(J~=0); o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varDimensions(o) %VARDIMENSIONS returns the Size node of a typed variable. % fast for single nodes... lix = o.Linkno.VarDimensions; J = o.T(o.IX, 3); % go to first ETC KKK = o.Linkok(lix, o.T(o.IX, 1)) & (J ~= 0)'; J = J(KKK); for next = [3 2] % then ETC -> Size J = o.T(J, next); J = J(J ~= 0); end o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end function o = varValidators(o) %VARVALIDATOR returns the Validators node of a typed variable. % fast for single nodes... lix = o.Linkno.VarDimensions; J = o.T(o.IX, 3); % go to ETC KKK = o.Linkok(lix, o.T(o.IX, 1)) & (J ~= 0)'; J = J(KKK); for next = [3 3 2] % then ETC -> ETC -> Validators J = o.T(J, next); J = J(J ~= 0); end o.IX(o.IX) = false; % reset o.IX(J)= true; o.m = length(J); end end methods oo = setter( o ) end methods (Hidden) % Low-level methods that are used for testing or special purposes % and will not be documented. b = sametree( o, oo ) oo = rawset( o ) T = newtree( o, varargin ) s = getpath( o, r ) function o = L(o) %L o = L(o) Raw Left operation % fast for single nodes... J = o.T( o.IX, 2 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = R(o) %R o = R(o) Raw Right operation J = o.T( o.IX, 3 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = P(o) %P o = P(o) Raw Parent operation J = o.T( o.IX, 9 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; o.m = length(J); end function o = X(o) %X o = X(o) Raw Next operation J = o.T( o.IX, 4 ); o.m = o.m - sum( J==0 ); J = J(J~=0); o.IX(o.IX) = false; o.IX(J)= true; end o = or( o, o2 ) o = and( o, o2 ) o = not( o ) o = minus( o, o2 ) end methods oo = allsetter( o, o2 ) % Deprecated. oo = anysetter( o, o2 ) % Deprecated. disp(o) show(o) dump(o) % Deprecated. dumptree(o) rawdump(o) o = List( o ) o = Full( o ) o = Tree( o ) oo = asgvars( o ) oo = geteq( o ) oo = dominator( o ) ooo = dominates( oo, o ) b = isbop( o ) b = isuop( o ) b = isop( o ) b = isstmt( o ) o = ops( o ) o = bops( o ) o =...