예제 #1
0
파일: Map.cpp 프로젝트: ZealousV/ART
//Returns the height of empty pixels @ the position
float Map::GetHeightAtPosition(Point2D position){
	int y = (int)(position.Y / _tileDimension.Y);
	int x = (int)(position.X / _tileDimension.X);

	float height = 0;
	TileType charType = GetCharType(Point2D((float)x, (float)y));
	
	if(charType == TileTypeNormal) //NormalBlock
		return 0; 
	y--;
	
	while(y >= 0){
		TileType t = GetCharType(Point2D((float)x, (float)y));
		if(t != TileTypeNone && t != TileTypeDrawing)
			break;
		else {
			y--; 
			height+= _tileDimension.Y;
		}
	}

	y = (int)(position.Y / _tileDimension.Y);
	while((unsigned)y <= _mapArray.size()){
		charType = GetCharType(Point2D((float)x, (float)y));
		if(charType == TileTypeNormal) 
			break;
		else if(charType == TileTypeSlope) {
			TileData td = GetTileData(x, y);
			int y1, y2; td.GetSlope(y1, y2);

			float diff = position.X - x * _tileDimension.X;
			float ratio = (y2-y1)/_tileDimension.X;
			float h = y2>y1?_tileDimension.Y - ratio*diff:ratio*diff*-1;
			height += h;
			break;
		}
		else {
			y++; 
			height+= _tileDimension.Y;
		}
	}
	return height;
}
예제 #2
0
// LexicalAnalyzer-DFA
Token* LexicalAnalyzer::NextToken() {
  // 定义结果变量并初始化
  Token* result = new Token();
  result->aLine = this->currentLine;
  result->aColumn = this->currentColumn;
  result->indexOfCode = this->PTRnextLetter;
  int alen = this->GetSourceCode().length();
  // 如果越界就返回
  if (PTRnextLetter < 0 || PTRnextLetter >= alen) {
    return result;
  }
  // 获取下一字符来判断token
  bool successFlag = false;
  CharaType cara = GetCharType(this->GetSourceCode()[PTRnextLetter]);
  switch (cara)
  {
  // 单字符token
  case CharaType::Plus:
  case CharaType::Minus:
  case CharaType::Multiply:
  case CharaType::Divide:
  case CharaType::Not:
  case CharaType::LeftParentheses:
  case CharaType::RightParentheses:
  case CharaType::Comma:
  case CharaType::Semicolon:
    successFlag = this->GetOneCharaCalculator(result);
    break;
  // 可能双字符token
  case CharaType::Equality:
  case CharaType::LessThan:
  case CharaType::GreaterThan:
  case CharaType::And:
  case CharaType::Or:
    successFlag = this->GetTwoCharaCalculator(result);
    break;
  // 关键字和标识符
  case CharaType::Letter:
  case CharaType::UnderLine:
    successFlag = this->GetReservedCalculator(result);
    break;
  // 数值
  case CharaType::Number:
    successFlag = this->GetConstantNumber(result);
    break;
  // 空白
  case CharaType::Space:
    successFlag = this->GetSpace(result);
    break;
  // 谜
  default:
    successFlag = this->GetUnknown(result);
    break;
  }
  // 如果成功获得了token,就返回她
  if (successFlag) {
    result->length = PTRnextLetter - result->indexOfCode;
    return result;
  }
  // 否则返回空
  return NULL;
}
예제 #3
0
	//--------------------------------------------------------------------------------
	unsigned short CCRTStringHelper::GetLevel3CharType( CLocale& Locale, TCHAR& tCh )
	{
		unsigned short wResult = 0;
		GetCharType( Locale, nsWin32::CT_CType3, tCh, wResult );
		return wResult;
	}
예제 #4
0
    void VirtualMachine::LoadRuntimeClasses()
    {
        // Load only once.
        if(objectClass)
            return;

        // The first loaded module must be the runtime.
        runtimeModule = loadedModules[0];
        runtimeModule->SetRuntimeFlag(true);

        // Get basic classes.
        typeClass = GetClass(runtimeModule, "Chela.Lang.Type");
        objectClass = GetClass(runtimeModule, "Chela.Lang.Object");
        stringClass = GetClass(runtimeModule, "Chela.Lang.String");
        closureClass = GetClass(runtimeModule, "Chela.Lang.Closure");
        arrayClass = GetClass(runtimeModule, "Chela.Lang.Array");
        valueTypeClass = GetClass(runtimeModule, "Chela.Lang.ValueType");
        enumClass = GetClass(runtimeModule, "Chela.Lang.Enum");
        delegateClass = GetClass(runtimeModule, "Chela.Lang.Delegate");

        // Special attributes.
        threadStaticAttribute = GetClass(runtimeModule, "Chela.Lang.ThreadStaticAttribute");
        chelaIntrinsicAttribute = GetClass(runtimeModule, "Chela.Runtime.Core.ChelaIntrinsicAttribute");

        // Get the kernel data holding classes.
        streamHolderClass = GetTemplateClass(runtimeModule, "Chela.Compute.StreamHolder");
        streamHolder1DClass = GetTemplateClass(runtimeModule, "Chela.Compute.StreamHolder1D");
        streamHolder2DClass = GetTemplateClass(runtimeModule, "Chela.Compute.StreamHolder2D");
        streamHolder3DClass = GetTemplateClass(runtimeModule, "Chela.Compute.StreamHolder3D");
        uniformHolderClass = GetTemplateClass(runtimeModule, "Chela.Compute.UniformHolder");

        // Get the reflection classes.
        assemblyClass = GetClass(runtimeModule, "Chela.Reflection.Assembly");
        constructorInfoClass = GetClass(runtimeModule, "Chela.Reflection.ConstructorInfo");
        eventInfoClass = GetClass(runtimeModule, "Chela.Reflection.EventInfo");
        fieldInfoClass = GetClass(runtimeModule, "Chela.Reflection.FieldInfo");
        memberInfoClass = GetClass(runtimeModule, "Chela.Reflection.MemberInfo");
        methodInfoClass = GetClass(runtimeModule, "Chela.Reflection.MethodInfo");
        parameterInfoClass = GetClass(runtimeModule, "Chela.Reflection.ParameterInfo");
        propertyInfoClass = GetClass(runtimeModule, "Chela.Reflection.PropertyInfo");

        // Register associated types.
        RegisterPrimStruct(GetBoolType(), "Chela.Lang.Boolean");
        RegisterPrimStruct(GetCharType(), "Chela.Lang.Char");
        RegisterPrimStruct(GetSByteType(), "Chela.Lang.SByte");
        RegisterPrimStruct(GetByteType(), "Chela.Lang.Byte");
        RegisterPrimStruct(GetShortType(), "Chela.Lang.Int16");
        RegisterPrimStruct(GetUShortType(), "Chela.Lang.UInt16");
        RegisterPrimStruct(GetIntType(), "Chela.Lang.Int32");
        RegisterPrimStruct(GetUIntType(), "Chela.Lang.UInt32");
        RegisterPrimStruct(GetLongType(), "Chela.Lang.Int64");
        RegisterPrimStruct(GetULongType(), "Chela.Lang.UInt64");
        RegisterPrimStruct(GetSizeType(), "Chela.Lang.UIntPtr");
        RegisterPrimStruct(GetPtrDiffType(), "Chela.Lang.IntPtr");
        RegisterPrimStruct(GetFloatType(), "Chela.Lang.Single");
        RegisterPrimStruct(GetDoubleType(), "Chela.Lang.Double");
        RegisterPrimStruct(GetVoidType(), "Chela.Lang.Void");

        // Register vector associated types.
        RegisterPrimStruct(GetFloatVectorTy(this, 2), "Chela.Lang.Single2");
        RegisterPrimStruct(GetFloatVectorTy(this, 3), "Chela.Lang.Single3");
        RegisterPrimStruct(GetFloatVectorTy(this, 4), "Chela.Lang.Single4");
        RegisterPrimStruct(GetDoubleVectorTy(this, 2), "Chela.Lang.Double2");
        RegisterPrimStruct(GetDoubleVectorTy(this, 3), "Chela.Lang.Double3");
        RegisterPrimStruct(GetDoubleVectorTy(this, 4), "Chela.Lang.Double4");
        RegisterPrimStruct(GetIntVectorTy(this, 2), "Chela.Lang.Int32x2");
        RegisterPrimStruct(GetIntVectorTy(this, 3), "Chela.Lang.Int32x3");
        RegisterPrimStruct(GetIntVectorTy(this, 4), "Chela.Lang.Int32x4");
        RegisterPrimStruct(GetBoolVectorTy(this, 2), "Chela.Lang.Boolean2");
        RegisterPrimStruct(GetBoolVectorTy(this, 3), "Chela.Lang.Boolean3");
        RegisterPrimStruct(GetBoolVectorTy(this, 4), "Chela.Lang.Boolean4");

        // Register matrix associated types.
        RegisterPrimStruct(GetFloatMatrixTy(this, 3,3), "Chela.Lang.Single3x3");
        RegisterPrimStruct(GetFloatMatrixTy(this, 4,4), "Chela.Lang.Single4x4");

        // Declare them.
        typeClass->DeclarePass();
        objectClass->DeclarePass();
        stringClass->DeclarePass();
        closureClass->DeclarePass();
        arrayClass->DeclarePass();
        valueTypeClass->DeclarePass();
        enumClass->DeclarePass();
        delegateClass->DeclarePass();
        streamHolderClass->DeclarePass();
        streamHolder1DClass->DeclarePass();
        streamHolder2DClass->DeclarePass();
        streamHolder3DClass->DeclarePass();
        uniformHolderClass->DeclarePass();

        assemblyClass->DeclarePass();
        constructorInfoClass->DeclarePass();
        eventInfoClass->DeclarePass();
        fieldInfoClass->DeclarePass();
        memberInfoClass->DeclarePass();
        methodInfoClass->DeclarePass();
        parameterInfoClass->DeclarePass();
        propertyInfoClass->DeclarePass();
    }