structure[$attributes->path]["Elements"]; for($element=0;$element<$elements;$element++) { $element_path=$attributes->path.",$element"; $data=$code->structure[$element_path]; if(GetType($data)=="array") { switch($data["Tag"]) { case "FUNCTION": Unset($name); $function=array(); $function_elements=$code->structure[$element_path]["Elements"]; for($function_element=0;$function_element<$function_elements;$function_element++) { $function_element_path=$element_path.",$function_element"; $data=$code->structure[$function_element_path]; if(GetType($data)=="array") { switch($data["Tag"]) { case "NAME": if(IsSet($name)) { $compiler->SetElementError($attributes->file,$function_element_path,"it was defined the CLASS FUNCTION NAME more than once"); return(0); } if(!$compiler->GetValidData($attributes->file,$function_element_path,&$name,"it was not specified a valid CLASS FUNCTION NAME option")) return(0); if(IsSet($this->functions[$name])) { $compiler->SetElementError($attributes->file,$function_element_path,"it was specified a NAME of an already defined CLASS FUNCTION"); return(0); } break; case "TYPE": if(IsSet($function["TYPE"])) { $compiler->SetElementError($attributes->file,$function_element_path,"it was defined the CLASS FUNCTION TYPE more than once"); return(0); } if(!$compiler->GetValidData($attributes->file,$function_element_path,&$function["TYPE"],"it was not specified a valid CLASS FUNCTION TYPE option")) return(0); break; case "DO": if(IsSet($function["DO"])) { $compiler->SetElementError($attributes->file,$function_element_path,"it was defined the CLASS FUNCTION DO statements more than once"); return(0); } $function["DO"]=array( "file"=>$attributes->file, "path"=>$function_element_path ); break; default: $compiler->SetElementError($attributes->file,$function_element_path,$data["Tag"]." is not a supported CLASS object attribute"); return(0); } } else { if(!$compiler->CheckWhiteSpace($attributes->file,$data,$function_element_path)) return(0); } } if(!IsSet($name)) { $compiler->SetElementError($attributes->file,$attributes->path,"it was not defined the CLASS FUNCTION NAME"); return(0); } if(!IsSet($function["TYPE"])) { $compiler->SetElementError($attributes->file,$attributes->path,"it was not defined the CLASS FUNCTION return TYPE"); return(0); } if(!IsSet($function["DO"])) { $compiler->SetElementError($attributes->file,$attributes->path,"it was not defined the CLASS FUNCTION DO statmemnts"); return(0); } $file=$function["DO"]["file"]; $path=$function["DO"]["path"]; $function["DO"]=array(); $this->functions[$name]=$function; if(!$compiler->GetOutputData($file,$path,&$this->functions[$name]["DO"],"it were not defined valid CLASS FUNCTION DO statements",1)) return(0); break; default: $compiler->SetElementError($attributes->file,$element_path,$data["Tag"]." is not a supported CLASS object attribute"); return(0); } } else { if(!$compiler->CheckWhiteSpace($attributes->file,$data,$element_path)) return(0); } } return(1); } Function Call(&$compiler,&$code,&$context,&$call) { $elements=$code->structure[$context->path]["Elements"]; for($element=0;$element<$elements;$element++) { $element_path=$context->path.",$element"; $data=$code->structure[$element_path]; if(GetType($data)=="array") { switch($data["Tag"]) { case "FUNCTION": case "OBJECT": $argument=$data["Tag"]; if(IsSet($call[$argument])) { $compiler->SetElementError($context->file,$element_path,"it was specified the CLASS CALL $argument argument"); return(0); } switch($argument) { case "FUNCTION": if(!$compiler->GetValidData($context->file,$element_path,&$call["FUNCTION"],"it was not specified a valid CLASS CALL FUNCTION argument")) return(0); if(!IsSet($this->functions[$call["FUNCTION"]])) { $compiler->SetElementError($context->file,$element_path,"it was requested to CALL a CLASS FUNCTION that was not defined"); return(0); } break; case "OBJECT": $evaluate_context=$context; $evaluate_context->path=$element_path; if(!$compiler->GetValidExpression(&$evaluate_context,"OBJECT","ANY","it was not specified a valid CLASS OBJECT expression",1) || !$compiler->GetExpressionValue(&$context,&$evaluate_context->result,&$call["OBJECT"])) return(0); break; } break; default: $compiler->SetElementError($context->file,$element_path,$data["Tag"]." is not a supported CLASS CALL argument"); return(0); } } else { if(!$compiler->CheckWhiteSpace($context->file,$data,$element_path)) return(0); } } return(1); } Function Execute(&$compiler,&$code,$function,&$context,&$arguments_code,&$arguments) { if(strcmp($compiler->language["NAME"],"PHP")) { $compiler->SetElementError($context->file,$context->path,$compiler->language["NAME"]." is not a language supported by the CLASS class"); return(0); } switch($function) { case "NEW": $context->result[]=array( "Data"=>$this->object_name, "Type"=>"INITIALIZATION" ); $context->result[]=array( "Data"=>array( "Value"=>"new ".$this->object_name, "Type"=>"OBJECT", "Class"=>$this->object_name, "Side"=>"RIGHT" ), "Type"=>"EXPRESSION" ); break; case "CALL": $call=array(); if(!$this->Call(&$compiler,&$arguments_code,&$arguments,&$call) || !$this->Call(&$compiler,&$code,&$context,&$call)) return(0); if(!IsSet($call[$argument="OBJECT"]) || !IsSet($call[$argument="FUNCTION"])) { $compiler->SetElementError($context->file,$context->path,"it was not defined the CLASS CALL $argument argument"); return(0); } $statement=$call["OBJECT"]."->".$call["FUNCTION"]."()"; if(strcmp($this->functions[$call["FUNCTION"]]["TYPE"],"VOID")) { $context->result[]=array( "Data"=>array( "Value"=>$statement, "Type"=>"ANY", "Side"=>"RIGHT" ), "Type"=>"EXPRESSION" ); } else { $context->result[]=array( "Data"=>$statement.";", "Type"=>"COMMAND" ); } break; default: $compiler->SetElementError($context->file,$context->path,$function." is not a supported CLASS object function"); return(0); } return(1); } Function Initialization(&$compiler,&$context) { if(strcmp($compiler->language["NAME"],"PHP")) { $compiler->SetElementError($context->file,$context->path,$compiler->language["NAME"]." is not a language supported by the CLASS class"); return(0); } $result=array(); $result[]=array( "Data"=>"", "Type"=>"COMMAND" ); $result[]=array( "Data"=>"class ".$this->object_name, "Type"=>"COMMAND" ); $result[]=array( "Data"=>"{", "Type"=>"COMMAND" ); $result[]=array( "Data"=>1, "Type"=>"INDENT" ); for(Reset($this->functions),$function=0;$functionfunctions);$function++,Next($this->functions)) { $name=Key($this->functions); $result[]=array( "Data"=>"Function $name()", "Type"=>"COMMAND" ); $result[]=array( "Data"=>"{", "Type"=>"COMMAND" ); $result[]=array( "Data"=>1, "Type"=>"INDENT" ); for($part=0;$partfunctions[$name]["DO"]);$part++) { if(strcmp($this->functions[$name]["DO"][$part]["Type"],"INITIALIZATION")) $result[]=$this->functions[$name]["DO"][$part]; else $context->result[]=$this->functions[$name]["DO"][$part]; } $result[]=array( "Data"=>1, "Type"=>"OUTDENT" ); $result[]=array( "Data"=>"}", "Type"=>"COMMAND" ); } $result[]=array( "Data"=>1, "Type"=>"OUTDENT" ); $result[]=array( "Data"=>"};", "Type"=>"COMMAND" ); $result[]=array( "Data"=>"", "Type"=>"COMMAND" ); for($part=0;$partresult[]=$result[$part]; return(1); } }; } ?>