Пример #1
0
void matrix4::ToScale( const point3& scale )
{
	MakeIdent();
	_11 = scale.x;
	_22 = scale.y;
	_33 = scale.z;
}
Пример #2
0
void matrix4::ToTranslation( const point3& p )
{
	MakeIdent();
	_41 = p.x;
	_42 = p.y;
	_43 = p.z;
}
Пример #3
0
void matrix4::ToZRot( float theta )
{
	float c = (float) cos(theta);
	float s = (float) sin(theta);
	MakeIdent();
	_11 = c;
	_12 = s;
	_21 = -s;
	_22 = c;
}
Пример #4
0
void matrix4::ToYRot( float theta )
{
	float c = (float) cos(theta);
	float s = (float) sin(theta);
	MakeIdent();
	_11 = c;
	_13 = -s;
	_31 = s;
	_33 = c;
}
Пример #5
0
void matrix4::ToXRot( float theta )
{
	float c = (float) cos(theta);
	float s = (float) sin(theta);
	MakeIdent();
	_22 = c;
	_23 = s;
	_32 = -s;
	_33 = c;
}
Пример #6
0
/* Parse a list enclosed in {braces} as an infix list */
VyParseTree* ParseCurlyList(){
	VyParseTree* list = ParseListGeneric(CCURLY);

	/* Put it in an outer list containting quote-substitutions */
	VyParseTree* outerList = MakeListTree();
	VyParseTree* symb = MakeIdent();
	SetStrData(symb, "infix");
	AddToList(outerList, symb);
	AddToList(outerList, list);

	return outerList;
}
Пример #7
0
/* Parse a bracketed list as a quoted list */
VyParseTree* ParseBracketedList(){
	/* Same procedure as for a normal list, but 
	 * with CBRACKET as the end condition instead of CPAREN */
	VyParseTree* list = ParseListGeneric(CBRACKET);

	/* Put it in an outer list containting quote-substitutions */
	VyParseTree* outerList = MakeListTree();
	VyParseTree* symb = MakeIdent();
	SetStrData(symb, "quote-substitutions");
	AddToList(outerList, symb);
	AddToList(outerList, list);

	return outerList;
}
Пример #8
0
static void loop ()
{
   char string [256];
   tIdent ident;

   (void) printf ("enter strings, one per line, - terminates\n");
   do {
      (void) scanf ("%s", string);
      ident = MakeIdent (string, strlen (string));
      WriteIdent (stdout, ident);
      (void) printf ("\n");
   } while (string [0] != '-' || string [1] != '\0');
   (void) printf ("\n");
   WriteIdents ();
}
Пример #9
0
void CppBuilder::AddMakeFile(MakeFile& makefile, String package,
	const Vector<String>& all_uses, const Vector<String>& all_libraries,
	const Index<String>& common_config, bool exporting)
{
	String packagepath = PackagePath(package);
	Package pkg;
	pkg.Load(packagepath);
	String packagedir = GetFileFolder(packagepath);
	Vector<String> src = GetUppDirs();
	for(int i = 0; i < src.GetCount(); i++)
		src[i] = UnixPath(src[i]);

	bool main = HasFlag("MAIN");
	bool is_shared = HasFlag("SO");
	bool libout = !main && !HasFlag("NOLIB");
	bool win32 = HasFlag("WIN32");

	String pack_ident = MakeIdent(package);
	String outdir = "OutDir_" + pack_ident;
	String macros = "Macro_" + pack_ident;
	String macdef = "$(Macro)";
	String objext = (HasFlag("MSC") || HasFlag("EVC") ? ".obj" : ".o");

	Vector<String> x(config.GetKeys(), 1);
	Sort(x);
	for(int i = 0; i < x.GetCount(); i++) {
		if(common_config.Find(x[i]) < 0)
			macdef << " -Dflag" << x[i];
		x[i] = InitCaps(x[i]);
	}

	makefile.outdir << "$(" << outdir << ")";
	makefile.outfile << AdjustMakePath(GetFileTitle(NativePath(package)));
	if(main)
		makefile.outfile << GetTargetExt();
	else if(is_shared)
		makefile.outfile << (win32 ? ".dll" : ".so");
	else
		makefile.outfile << (win32 && HasFlag("MSC") ? ".lib" : ".a");
	makefile.output << (main ? String("$(OutDir)") : makefile.outdir) << makefile.outfile;

	if(main) {
		makefile.config << "CXX = c++\n"
			"LINKER = $(CXX)\n";
		String flags;
		if(HasFlag("DEBUG"))
			flags << " -D_DEBUG " << debug_options;
		else
			flags << ' ' << release_options;
		if(HasFlag("DEBUG_MINIMAL"))
			flags << " -ggdb -g1";
		if(HasFlag("DEBUG_FULL"))
			flags << " -ggdb -g2";
		if(is_shared && !win32)
			flags << " -fPIC ";
		flags << ' ' << Gather(pkg.option, config.GetKeys());
		makefile.config << "CFLAGS =" << flags << "\n"
			"CXXFLAGS =" << flags << "\n"
			"LDFLAGS = " << (HasFlag("DEBUG") ? debug_link : release_link) << " $(LINKOPTIONS)\n"
			"LIBPATH =";
		for(int i = 0; i < libpath.GetCount(); i++)
			makefile.config << " -L" << GetMakePath(AdjustMakePath(GetHostPathQ(libpath[i])));
		makefile.config << "\n"
			"AR = ar -sr\n\n";
		makefile.install << "\t-mkdir -p $(OutDir)\n";
		Vector<String> lib;
		String lnk;
		lnk << "$(LINKER)";
		if(!HasFlag("SHARED"))
			lnk << " -static";
		if(HasFlag("WIN32")) {
			lnk << " -mwindows";
			if(!HasFlag("GUI"))
				makefile.linkfiles << " -mconsole";
		}
		lnk << " -o $(OutFile)";
		if(HasFlag("DEBUG") || HasFlag("DEBUG_MINIMAL") || HasFlag("DEBUG_FULL"))
			lnk << " -ggdb";
		else
			lnk << (!HasFlag("OSX11") ? " -Wl,-s" : "");

		lnk << " $(LIBPATH)";
		if (!HasFlag("OSX11"))
			lnk << " -Wl,-O,2";
		lnk << " $(LDFLAGS) -Wl,--start-group ";

		makefile.linkfiles = lnk;
	}

	makefile.config << outdir << " = $(UPPOUT)"
		<< GetMakePath(AdjustMakePath(String().Cat() << package << '/' << method << '-' << Join(x, "-") << '/')) << "\n"
		<< macros << " = " << macdef << "\n";

	makefile.install << "\t-mkdir -p $(" << outdir << ")\n";

	String libdep, libfiles;

	libdep << makefile.output << ":";
	if(is_shared)
	{
		libfiles = "c++ -shared -fPIC"; // -v";
		Point p = ExtractVersion();
		if(!IsNull(p.x)) {
			libfiles << " -Xlinker --major-image-version -Xlinker " << p.x;
			if(!IsNull(p.y))
				libfiles << " -Xlinker --minor-image-version -Xlinker " << p.y;
		}
		libfiles << " -o ";
	}
	else
		libfiles = "$(AR) ";
	libfiles << makefile.output;

	Vector<String> libs = Split(Gather(pkg.library, config.GetKeys()), ' ');
	for(int i = 0; i < libs.GetCount(); i++) {
		String ln = libs[i];
		String ext = ToLower(GetFileExt(ln));
		if(ext == ".a" || ext == ".so" || ext == ".dll")
			makefile.linkfileend << " \\\n\t\t\t" << GetHostPathQ(FindInDirs(libpath, ln));
		else
			makefile.linkfileend << " \\\n\t\t\t-l" << ln;
	}
	
	for(int i = 0; i < pkg.GetCount(); i++)
		if(!pkg[i].separator) {
			String gop = Gather(pkg[i].option, config.GetKeys());
			String fn = SourcePath(package, pkg[i]);
			String ext = ToLower(GetFileExt(fn));
			bool isc = ext == ".c";
			bool isrc = (ext == ".rc" && HasFlag("WIN32"));
			bool iscpp = (ext == ".cpp" || ext == ".cc" || ext == ".cxx");
			bool isicpp = (ext == ".icpp");
			if(ext == ".brc") {
				isc = true;
				fn << "c";
			}
			if(isc || isrc || iscpp || isicpp) {
				String outfile;
				outfile << makefile.outdir << AdjustMakePath(GetFileTitle(fn)) << (isrc ? "_rc" : "") << objext;
				String srcfile = GetMakePath(MakeSourcePath(src, fn, false, exporting));
				makefile.rules << outfile << ": " << srcfile;
				Vector<String> dep = HdependGetDependencies(fn);
				Sort(dep, GetLanguageInfo());
				for(int d = 0; d < dep.GetCount(); d++) {
					String dfn = MakeSourcePath(src, dep[d], true, exporting);
					if(!IsNull(dfn))
						makefile.rules << " \\\n\t" << GetMakePath(dfn);
				}
				makefile.rules << "\n"
					"\t$(CXX) -c " << (isc ? "-x c $(CFLAGS)" : "-x c++ $(CXXFLAGS)") << " $(CINC) $(" << macros << ") "
						<< gop << " " << srcfile << " -o " << outfile << "\n\n";
				if(!libout || isicpp) {
					makefile.linkdep << " \\\n\t" << outfile;
					makefile.linkfiles << " \\\n\t\t" << outfile;
				}
				else {
					libdep << " \\\n\t" << outfile;
					libfiles << " \\\n\t\t" << outfile;
				}
			}
			else
			if(ext == ".o" || ext == ".obj" || ext == ".a" || ext == ".so" || ext == ".lib" || ext == ".dll") {
				makefile.linkdep << " \\\n\t" << fn;
				makefile.linkfiles << ' ' << fn;
			}
		}

	if(libout) {
		makefile.rules << libdep << "\n\t" << libfiles << "\n\n";
		makefile.linkdep << " \\\n\t" << makefile.output;
		makefile.linkfiles << " \\\n\t\t\t" << makefile.output;
	}
/*
	if(main) {
		if(!HasFlag("SOLARIS")&&!HasFlag("OSX11"))
			makefile.linkfiles << " \\\n\t\t-Wl,--start-group ";
		DDUMPC(all_libraries);
		for(int i = 0; i < all_libraries.GetCount(); i++) {
			String ln = all_libraries[i];
			String ext = ToLower(GetFileExt(ln));
			if(ext == ".a" || ext == ".so" || ext == ".dll")
				makefile.linkfileend << " \\\n\t\t\t" << GetHostPathQ(FindInDirs(libpath, ln));
			else
				makefile.linkfileend << " \\\n\t\t\t-l" << ln;
		}
		if(!HasFlag("SOLARIS")&&!HasFlag("OSX11"))
			makefile.linkfileend << " \\\n\t\t-Wl,--end-group\n\n";
	}
*/
}
Пример #10
0
/* Parse the next expression */
VyParseTree* Parse(){
	/* Check that we have not reached the end of the input stream; if so, return null */
	if(!MoreTokensExist()){
		return NULL;	
	}


	/* Get the next token */
	VyToken* next = GetNextToken();

	/* It's type is used to determine how to continue parsing */
	int tokType = next->type;

	/* Store the result of parsing before returning it */
	VyParseTree* expr;

	/* If it starts with a parenthesis, parse it as a list */
	if(tokType == OPAREN){
		expr =  ParseList();
	}

	/* If it begins with a quote, then parse whatever is next and quote it */
	else if(tokType == QUOTE){
		expr = ParseQuoted();
	}

	/* Parse a substitution */
	else if(tokType == DOLLAR){
		expr = ParseSubstitution();
	}
	/* Parse a splicing substitution */
	else if(tokType == DOLLARAT){
		expr = ParseSpliceSubstitution();	
	}

	/* Parse a bracketed list */
	else if(tokType == OBRACKET){
		expr = ParseBracketedList();
	}

	/* Parse an infix list (curly braces) */
	else if(tokType == OCURLY){
		expr = ParseCurlyList();	
	}
	/* If it is a number, identifier, or string then make a parse tree out of the token */
	else if(tokType == IDENT){
		VyParseTree* ident = MakeIdent();
		SetStrData(ident, next->data);
		expr = ident;
	}
	else if(tokType == NUM){
		expr = ParseNumberFromToken(next);
	}
	else if(tokType == STRING){
		VyParseTree* str = MakeString();
		SetStrData(str,next->data);
		expr = str;
	}
	/* Unexpected end of list */
	else if(tokType == CPAREN || tokType == CBRACKET || tokType == CCURLY){
		VyParseTree* err = ParseError("Unexpected end of list");
		SetPosition(err, next->pos);
		return err;
	}

	/* If there is no expression before a :, then the token type will be COLON
	 * Instead of dying, add an error */
	else if(tokType == COLON){
		VyParseTree* error = ParseError("Reference lacking instance");
		SetPosition(error, next->pos);  
		return error;
	}

	/* Handle object references: Check whether the next token is a colon.
	 * If so, then use the previously parsed expression (expr) and another
	 * expression  gotten from Parse() to create a reference node */
	VyToken* lookAhead = GetNextToken();
	if(lookAhead != NULL /* Make sure that the token list didn't end before looking at the type */
			&& lookAhead->type == COLON){ 
		VyParseTree* obj = expr;

		VyParseTree* ref = Parse();

		/* Check for validity */
		if(ref == NULL){
			expr = Reference(obj, ParseError("Incomplete reference."));  
		}else{
			expr = Reference(obj, ref);
		}
	}
	else{
		/* Backtrack one token to make up for the lookahead */
		if(lookAhead != NULL) BacktrackToken();
	}   

	/* Set the position of the current expression */
	SetPosition(expr, next->pos);

	/* If the tree is an object reference, set the position of 
	 * the first part (obj), because it wasn't gotten through a full Parse() call*/
	if(expr->type == TREE_REF){
		SetPosition(GetObj(expr), next->pos);
	}

	return expr;
}