private Expression GetInitialValue() { VccArrayTypeExpression /*?*/ arrayTypeExpression = this.ContainingLocalDeclarationsStatement.TypeExpression as VccArrayTypeExpression; var baseInit = base.InitialValue; if (baseInit == null && arrayTypeExpression != null && arrayTypeExpression.Size != null) { VccLocalDefinition loc = this.LocalVariable as VccLocalDefinition; var isSpec = loc != null ? loc.IsSpec : false; var result = new VccCreateStackArray(arrayTypeExpression.ElementType, arrayTypeExpression.Size, isSpec, SourceDummy.SourceLocation); var containingExpression = new DummyExpression(this.ContainingLocalDeclarationsStatement.ContainingBlock, SourceDummy.SourceLocation); result.SetContainingExpression(containingExpression); return(result); } else if (baseInit == null) { return(new DummyExpression(this.Name.SourceLocation)); } else { return(baseInit); } }
internal static uint ComputeSizeOf(IEnumerable <ITypeDeclarationMember> members) { uint size = 0; foreach (ITypeDeclarationMember member in members) { AnonymousFieldDefinition anonFieldDef = member as AnonymousFieldDefinition; if (anonFieldDef != null) { uint memberSize = TypeHelper.SizeOfType(anonFieldDef.Type.ResolvedType); size = Math.Max(size, memberSize); continue; } FieldDefinition /*?*/ fieldDef = member as FieldDefinition; if (fieldDef != null && !fieldDef.IsStatic && !fieldDef.IsCompileTimeConstant) { uint memberSize; VccArrayTypeExpression /*?*/ arrayType = fieldDef.Type as VccArrayTypeExpression; if (arrayType != null && arrayType.Size != null) { uint numElements = (uint)arrayType.SizeAsInt32; memberSize = numElements * TypeHelper.SizeOfType(arrayType.ElementType.ResolvedType); } else { memberSize = TypeHelper.SizeOfType(fieldDef.Type.ResolvedType); } size = Math.Max(size, memberSize); continue; } BitFieldDefinition bfieldDef = member as BitFieldDefinition; if (bfieldDef != null && !bfieldDef.IsStatic && !bfieldDef.IsCompileTimeConstant) { uint memberSize = TypeHelper.SizeOfType(bfieldDef.Type.ResolvedType); size = Math.Max(size, memberSize); continue; } } return(size); }