Jump to content

  • Log In with Google      Sign In   
  • Create Account


Jason Goepel

Member Since 15 May 2013
Offline Last Active Sep 12 2014 06:48 AM

#5153138 Global Variable Redeclaration

Posted by Jason Goepel on 12 May 2014 - 02:50 PM

I'm sorry, I mean global variables declared from the script.  I find that in any script two global variable declarations compile with no errors.

double x;
double x;
void test() {

}

It doesn't look like there is any test for duplicate names in asCCompiler::CompileGlobalVariable.

 

as_compiler.cpp(1196):

asSExprContext compiledCtx(engine);
bool preCompiled = false;
if( gvar->datatype.IsAuto() )
	preCompiled = CompileAutoType(gvar->datatype, compiledCtx, node, gvar->declaredAtNode);
if( gvar->property == 0 )
{
	gvar->property = builder->module->AllocateGlobalProperty(gvar->name.AddressOf(), gvar->datatype, gvar->ns);
	gvar->index = gvar->property->id;
}

as_module.cpp(1175):

asCGlobalProperty *asCModule::AllocateGlobalProperty(const char *name, const asCDataType &dt, asSNameSpace *ns)
{
	asCGlobalProperty *prop = engine->AllocateGlobalProperty();
	prop->name = name;
	prop->nameSpace = ns;

	// Allocate the memory for this property based on its type
	prop->type = dt;
	prop->AllocateMemory();

	// Make an entry in the address to variable map
	engine->varAddressMap.Insert(prop->GetAddressOfValue(), prop);

	// Store the variable in the module scope (the reference count is already set to 1)
	scriptGlobals.Put(prop);

	return prop;
}



#5117587 Factory for const string

Posted by Jason Goepel on 17 December 2013 - 09:49 AM

It doesn't seem like AngelScript treats literal strings a constant strings, since I am able to call non-constant functions from a literal string.

 

"Hello World".clear();




#5064168 What's everyone doing with Angelscript!

Posted by Jason Goepel on 23 May 2013 - 09:09 AM

I am a chemical engineer working for Eastman Chemical Company.  We develop a software tool which we use for chemical process control and simulation.  Our software allows users to write scripts to support their simulations and enable custom models or calculations.  We were using Microsoft's scripting engine (VBScript and JScript), but we never liked the language and were not impressed with the effort required to expose our object model through the script.

 

Microsoft appeared to have some bugs in the latest version of their scripting engine, which ships with Internet Explorer.  We didn't have control over the distribution of the scripting engine and were having too much trouble making our application work between versions.  We started looking for a replacement, and it was looking like we were going to implement Google's V8 engine or Mozilla's SpiderMonkey.... until we stumbled upon AngelScript.

 

AngelScript has almost everything we need, and the source is very readable.  Thanks Andreas!




PARTNERS