Esempio n. 1
0
char *SourceName()
{
 int i;
 char *RetS;
 char *Env = Environment();

 do Env++; while ((Env[-1] != 0) || (Env[0] != 0));
 do Env++; while (Env[0] != 0);
 Env++;
 i = strlen(Env);
 RetS = malloc(i);
 if (RetS) strcpy(RetS, Env);
 return RetS;
}
Esempio n. 2
0
void MakeBuild::SetHdependDirs()
{
	Vector<String> include = SplitDirs(GetVar("UPP") + ';'
		+ GetMethodVars(method).Get("INCLUDE", "") + ';'
		+ Environment().Get("INCLUDE", "")
#ifdef PLATFORM_POSIX
		+ ";/usr/include;/usr/local/include;"
#endif
		+ add_includes
		);
	// Also adding internal includes
	const Workspace& wspc = GetIdeWorkspace();
	for(int i = 0; i < wspc.GetCount(); i++) {
		const Package& pkg = wspc.GetPackage(i);
		for(int j = 0; j < pkg.include.GetCount(); j++)
			include.Add(SourcePath(wspc[i], pkg.include[j].text));
	}

	HdependSetDirs(include);
}
Esempio n. 3
0
char *SourcePath()
{
 int i;
 char *RetS;
 char *Env = Environment();

 do Env++; while ((Env[-1] != 0) || (Env[0] != 0));
 do Env++; while (Env[0] != 0);

 Env++; RetS = Env + strlen(Env);
 while ((RetS > Env) && (strlast(RetS[-1], PATHSEP) < 0)) RetS--;

 i = RetS - Env;
 RetS = malloc(i + 1);
 if (RetS)
 {
  strncpy(RetS, Env, i);
  RetS[i] = 0;
 }
 return RetS;
}
Esempio n. 4
0
UBOOL CompileShader(
	const TCHAR* ShaderFilename,
	const TCHAR* FunctionName,
	FShaderTarget Target,
	const FShaderCompilerEnvironment& InEnvironment,
	FShaderCompilerOutput& OutData,
	UBOOL bDebugDump
	)
{
	UBOOL bResult = FALSE;
	FShaderCompilerEnvironment Environment(InEnvironment);
	Environment.Definitions[TEXT("VERTEXSHADER")] = (Target.Frequency == SF_Vertex ? TEXT("1") : TEXT("0"));
	Environment.Definitions[TEXT("PIXELSHADER")]  = (Target.Frequency == SF_Pixel ? TEXT("1") : TEXT("0"));

	if( Target.Platform == SP_SM3 || Target.Platform == SP_SM2 )
	{
		bResult = D3D9CompileShader(ShaderFilename, FunctionName, Target, Environment, OutData, bDebugDump);
	}

	return bResult;
}
Esempio n. 5
0
One<Host> MakeBuild::CreateHost(bool sync_files)
{
	SetupDefaultMethod();
	VectorMap<String, String> bm = GetMethodVars(method);
	One<Host> outhost;
	{
		One<LocalHost> host = new LocalHost;
		VectorMap<String, String> env(Environment(), 1);
		host->exedirs = SplitDirs(bm.Get("PATH", "") + ';' + env.Get("PATH", ""));
		env.GetAdd("PATH") = Join(host->exedirs, ";");
		env.GetAdd("UPP_MAIN__") = GetFileDirectory(PackagePath(GetMain()));
		env.GetAdd("UPP_ASSEMBLY__") = GetVar("UPP");
		for(int i = 0; i < env.GetCount(); i++) {
			LDUMP(env.GetKey(i));
			LDUMP(env[i]);
			host->environment << env.GetKey(i) << '=' << env[i] << '\0';
		}
		host->environment.Cat(0);
		host->cmdout = &cmdout;
		outhost = -host;
	}
	return outhost;
}
Esempio n. 6
0
void IGame_Persistent::OnFrame		()
{

#ifndef DEDICATED_SERVER
	if(!Device.Paused() || Device.dwPrecacheFrame)
		Environment().OnFrame				();
#endif

#ifndef _EDITOR

	Device.Statistic->Particles_starting= ps_needtoplay.size	();
	Device.Statistic->Particles_active	= ps_active.size		();
	Device.Statistic->Particles_destroy	= ps_destroy.size		();

	// Play req particle systems
	while (ps_needtoplay.size())
	{
		CPS_Instance*	psi		= ps_needtoplay.back	();
		ps_needtoplay.pop_back	();
		psi->Play				();
	}
	// Destroy inactive particle systems
	while (ps_destroy.size())
	{
//		u32 cnt					= ps_destroy.size();
		CPS_Instance*	psi		= ps_destroy.back();
		VERIFY					(psi);
		if (psi->Locked())
		{
			Log("--locked");
			break;
		}
		ps_destroy.pop_back		();
		psi->PSI_internal_delete();
	}
#endif
}
// -----------------------------------------------------------------------------
// CTFTestCaseRepeater::Log
// -----------------------------------------------------------------------------
void CTFTestCaseRepeater::Log( TInt aDepth )
    {
    _LIT ( KCaseDesc, "Case %d: %S" );
    Environment().Logger().WriteList( aDepth, KCaseDesc, Id(), &Name() );
    }
Esempio n. 8
0
ConfigScanner::ConfigScanner() {
	enviro = Environment();
	numOfSteps = 0;
	useStatefileSetup = false;
	useZMatrixSetup = false;
}
Esempio n. 9
0
File: main.cpp Progetto: alobo/ev
#include <fstream>
#include <algorithm>
#include <SFML/Graphics.hpp>
#include "Physics/Environment.h"
#include "AI/Creature.h"
#include "AI/Food.h"
#include "AI/Mutator.h"

const int WIDTH = 1600;
const int HEIGHT = 1200;
const int NUM_CREATURES = 25;
const int NUM_FOOD = 100;
const int GENERATION_LENGTH_SECONDS = 15;

int gen_count = 0;
Environment env = Environment(WIDTH, HEIGHT, 0.5);
Creature creatures [NUM_CREATURES];
std::vector<Food> food;

/**
* Provide an interactive console
*/
void launchConsole() {
    std::cout << "Commands" << std::endl;
    std::cout << "\tr:\tResume Simulation" << std::endl;
    for (std::string line; line != "r"; std::getline(std::cin, line)) {
        int index = 0;
        switch (line[0]) {
            case 'c':
                index = (int) (line[2] - '0');
                std::cout << creatures[index].getNeuralNetwork() << std::endl;
Esempio n. 10
0
bool ConfigScanner::readInConfig(string configpath) {
    isSafeToContinue = true;
    enviro = Environment();
    numOfSteps = 0;

    configPath = configpath;
    if (configPath.empty()) {
        std::cerr << "Configuration File path is empty" << std::endl;
        return false;
    }

    ifstream configscanner(configPath.c_str());
    if (!configscanner.is_open()) {
        std::cerr << "Unable to open configuration file (" << configPath << ")"
                  << std::endl;
        return false;
    }
    string line;

    while (configscanner.good()) {
        getline(configscanner, line);
        trim(line);

        // Ignore blank lines and comments
        if (line.empty() || line[0] == '#' || line[0] == ';') {
            continue;
        }

        // Sections are supported, but don't have any additional functionality
        if (line[0] == '[' && line.find(']') == line.length()) {
            continue;
        }

        int splitPos = line.find('=');
        if (splitPos == -1) {
            throwScanError("Error: Configuration File not well formed.\n"
                           "Offending line: \"" + line + "\"");
            return false;
        }
        string key = line.substr(0, splitPos);
        string value = line.substr(splitPos+1, line.length());

        // Assign attributes based on key
        if (key == "x") {
            if (value.length() > 0) {
                enviro.x = atof(value.c_str());
            } else {
                throwScanError("Error: Config File: Missing environment X value.");
                return false;
            }
        } else if (key == "y") {
            if (value.length() > 0) {
                enviro.y = atof(value.c_str());
            } else {
                throwScanError("Error: Config File: Missing environment Y value.");
                return false;
            }
        } else if (key == "z") {
            if (value.length() > 0) {
                enviro.z = atof(value.c_str());
            } else {
                throwScanError("Configuration file not well formed. Missing environment z value.");
                return false;
            }
        } else if (key == "temp") {
            if (value.length() > 0) {
                enviro.temp = atof(value.c_str());
            } else {
                throwScanError("Configuration file not well formed. Missing environment temperature value.");
                return false;
            }
        } else if (key == "max-translation") {
            if (value.length() > 0) {
                enviro.maxTranslation = atof(value.c_str());
            } else {
                throwScanError("Configuration file not well formed. Missing environment max translation value.");
                return false;
            }
        } else if (key == "steps") {
            if (value.length() > 0) {
                numOfSteps = atoi(value.c_str());
            } else {
                throwScanError("Configuration file not well formed. Missing number of steps value.");
                return false;
            }
        } else if (key == "molecules") {
            if (value.length() > 0) {
                enviro.numOfMolecules = atoi(value.c_str());
            } else {
                throwScanError("Configuration file not well formed. Missing number of molecules value.");
                return false;
            }
        } else if (key == "opla.par") {
            if (value.length() > 0) {
                oplsuaparPath = value;
            } else {
                throwScanError("Configuration file not well formed. Missing oplsuapar path value.");
                return false;
            }
        } else if (key == "z-matrix") {
            if (value.length() > 0) {
                zmatrixPath = value;
                useZMatrixSetup = true;
                useStatefileSetup = true;
            } else {
                throwScanError("INFO: Configuration file not well formed. Missing z-matrix path value. Attempting to rely on prior state information...");
                isSafeToContinue = false; //now that it is false, check if there is a state file
                useZMatrixSetup = false;
                useStatefileSetup = true;
            }
        } else if (key == "state-input") {
            if (value.length() > 0) {
                statePath = value;
                useZMatrixSetup = false; //we will go ahead and use the statefile, since the path was provided
                useStatefileSetup = true;
            } else if (isSafeToContinue == false) { // If no z matrix was provided, and no state file, there is a problem.
                throwScanError("Configuration file not well formed. Missing value pointing to prior state file path. Cannot safely continue with program execution.");
                useStatefileSetup = false; //we can't even hope to find the state file, so don't use it
                useZMatrixSetup = false;
                return false; //preferable to simply exiting, as we want to give the program a chance to do...whatever?
            } else { // If we don't have a state file, but do have a z-matrix, use the z-matrix.
                throwScanError("INFO: Value pointing to prior state file path not found in main config file. Environment setup defaulting to clean simulation.");
                useZMatrixSetup = true; //revert to using the Zmatrix file for all setup
                useStatefileSetup = false;
                isSafeToContinue = true;
            }
        } else if (key == "state-output") {
            if (value.length() > 0) {
                stateOutputPath = value;
            } else {
                throwScanError("Configuration file not well formed. Missing state file output path value.");
                return false;
            }
        } else if (key == "pdb-output") {
            if (value.length() > 0) {
                pdbOutputPath = value;
            } else {
                throwScanError("Configuration file not well formed. Missing PDB output path value.");
                return false;
            }
        } else if (key == "cutoff") {
            if (value.length() > 0) {
                enviro.cutoff = atof(value.c_str());
            } else {
                throwScanError("Configuration file not well formed. Missing environment cutoff value.");
                return false;
            }
        } else if (key == "max-rotation") {
            if (value.length() > 0) {
                enviro.maxRotation = atof(value.c_str());
            } else {
                throwScanError("Configuration file not well formed. Missing environment max rotation value.");
                return false;
            }
        } else if (key == "random-seed") {
            if (value.length() > 0) {
                enviro.randomseed=atoi(value.c_str());
            } else {
                enviro.randomseed = (unsigned int) time(NULL);
            }
        } else if (key == "primary-atom") {
            if (value.length() > 0) {
                // Convert to a zero-based index
                parsePrimaryIndexDefinitions(value);
            } else {
                throwScanError("Configuration file not well formed. Missing "
                               "environment primary atom index value.");
                return false;
            }
        } else if (key == "sim-name") {
            if (value.length() > 0) {
                simName = value;
            }
        } else if (key == "strategy") {
            if (value.length() > 0) {
                strategy = value;
            }
        } else if (key == "max-bond-delta") {
            enviro.maxBondDelta = atof(value.c_str());
        } else if (key == "max-angle-delta") {
            enviro.maxAngleDelta = atof(value.c_str());
        } else {
            throwScanError("Unexpected key encountered: " + key);
            return false;
        }
    }
    configscanner.close();
    return true;
}
int main(int argc, char *argv[])
{                        
    void usage(void);
#ifdef _DEBUG
	ofstream sampf("samp.dat");
	ofstream resf("res.dat");
#endif
	long num;
	long loops=12;
	long i;
	double snr=11.0;
	long paths=3;

	if (argc<4) {
	  num = 100000;
	} else if (argc!=4) {
	  usage();
	} else {
	  num = ((long)atof(argv[1]));       // Number of symbols simulated 
	  snr = atof(argv[2]);               // SNR dBs
	  paths = ((long)atof(argv[3]));     // Number of multipath paths
	}

	baud_eq_env Environment(paths);
	long rcv_symbols=0;
	long symbols=0;
	Environment.num = num;

	time_t current_time;
	time(&current_time);
	noise random_offset;
	random_offset.set_seed((double)(current_time*10));

	// MAIN LOOP
	for (i=0;i<loops;i++) {
	  snr -= 1;
	  Environment.snr = snr;
	  Environment.loop_init();
	  symbols = 0;

	  do {
		Environment.step();
#ifdef _SDEBUG
		sampf.width(4);
		sampf.setf(ios::fixed);
		sampf << Environment.base.re << ' ';
#endif
		// Get data output from Chip
		Environment.BER_mon->synchronize(&symbols,Environment.data);
		// Correlate with reference PN
		if (Environment.BER_mon->found_sync()) Environment.BER_mon->ber_results(symbols++); 
		else symbols++;
		if (Environment.rcv_symbols > num && !Environment.BER_mon->found_sync()) break;
#ifdef _SDEBUG
		sampf << Environment.data << '\n';
#endif
	  } while (symbols < num);

	  cout << " SNR = " << snr << " BER = " << Environment.BER_mon->ber(symbols) << '\n';
	  resf << snr << " " <<  Environment.BER_mon->ber(symbols) << '\n';
	  Environment.BER_mon->final_results(symbols);
	  Environment.loop_end();
	}
#ifdef _DEBUG
	sampf.close();
	resf.close();
#endif
	return(1);
}                                      
int main(int argc, char *argv[])
{                        
    void usage(void);
#ifdef _DEBUG
	ofstream sampf("samp.dat");
	ofstream resf("res.dat");
#endif
	long num;
	double snr=9.0;
	double timing_offset=0.0;

	if (argc<3) {
	  num = 600;
	} else if (argc!=3) {
	  usage();
	} else {
	  num = ((long)atof(argv[1]));       // Number of symbols simulated 
	  snr = atof(argv[2]);   // Unfiltered noise std dev	
	}

	double actual_over=4.00;
	sim_equalizer Environment(4,3);
	long rcv_symbols=0;
	long symbols=0;

	Environment.num = num;
	Environment.snr = snr;

	time_t current_time;
	time(&current_time);
	noise random_offset;
	random_offset.set_seed((double)(current_time*10));

	Environment.loop_init();
//	Environment.BER_mon->init_delay(68); // makes correlation occur earlier
	symbols = 0;

	// MAIN LOOP
	do {
	  Environment.step();
#ifdef _DEBUG
	  sampf.width(4);
	  sampf.setf(ios::fixed);
	  sampf << Environment.base.re << " ";
	  sampf << Environment.base.im << '\n';
#endif

//	  if (Environment.DUT->symclk()==1) {
		if (Environment.rcv_symbols > WAITSYMBOLS )  {                    
		  // Get data output from Chip
		  Environment.BER_mon->synchronize(&symbols,Environment.data);
		  // Correlate with reference PN
		  if (Environment.BER_mon->found_sync()) Environment.BER_mon->ber_results(symbols++); 
		  else symbols++;
		}
//	  }  				 
	  if (Environment.rcv_symbols > num && !Environment.BER_mon->found_sync()) break;
	} while (symbols < num);

	Environment.BER_mon->final_results(symbols);
	Environment.loop_end();

#ifdef _DEBUG
	sampf.close();
	resf.close();
#endif
	return(1);
}                                      
Esempio n. 13
0
/////////////////////////////////////////////////////////////////////////////////////
// gets base path of user data
String GetPdfBasePath(void)
{
	return "/home/" + Environment().Get("USER") + "/.MaxPdf/";

} // END GetPdfBasePath()
Esempio n. 14
0
void IGame_Persistent::OnAppStart	()
{
	if(!g_dedicated_server)
		Environment().load				();
}
Esempio n. 15
0
QnxDeviceProcess::QnxDeviceProcess(const QSharedPointer<const IDevice> &device, QObject *parent)
    : SshDeviceProcess(device, parent)
{
    setEnvironment(Environment(OsTypeLinux));
    m_pidFile = QString::fromLatin1("/var/run/qtc.%1.pid").arg(++pidFileCounter);
}
Esempio n. 16
0
bool ConfigScanner::readInConfig(string configpath) {
	isSafeToContinue = true;
	enviro = Environment();
	numOfSteps = 0;

	configPath = configpath;
	if (configPath.empty()) {
		std::cerr << "Configuration File path is empty" << std::endl;
		return false;
	}

  ifstream configscanner(configPath.c_str());
  if (!configscanner.is_open()) {
    std::cerr << "Unable to open configuration file (" << configPath << ")"
              << std::endl;
    return false;
  } else {
    string line;
    int currentLine = 1;

    while (configscanner.good()) {
      getline(configscanner,line);
			trim(line);
      //assigns attributes based on line number
      switch(currentLine) {
        case 2:     // read in x size of environment
					if (line.length() > 0) {
						enviro.x = atof(line.c_str());
          } else {
						throwScanError("Error: Config File: Missing environment X value.");
						return false;
					}
          break;
        case 3:     // read in y size of environment
					if (line.length() > 0) {
						enviro.y = atof(line.c_str());
          } else {
						throwScanError("Error: Config File: Missing environment Y value.");
						return false;
					}
          break;
        case 4:     // read in z size of environment
					if (line.length() > 0) {
						enviro.z = atof(line.c_str());
          } else {
						throwScanError("Configuration file not well formed. Missing environment z value.");
						return false;
					}
          break;
        case 6:     // read in the temperature of the environment
					if (line.length() > 0) {
						enviro.temp = atof(line.c_str());
          } else {
						throwScanError("Configuration file not well formed. Missing environment temperature value.");
						return false;
					}
          break;
        case 8:     // read in the maximum translation an atom can have.
					if (line.length() > 0) {
						enviro.maxTranslation = atof(line.c_str());
          } else {
						throwScanError("Configuration file not well formed. Missing environment max translation value.");
						return false;
					}
          break;
        case 10:    // read in the number of steps to perform.
					if (line.length() > 0) {
						numOfSteps = atoi(line.c_str());
          } else {
						throwScanError("Configuration file not well formed. Missing number of steps value.");
						return false;
					}
          break;
        case 12:    // read in the number of molecules.
					if (line.length() > 0) {
						enviro.numOfMolecules = atoi(line.c_str());
          } else {
						throwScanError("Configuration file not well formed. Missing number of molecules value.");
						return false;
					}
          break;
        case 14:    // read in the oplsua.par path.
					if (line.length() > 0) {
						oplsuaparPath = line;
          }	else {
						throwScanError("Configuration file not well formed. Missing oplsuapar path value.");
						return false;
					}
          break;
        case 16:    // read in the z matrix path.
					if (line.length() > 0) {
						zmatrixPath = line;
						useZMatrixSetup = true;
						useStatefileSetup = true;
					} else {
						throwScanError("INFO: Configuration file not well formed. Missing z-matrix path value. Attempting to rely on prior state information...");
						isSafeToContinue = false; //now that it is false, check if there is a state file
						useZMatrixSetup = false;
						useStatefileSetup = true;
					}
					break;
        case 18:  // read in the state file path.
          if (line.length() > 0) {
            statePath = line;
            useZMatrixSetup = false; //we will go ahead and use the statefile, since the path was provided
            useStatefileSetup = true;
          } else if (isSafeToContinue == false) { // If no z matrix was provided, and no state file, there is a problem.
						throwScanError("Configuration file not well formed. Missing value pointing to prior state file path. Cannot safely continue with program execution.");
						useStatefileSetup = false; //we can't even hope to find the state file, so don't use it
						useZMatrixSetup = false;
						return false; //preferable to simply exiting, as we want to give the program a chance to do...whatever?
					} else { // If we don't have a state file, but do have a z-matrix, use the z-matrix.
						throwScanError("INFO: Value pointing to prior state file path not found in main config file. Environment setup defaulting to clean simulation.");
						useZMatrixSetup = true; //revert to using the Zmatrix file for all setup
						useStatefileSetup = false;
						isSafeToContinue = true;
					}
					break;
        case 20:    // read in the path to output state files to.
          if (line.length() > 0) {
            stateOutputPath = line;
          } else {
						throwScanError("Configuration file not well formed. Missing state file output path value.");
						return false;
					}
          break;
        case 22:    // read in the path to output pdb files to.
          if (line.length() > 0) {
            pdbOutputPath = line;
          } else {
						throwScanError("Configuration file not well formed. Missing PDB output path value.");
						return false;
					}
          break;
        case 24:    // read in the energy calculation cutoff value.
					if (line.length() > 0) {
						enviro.cutoff = atof(line.c_str());
          } else {
						throwScanError("Configuration file not well formed. Missing environment cutoff value.");
						return false;
					}
          break;
        case 26:  // read in the max rotation value.
					if (line.length() > 0) {
				    enviro.maxRotation = atof(line.c_str());
          } else {
						throwScanError("Configuration file not well formed. Missing environment max rotation value.");
						return false;
					}
          break;
        case 28:    // read in the random seed.
          if (line.length() > 0) {
						enviro.randomseed=atoi(line.c_str());
          } else {
						enviro.randomseed = (unsigned int) time(NULL);
						//throwScanError("Configuration file not well formed. Missing random seed value.");
						//return false;
					}
          break;
        case 30:  // Get the primary atom index definitions.
          if (line.length() > 0) {
						// Convert to a zero-based index
						parsePrimaryIndexDefinitions(line);
          } else {
						throwScanError("Configuration file not well formed. Missing environment primary atom index value.");
						return false;
					}
          break;
      }

			currentLine++;
    }
  }

  configscanner.close();

  return true;
}
Esempio n. 17
0
///////////////////////////////////////////////////////////////////////////////////////
// constructor
Updater::Updater()
{
	// defaults to web server mode
	isWebServer = true;

	// fetches and stores environment, we need to change it later
	environment <<= Environment();
	
	// accepts development versions by default
	acceptDevelVersions = true;

	// gets state variable, if not present assume starting in normal mode
	String stateStr;
	if(environment.Find("UPDATER_STATE") < 0)
		state = NormalRun;
	else
	{
		stateStr = environment.Get("UPDATER_STATE");
		if(stateStr == "INSIDEUPDATER")
			state = InsideUpdater;
		else if(stateStr == "UNINSTALLFAILED")
			state = UninstallFailed;
		else if(stateStr == "INSTALLFAILED")
			state = InstallFailed;
		else if(stateStr == "UPDATEFAILED")
			state = UpdateFailed;
		else if(stateStr == "UNINSTALLSUCCEEDED")
			state = UninstallSucceeded;
		else if(stateStr == "INSTALLSUCCEEDED")
			state = InstallSucceeded;
		else if(stateStr == "UPDATESUCCEEDED")
			state = UpdateSucceeded;
		else
			NEVER();
	}

	// gets user name
	if(state != InsideUpdater)
		user = GetUserName();
	else if(environment.Find("UPDATER_USER") < 0)
		user = "******";
	else
		user = environment.Get("UPDATER_USER");

	// get application name -- either from GetExeTitle() if in normal mode
	// or from environment if in superuser mode
	if(state != InsideUpdater && state != UninstallSucceeded)
		appName = GetExeTitle();
	else if(environment.Find("UPDATER_APPNAME") >= 0)
		appName = environment.Get("UPDATER_APPNAME");
	else
		appName = GetExeTitle(); // fallout -- should NEVER get here
	
	// setup appName depending fields
	SetAppName(appName);
	
	// sets default confirm for install and uninstall
	confirmInstall = true;
	confirmUninstall = true;
	
	// no desktop icon installation by default
	desktopIcon = false;
	
	// setup default user choices on errors
	installBehaviour = AbortExecution;
	noInstallBehaviour = AbortExecution;
	updateBehaviour = AskUser;
}
Esempio n. 18
0
static UBOOL D3D9CompileShaderWrapper(
	const TCHAR* ShaderFilename,
	const TCHAR* FunctionName,
	const TCHAR* ShaderProfile,
	DWORD CompileFlags,
	const FShaderCompilerEnvironment& InEnvironment,
	const vector<D3DXMACRO>& Macros,
	FShaderCompilerOutput& Output,
	vector<FD3D9ConstantDesc>& Constants,
	FString& DisassemblyString,
	FString& ErrorString
	)
{
	const FString& SourceFile = LoadShaderSourceFile(ShaderFilename);

	TRefCountPtr<ID3DXBuffer> Shader;
	TRefCountPtr<ID3DXBuffer> Errors;
	FD3DIncludeEnvironment Environment(InEnvironment);
	TRefCountPtr<ID3DXConstantTable> ConstantTable;
	FTCHARToANSI AnsiSourceFile(SourceFile.c_str());
	HRESULT Result = D3DXCompileShader(
						AnsiSourceFile, 
						SourceFile.size(), 
						&Macros[0], 
						&Environment, 
						TCHAR_TO_ANSI(FunctionName), 
						TCHAR_TO_ANSI(ShaderProfile),
						CompileFlags, 
						Shader.GetInitReference(),
						Errors.GetInitReference(), 
						ConstantTable.GetInitReference());

	if( FAILED(Result) )
	{
		ErrorString = TEXT("Compile Failed without warnings!");
		void* ErrorBuffer = Errors ? Errors->GetBufferPointer() : NULL;
		if( ErrorBuffer )
		{
			FANSIToTCHAR Convert((ANSICHAR*)ErrorBuffer);
			ErrorString = Convert;
		}
	}
	else
	{
		// get the ShaderCode
		INT NumShaderBytes = Shader->GetBufferSize();
		Output.ShaderCode.resize(NumShaderBytes);
		appMemcpy(&Output.ShaderCode[0], Shader->GetBufferPointer(), NumShaderBytes);

		// collect the constant table
		D3DXCONSTANTTABLE_DESC ConstantTableDesc;
		VERIFYD3DRESULT(ConstantTable->GetDesc(&ConstantTableDesc));
		for(UINT ConstantIndex = 0; ConstantIndex < ConstantTableDesc.Constants; ++ConstantIndex)
		{
			D3DXHANDLE ConstantHandle = ConstantTable->GetConstant(NULL, ConstantIndex);

			D3DXCONSTANT_DESC ConstantDesc;
			UINT NumConstants = 1;
			VERIFYD3DRESULT(ConstantTable->GetConstantDesc(ConstantHandle, &ConstantDesc, &NumConstants));

			FD3D9ConstantDesc NamedConstantDesc;
			appStrcpyANSI(NamedConstantDesc.Name, ConstantDesc.Name);
			NamedConstantDesc.bIsSampler = ConstantDesc.RegisterSet == D3DXRS_SAMPLER;
			NamedConstantDesc.RegisterIndex = ConstantDesc.RegisterIndex;
			NamedConstantDesc.RegisterCount = ConstantDesc.RegisterCount;
			Constants.push_back(NamedConstantDesc);
		}

		// disassemble a shader
		TRefCountPtr<ID3DXBuffer> DisassemblyBuffer;
		VERIFYD3DRESULT(D3DXDisassembleShader((const DWORD*)Shader->GetBufferPointer(), FALSE, NULL, DisassemblyBuffer.GetInitReference()));
		DisassemblyString = ANSI_TO_TCHAR((ANSICHAR*)DisassemblyBuffer->GetBufferPointer());
	}

	return TRUE;
}
Co<Expression> ExpressionCallWithNamedParameters::evaluate(Environment &env) const {
  env.checkTimeout(getSourceLocation());

  Co<ExpressionClosure> closure = env[name];
  /* std::cout << "getSource(): " << getSource() << std::endl; */
  /* std::cout << "getSourceLocation(): " << getSourceLocation().toAnchor() << std::endl; */
  /* std::cout << "closure->getSourceLocation(): " << closure->getSourceLocation().toAnchor() << std::endl; */
  if (closure.IsNull()) {
    throw MessagedException(getSourceLocation().toAnchor() + ": No function named " + name + " is defined.");
  }
  /* closure->setSource(getSource(), getSourceLocation()); */

  Co<ExpressionDefine> define = closure->getDefine();
  Co<Environment> closure_env(new Environment(*closure->getEnvironment()));

  // Before trying to execute this business, let's make certain the user didn't
  // pass any named parameters that don't apply. Having extras isn't going to
  // stop us from executing the function, but it probably means the caller has
  // some different intent.
  set<string> formal_names = define->getFormalNames();
  for (bindings_t::const_iterator i = bindings.begin();
       i != bindings.end();
       ++i) {
    if (formal_names.find(i->first) == formal_names.end()) {
      throw MessagedException(getSourceLocation().toAnchor() + ": I saw that you passed a parameter named " + i->first + " to function " + define->getName() + ", but " + define->getName() + " doesn't accept a parameter named " + i->first + ".");
    }
  }

  // Having cleared the appropriateness of the bindings, let's start evaluating.
  for (unsigned int i = 0; i < define->getArity(); ++i) {
    const FormalParameter &formal = define->getFormal(i);
    bool is_lazy = formal.getEvaluationMode() == FormalParameter::LAZY;

    // Look up parameter name in enumerated bindings first. If we find an
    // explicit parameter with that name, use its value.
    bindings_t::const_iterator match = bindings.find(formal.getName());
    Co<ExpressionDefine> parameter_define;
    Co<ExpressionDefine> parameter_closure;
    if (match != bindings.end()) {
      parameter_define = Co<ExpressionDefine>(new ExpressionDefine(formal.getName(), is_lazy ? match->second : match->second->evaluate(env)));
      parameter_closure = Co<ExpressionClosure>(new ExpressionClosure(parameter_define, is_lazy ? env : Environment()));
      parameter_closure->setSource(match->second->getSource(), match->second->getSourceLocation());
    } else if (!formal.getDefaultValue().IsNull()) {
      parameter_define = Co<ExpressionDefine>(new ExpressionDefine(formal.getName(), formal.getDefaultValue()->evaluate(env)));
      parameter_closure = Co<ExpressionClosure>(new ExpressionClosure(parameter_define, Environment()));
      parameter_closure->setSource(formal.getDefaultValue()->getSource(), formal.getDefaultValue()->getSourceLocation());

    // UPDATE: disallow implicits. They work, but their benefit is small and
    // risk of confusion is too high.
    // If no such parameter was enumerated, checking for a binding with that
    // name in the surrounding environment at the time of the call.
    /* else if (env.isBound(formal.getName())) { */
      /* Co<Expression> closure = env[formal.getName()]; */
      /* parameter_define = Co<ExpressionDefine>(new ExpressionDefine(formal.getName(), is_lazy ? closure : closure->evaluate(env))); */
      /* parameter_closure = Co<ExpressionClosure>(new ExpressionClosure(parameter_define, is_lazy ? env : Environment())); */
      /* parameter_closure->setSource(closure->getSource(), closure->getSourceLocation()); */
    } else {
      throw MessagedException(getSourceLocation().toAnchor() + ": Function " + define->getName() + " expects a parameter named " + formal.getName() + ". No such parameter was provided and no variable with that name was defined.");
    }

    closure_env->replace(define->getFormal(i).getName(), parameter_closure);
  }

  try {
    return closure->evaluate(*closure_env);
  } catch (Co<Expression> return_value) {
    return return_value;
  } catch (UnlocatedException e) {
    throw MessagedException(getSourceLocation().toAnchor() + ": " + e.GetMessage());
  }
}
Esempio n. 20
0
void IGame_Persistent::OnAppStart	()
{
#ifndef _EDITOR
	Environment().load				();
#endif    
}
Esempio n. 21
0
Func::Func(const std::string& name, const std::vector<Var>& arguments,
           const std::vector<Var>& results, const Stmt& body, Kind kind)
    : Func(name, arguments, results, body, Environment(), kind) {
}
Esempio n. 22
0
  void loadLevel(int level, bool ascending) {
    std::wstring filename;
    int numWalls = 0;
    wall *walls = NULL;
    
    switch (level) {
      // transition
      case -1: {
		player.setScore(player.getScore() + 50);

        filename = Gosu::resourcePrefix() + L"media/ui/transitionScreen.bmp";
        
        despawnItems();
        despawnEnemies();

		items.push_back(Item(kittensAnim, KITTENS, 135, 105));
        
        break;
      }

      // start screen
	  case 0: {
		  onStartScreen = true;
		  filename = Gosu::resourcePrefix() + L"media/ui/startScreen.bmp";

		  despawnItems();
          despawnEnemies();

		  // Set entrances and exits
          down = Stair(15, 45, false);
          up = Stair(105, 195, true);
        
          // Set player location
          if (ascending) {
            player.warp(down.x(), down.y());
          }
          else {
            player.warp(up.x(), up.y());
          }

		  break;
	  }
    
      case 1: {
        // Get map graphic
        filename = Gosu::resourcePrefix() + L"media/maps/map1.bmp";

        // Get map walls
        numWalls = 25;
        wall someWalls[] = {
           wall(0, 0, 240, 0),
           wall(0, 0, 0, 210),
           wall(0, 210, 240, 210),
           wall(240, 210, 240, 0),
           wall(0, 180, 30, 180),
           wall(30, 30, 30, 120),
           wall(30, 150, 30, 180),
           wall(30, 30, 90, 30),
           wall(90, 30, 90, 60),
           wall(90, 60, 60, 60),
           wall(30, 120, 60, 120),
           wall(60, 120, 60, 150),
           wall(30, 90, 120, 90),
           wall(120, 90, 120, 0),
           wall(90, 210, 90, 180),
           wall(60, 180, 210, 180),
           wall(210, 180, 210, 30),
           wall(210, 60, 180, 60),
           wall(210, 120, 180, 120),
           wall(210, 150, 90, 150),
           wall(90, 150, 90, 120),
           wall(90, 120, 150, 120),
           wall(150, 120, 150, 30),
           wall(150, 30, 180, 30),
           wall(150, 90, 180, 90)
        };
        walls = (wall *)realloc(walls, numWalls * sizeof(wall));
        memcpy(walls, someWalls, (numWalls * sizeof(wall)));
        
        // Set entrances and exits
        down = Stair(15, 45, false);
        up = Stair(105, 195, true);
        
        // Set player location
        if (ascending) {
          player.warp(down.x(), down.y());
        }
        else {
          player.warp(up.x(), up.y());
        }
        
        // Set items
        despawnItems();
        items.push_back(Item(ammoAnim, AMMO, 195, 75));
        items.push_back(Item(healthAnim, HEALTH, 195, 165));

        // Spawn enemies
        spawnEnemies();

        break;
      }
      case 2: {
          // Get map graphic
          filename = Gosu::resourcePrefix() + L"media/maps/map2.bmp";

          // Get map walls
          numWalls = 29;
          wall someWalls[] = {
              wall(0, 0, 240, 0),
              wall(0, 0, 0, 210),
              wall(0, 210, 240, 210),
              wall(240, 210, 240, 0),
              wall(0, 60, 30, 60),
              wall(30, 60, 30, 30),
              wall(30, 30, 90, 30),
              wall(90, 30, 90, 90),
              wall(0, 120, 90, 120),
              wall(30, 120, 30, 90),
              wall(30, 90, 60, 90),
              wall(60, 90, 60, 60),
              wall(30, 210, 30, 150),
              wall(30, 150, 120, 150),
              wall(120, 150, 120, 90),
              wall(120, 90, 150, 90),
              wall(150, 60, 150, 180),
              wall(120, 60, 180, 60),
              wall(120, 30, 120, 60),
              wall(180, 30, 180, 60),
              wall(180, 30, 210, 30),
              wall(210, 60, 240, 60),
              wall(210, 150, 240, 150),
              wall(180, 90, 180, 210),
              wall(180, 90, 210, 90),
              wall(210, 90, 210, 120),
              wall(60, 180, 120, 180),
              wall(90, 180, 90, 210),
              wall(150, 0, 150, 30)
          };
          walls = (wall *)realloc(walls, numWalls * sizeof(wall));
          memcpy(walls, someWalls, (numWalls * sizeof(wall)));
        
        // Set entrances and exits
        down = Stair(75, 195, false);
        up = Stair(15, 105, true);
        
        // Set player location
        if (ascending) {
          player.warp(down.x(), down.y());
        }
        else {
          player.warp(up.x(), up.y());
        }
        
        // Set items
        despawnItems();
        items.push_back(Item(ammoAnim, AMMO, 225, 195));
        items.push_back(Item(healthAnim, HEALTH, 15, 195));
        
        // Spawn enemies
        spawnEnemies();

        break;
      }
      case 3: {
          // Get map graphic
          filename = Gosu::resourcePrefix() + L"media/maps/map3.bmp";

          // Get map walls
          numWalls = 25;
          wall someWalls[] = {
             wall(0, 0, 240, 0),
             wall(0, 0, 0, 210),
             wall(0, 210, 240, 210),
             wall(240, 210, 240, 0),
             wall(0, 60, 30, 60),
             wall(30, 60, 30, 90),
             wall(30, 90, 60, 90),
             wall(60, 60, 60, 180),
             wall(30, 30, 90, 30),
             wall(90, 30, 90, 150),
             wall(30, 180, 180, 180),
             wall(180, 180, 180, 90),
             wall(210, 90, 210, 180),
             wall(210, 180, 240, 180),
             wall(210, 60, 210, 30),
             wall(210, 30, 120, 30),
             wall(120, 30, 120, 0),
             wall(90, 60, 180, 60),
             wall(150, 60, 150, 90),
             wall(120, 90, 180, 90),
             wall(90, 120, 150, 120),
             wall(150, 120, 150, 150),
             wall(150, 150, 120, 150),
             wall(0, 120, 30, 120),
             wall(30, 120, 30, 150)
          };
          walls = (wall *)realloc(walls, numWalls * sizeof(wall));
          memcpy(walls, someWalls, (numWalls * sizeof(wall)));
        
        // Set entrances and exits
        down = Stair(15, 135, false);
        up = Stair(-15, -15, true);
        
        // Set player location
        if (ascending) {
          player.warp(down.x(), down.y());
        }
        else {
          player.warp(up.x(), up.y());
        }
        
        // Set items
        despawnItems();
        items.push_back(Item(ammoAnim, AMMO, 135, 15));
        items.push_back(Item(healthAnim, HEALTH, 45, 75));
        items.push_back(Item(kittensAnim, KITTENS, 135, 75));

        // Spawn enemies
        spawnEnemies();

        break;
      }

      default:
        break;
    }

	if (level == 1 && ascending)
		player.startSong1();
	else if (level != 0)
		Gosu::Sample(Gosu::resourcePrefix() + L"media/sounds/levelChange.wav").play();
    
    backgroundImage.reset(new Gosu::Image(graphics(), filename, true));
    environment = Environment(numWalls, walls);
  }
Esempio n. 23
0
int main(int argc,char* argv[])
{
	int i,j,k;
	wchar_t*** Long_sentence_KOR = NULL;
	int Long_Num_KOR = 0;
	int sentence_Count_KOR[5] = {0,};
	
	wchar_t*** Long_sentence_ENG = NULL;
	int Long_Num_ENG = 0;
	int sentence_Count_ENG[5] = {0,};
	
	wchar_t** Short_sentence_KOR = NULL;
	int Short_sentence_Count_KOR = 0;

	wchar_t** Short_sentence_ENG = NULL;
	int Short_sentence_Count_ENG = 0;
	
	FILE* Short_practice_KOR;
	FILE* Short_practice_ENG;
	FILE* Long_practice_KOR;
	FILE* Long_practice_ENG;
	FILE* Info_practice;
			
	
	//ÆÄÀÏ ¿­±â
	Short_practice_KOR = fopen(argv[1],"r");
	Short_practice_ENG = fopen(argv[2],"r");
	Long_practice_KOR = fopen(argv[3],"r");
	Long_practice_ENG = fopen(argv[4],"r");
	Info_practice = fopen(argv[5],"r+");

	if(Short_practice_KOR == NULL)
	{
		printf("FILE OPEN ERROR\n");
		return -1;
	}
	if(Short_practice_ENG == NULL)
	{
		printf("FILE OPEN ERROR\n");
		return -1;
	}
	if(Long_practice_KOR == NULL)
	{
		printf("FILE OPEN ERROR\n");
		return -1;
	}
	
	if(Long_practice_ENG == NULL)
	{
		printf("FILE OPEN ERROR\n");
		return -1;
	}
	if(Info_practice == NULL)
	{
		printf("FILE OPEN ERROR\n");
		return -1;
	}
	//¸Þ¸ð¸® ÇÒ´ç
	Long_sentence_KOR = include_long_sentence(Long_practice_KOR,&Long_Num_KOR,sentence_Count_KOR);
	Long_sentence_ENG = include_long_sentence(Long_practice_ENG,&Long_Num_ENG,sentence_Count_ENG);
	Short_sentence_KOR = include_short_sentence(&Short_sentence_Count_KOR,Short_practice_KOR);
	Short_sentence_ENG = include_short_sentence(&Short_sentence_Count_ENG,Short_practice_ENG);
	
	//ÇÁ·Î±×·¥ ½ÇÇà
	First_Page();
	while(1)
	{
		i = Short_prac_Main();
		if(i == -1)
			break;
		switch(i)
		{
		case 0:
			break;
		case 1:
			if(language_Type == 1)
				i = Short_sentence_practice(Short_sentence_KOR,Short_sentence_Count_KOR);
			else if(language_Type == 2)
				i = Short_sentence_practice(Short_sentence_ENG,Short_sentence_Count_ENG);
			break;
		}
		fflush(stdin);
		
		if(language_Type == 1)
			i = Long_sentence_practice(Long_sentence_KOR,Long_Num_KOR,sentence_Count_KOR,Info_practice);
		else if(language_Type == 2)
			i = Long_sentence_practice(Long_sentence_ENG,Long_Num_ENG,sentence_Count_ENG,Info_practice);
		if(i == -1)
			break;
		fflush(stdin);
		
		
		i = Game_Main();
		if(i >= 1 && i <= 7)
			stage = i;
		if(i == -1)
			break;
		switch(i)
		{
		case 0:
			break;
		default:
			Game_Exe();
			break;
		}
		fflush(stdin);
		
		i = Environment_Main();
		if( i == -1)
			break;
		switch(i)
		{
		case 0:
			break;
		case 1:
			language_Type = Environment(Info_practice);
			break;
		}
	}
	
	//¸Þ¸ð¸® ¹Ýȯ
	for( k = 0 ; k < Long_Num_KOR ; k++)
	{
		for(j = 0 ; j < sentence_Count_KOR[i] ; j++)
			free(Long_sentence_KOR[k][j]);
	}
	free(Long_sentence_KOR);
	for( k = 0 ; k < Long_Num_ENG ; k++)
	{
		for(j = 0 ; j < sentence_Count_ENG[i] ; j++)
			free(Long_sentence_ENG[k][j]);
	}
	free(Long_sentence_ENG);
	 
	for( i = 0 ; i < Short_sentence_Count_KOR ; i++)
	{
		free(Short_sentence_KOR[i]);
	}
	free(Short_sentence_KOR);
	for( i = 0 ; i < Short_sentence_Count_ENG ; i++)
	{
		free(Short_sentence_ENG[i]);
	}
	
	//ÆÄÀÏ ´Ý±â
	free(Short_sentence_ENG);
	fclose(Short_practice_ENG);
	fclose(Short_practice_KOR);
	fclose(Long_practice_ENG);
	fclose(Long_practice_KOR);
	fclose(Info_practice);
	return 0;
}